Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
e92c5e23b8 | |
![]() |
5ae310fe26 | |
![]() |
de102e45c6 | |
![]() |
2edf31f4b5 | |
![]() |
53fc9b41f0 | |
![]() |
ad3fe5d750 | |
![]() |
9d93b500cf | |
![]() |
a6b4a318e0 | |
![]() |
d003d8f6e0 | |
![]() |
d6e4daf0df | |
![]() |
5ed52785ff | |
![]() |
b707ba62b3 |
|
@ -7,10 +7,12 @@ env:
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
|
@ -21,7 +23,7 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '13.2.1'
|
||||
xcode-version: '12.5'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
@ -32,7 +34,6 @@ jobs:
|
|||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: swift52
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
|
@ -60,3 +61,11 @@ jobs:
|
|||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
||||
|
||||
- name: 'Upload Artefact'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-artefact-big-sur
|
||||
path: |
|
||||
SwiftGdk/Sources/
|
||||
retention-days: 1
|
||||
|
|
|
@ -19,11 +19,6 @@ jobs:
|
|||
build-ubuntu-18_04-swift-latest:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: YOCKOW/Action-setup-swift@v1
|
||||
with:
|
||||
swift-version: '5.6.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
|
@ -38,16 +33,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -7,10 +7,12 @@ env:
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
|
@ -32,7 +34,6 @@ jobs:
|
|||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: swift52
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
|
@ -60,3 +61,11 @@ jobs:
|
|||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
||||
|
||||
- name: 'Upload Artefact'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-artefact-catalina
|
||||
path: |
|
||||
SwiftGdk/Sources/
|
||||
retention-days: 1
|
||||
|
|
|
@ -19,11 +19,6 @@ jobs:
|
|||
build-ubuntu-20_04-swift-latest:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: YOCKOW/Action-setup-swift@v1
|
||||
with:
|
||||
swift-version: '5.6.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
|
@ -38,16 +33,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -17,13 +17,13 @@ on:
|
|||
jobs:
|
||||
# macOS tasks
|
||||
build-mac-gtk4-swift-latest:
|
||||
runs-on: macos-12.0
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '13.3'
|
||||
xcode-version: '12.3'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
@ -44,16 +44,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
name: macOS 12
|
||||
|
||||
# Dependencies of this package
|
||||
env:
|
||||
MACOS_BREW: ${{ 'gtk+3 pango glib glib-networking gobject-introspection pkg-config jq' }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
build-mac-monterey-latest:
|
||||
runs-on: macos-12.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '13.3.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
- name: Fetch dependencies for general repository
|
||||
run: brew install $MACOS_BREW
|
||||
|
||||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
|
@ -9,7 +9,7 @@ import GIO
|
|||
import Pango
|
||||
import Cairo
|
||||
import PangoCairo
|
||||
import GdkPixBuf
|
||||
import GdkPixbuf
|
||||
|
||||
// missing header file type aliases
|
||||
public typealias GdkXEvent = _GdkXEvent
|
||||
|
|
|
@ -9,5 +9,5 @@ import GIO
|
|||
import Pango
|
||||
import Cairo
|
||||
import PangoCairo
|
||||
import GdkPixBuf
|
||||
import GdkPixbuf
|
||||
|
||||
|
|
43
Gdk-3.0.sed
43
Gdk-3.0.sed
|
@ -1,19 +1,50 @@
|
|||
s/EVENT_STOP: Bool = 5/EVENT_STOP: gboolean = 1/
|
||||
s/gdk_cursor_ref/g_object_ref/g
|
||||
s/gdk_cursor_unref/g_object_unref/g
|
||||
s/createSimilarImageSurface(format: CInt/createSimilarImageSurface(format: cairo_format_t/
|
||||
s/\(@available(., deprecated) @inlinable\) \(public init() {\)/\1 override \2/
|
||||
s/\(public init<T: AppLaunchContextProtocol>(\)appLaunchContext \(other: T)\)/\1_ \2/
|
||||
s/-> GdkAtom {/-> GdkAtom! {/g
|
||||
s/: GdkAtom/: GdkAtom!/g
|
||||
s/UnsafeMutablePointer<GdkAtom>/GdkAtom/
|
||||
s/targets: UnsafePointer<GdkAtom>/targets: UnsafePointer<GdkAtom?>/
|
||||
s/GdkAtom!.self/_GdkAtom.self/
|
||||
s/actual_property_type: AtomT/actual_property_type: UnsafeMutablePointer<GdkAtom?>/
|
||||
s/Xproperty: GdkAtom!, type: GdkAtom!/property: AtomT!, type: AtomT!/
|
||||
s/property: GdkAtom!, type: GdkAtom!/property: AtomT!, type: AtomT!/
|
||||
s/property, type/property._ptr, type._ptr/
|
||||
s/propertyGet<WindowT: WindowProtocol>/propertyGet<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/propertyChange<WindowT: WindowProtocol>/propertyChange<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/func propertyChange(property: AtomT/func propertyChange<AtomT: AtomProtocol>(property: AtomT/
|
||||
s/\(propertyGet.*\)window: WindowT, property: AtomT!, type: AtomT!/\1window: WindowT, property: UnsafeMutablePointer<GdkAtom?>, type: AtomT!/
|
||||
s/(gdk_property_get(window.window_ptr, property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), _ptr, actual_format, actual_length, data)/(gdk_property_get(window.window_ptr, _ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), property, actual_format, actual_length, data)/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol, WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propType: AtomT/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol>(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propType: AtomT, propFormat: UnsafeMutablePointer<gint>!) -> Int/selectionPropertyGet(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>, propertyFormat: UnsafeMutablePointer<gint>!) -> Int/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propFormat/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, property _ptr: UnsafeMutablePointer<GdkAtom?>, propertyFormat/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propertyType: UnsafeMutablePointer<GdkAtom.>!, propFormat:/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!, propertyFormat:/
|
||||
s/targets: GdkAtom/targets: UnsafePointer<GdkAtom?>/
|
||||
s/gdk_selection_property_get(requestor.window_ptr, data, propType._ptr, propFormat)/gdk_selection_property_get(requestor.window_ptr, data, propertyType, propertyFormat)/
|
||||
s/gdk_selection_property_get(window_ptr, data, propType._ptr, propFormat)/gdk_selection_property_get(window_ptr, data, propertyType, propertyFormat)/
|
||||
s/gdk_selection_property_get(requestor.window_ptr, data, _ptr, propFormat)/gdk_selection_property_get(requestor.window_ptr, data, _ptr, propertyFormat)/
|
||||
s/\(@available(., deprecated) @inlinable\) \(public init() {\)/\1 override \2/
|
||||
s/property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type._ptr/_ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type/
|
||||
s/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, propType._ptr, propFormat))/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, propertyType, propertyFormat))/
|
||||
s/Int(gdk_selection_property_get(window_ptr, data, propType._ptr, propFormat))/Int(gdk_selection_property_get(window_ptr, data, propertyType, propertyFormat))/
|
||||
s/Int(gdk_selection_property_get(requestor.window_ptr, data, _ptr, propFormat))/Int(gdk_selection_property_get(requestor.window_ptr, data, _ptr, propertyFormat))/
|
||||
s/gdk_gl_context_set_use_es(gl_context_ptr, gint(newValue))/gdk_gl_context_set_use_es(gl_context_ptr, newValue ? 1 : 0)/
|
||||
s/: \([A-Za-z.]*Notify[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Func[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Marshal[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Marshaller[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Callback[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Accumulator[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Handler[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transformer[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transform[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transformer =\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Hook[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Mapping[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Listener[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*ListenerInit[,)]\)/: @escaping \1/g
|
||||
s/GObject.Callback/GLibObject.Callback/g
|
||||
s/func endPaint/@available(*, deprecated) func endPaint/
|
||||
s/public func beep/@available(*, deprecated) public func beep/
|
||||
s/public func errorTrap/@available(*, deprecated) public func errorTrap/
|
||||
s/public func flush/@available(*, deprecated) public func flush/
|
||||
s/public func setDoubleClickTime/@available(*, deprecated) public func setDoubleClickTime/
|
||||
s/_ptr.pointee.state = newValue.value/_ptr.pointee.state = newValue.rawValue/
|
||||
s/targets: GdkAtom/targets: UnsafePointer<GdkAtom?>/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// swift-tools-version:5.6
|
||||
// swift-tools-version:5.2
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
@ -6,10 +6,9 @@ let package = Package(
|
|||
name: "Gdk",
|
||||
products: [ .library(name: "Gdk", targets: ["Gdk"]) ],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/rhx/gir2swift.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftGdkPixbuf.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftPangoCairo.git", branch: "main"),
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("main")),
|
||||
.package(name: "GdkPixbuf", url: "https://github.com/rhx/SwiftGdkPixbuf.git", .branch("main")),
|
||||
.package(name: "PangoCairo", url: "https://github.com/rhx/SwiftPangoCairo.git", .branch("main")),
|
||||
],
|
||||
targets: [
|
||||
.systemLibrary(name: "CGdk", pkgConfig: "gdk-3.0",
|
||||
|
@ -19,19 +18,8 @@ let package = Package(
|
|||
]),
|
||||
.target(
|
||||
name: "Gdk",
|
||||
dependencies: [
|
||||
"CGdk",
|
||||
.product(name: "gir2swift", package: "gir2swift"),
|
||||
.product(name: "GdkPixBuf", package: "SwiftGdkPixbuf"),
|
||||
.product(name: "PangoCairo", package: "SwiftPangoCairo"),
|
||||
],
|
||||
swiftSettings: [
|
||||
.unsafeFlags(["-suppress-warnings"], .when(configuration: .release)),
|
||||
.unsafeFlags(["-suppress-warnings", "-Xfrontend", "-serialize-debugging-options"], .when(configuration: .debug)),
|
||||
],
|
||||
plugins: [
|
||||
.plugin(name: "gir2swift-plugin", package: "gir2swift")
|
||||
]
|
||||
dependencies: ["CGdk", "GdkPixbuf", "PangoCairo"],
|
||||
swiftSettings: [.unsafeFlags(["-Xfrontend", "-serialize-debugging-options"], .when(configuration: .debug))]
|
||||
),
|
||||
.testTarget(name: "GdkTests", dependencies: ["Gdk"]),
|
||||
]
|
||||
|
|
122
README.md
122
README.md
|
@ -13,43 +13,82 @@ For up to date (auto-generated) reference documentation, see https://rhx.github.
|
|||
|
||||
Support for gtk 4 was added via the `gtk4` branch.
|
||||
|
||||
Version 15 of gir2swift provides a Package Manager Plugin. This requires Swift 5.6 or higher.
|
||||
(older versions can be used via the [swift52](https://github.com/rhx/SwiftGdk/tree/swift52) branch).
|
||||
Version 12 of gir2swift pulls in [PR#10](https://github.com/rhx/gir2swift/pull/10), addressing several issues:
|
||||
|
||||
- Improvements to the Build experience and LSP [rhx/SwiftGtk#34](https://github.com/rhx/SwiftGtk/issues/34)
|
||||
- Fix issues with LLDB [rhx/SwiftGtk#39](https://github.com/rhx/SwiftGtk/issues/39)
|
||||
- **Controversial:** Implicitly marks all declarations named "priv" as if they had attribute `private=1`
|
||||
- Prevents all "Private" records from generating unless generated in their instance record
|
||||
- `-a` option generates all records
|
||||
- Introduces CI
|
||||
- For Class metadata types no longer generates class wrappers. Ref structs now contain static method which returnes the GType of the class and instance of the Class metatype wrapped in the Ref struct.
|
||||
- Adds final class GWeak<T> where T could be any Ref struct of a type which supports ARC. This class is a property wrapper which contains weak reference to any instance of T. This is especially beneficial for capture lists.
|
||||
- Adds support for weak observation.
|
||||
- Constructors and factories of GObjectInitiallyUnowned classes now consume floating reference upon initialisation as advised by [the GObject documentation](https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html)
|
||||
|
||||
Partially implemented:
|
||||
- Typed signal generation. Issues shown in [rhx/SwiftGtk#35](https://github.com/rhx/SwiftGtk/issues/35) hat remain to be addressed are listed here: [mikolasstuchlik/gir2swift#2](https://github.com/mikolasstuchlik/gir2swift/pull/2).
|
||||
|
||||
### Other Notable changes
|
||||
|
||||
Version 11 introduces a new type system into `gir2swift`,
|
||||
to ensure it has a representation of the underlying types.
|
||||
This is necessary for Swift 5.3 onwards, which requires more stringent casts.
|
||||
As a consequence, accessors can accept and return idiomatic Swift rather than
|
||||
underlying types or pointers.
|
||||
This means that a lot of the changes will be source-breaking for code that
|
||||
was compiled against libraries built with earlier versions of `gir2swift`.
|
||||
|
||||
* Requires Swift 5.2 or later (Swift 5.3 is required for the `gtk4` branch)
|
||||
* Uses the namespace referenced in the `gir` file
|
||||
* Wrapper code is now `@inlinable` to enable the compiler to optimise away most of the wrappers
|
||||
* Parameters and return types use more idiomatic Swift (e.g. `Ref` wrappers instead of pointers, `Int` instead of `gint`, etc.)
|
||||
* Functions that take or return records now are templated instead of using the type-erased Protocol
|
||||
* `ErrorType` has been renamed `GLibError` to ensure it neither clashes with `Swift.Error` nor the `GLib.ErrorType` scanner enum
|
||||
* Parameters or return types for records/classes now use the corresponding, lightweight Swift `Ref` wrapper instead of the underlying pointer
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Swift 5.6 or higher
|
||||
### Swift
|
||||
|
||||
To build, download Swift from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well). Test that your compiler works using `swift --version`, which should give you something like
|
||||
To build, you need at least Swift 5.2 (Swift 5.3 is required for `gtk4`; also some Linux distributions have issues and seem to **require at least Swift 5.5**), download from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well). Test that your compiler works using `swift --version`, which should give you something like
|
||||
|
||||
$ swift --version
|
||||
swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
|
||||
Target: x86_64-apple-darwin20.3.0
|
||||
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
|
||||
Target: x86_64-apple-darwin20.5.0
|
||||
|
||||
on macOS, or on Linux you should get something like:
|
||||
|
||||
$ swift --version
|
||||
Swift version 5.6.1 (swift-5.6.1-RELEASE)
|
||||
Swift version 5.4 (swift-5.4-RELEASE)
|
||||
Target: x86_64-unknown-linux-gnu
|
||||
|
||||
### Gtk 3.22 or higher
|
||||
|
||||
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66, 2.68, 2.70 and 2.72, and gdk/gtk 3.22 and 3.24 as well as 4.0, 4.2, 4.4, and 4.6 on the gtk4 branch. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
|
||||
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66 and 2.68, and gdk/gtk 3.22 and 3.24 as well as 4.0 and 4.2 on the gtk4 branch. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
|
||||
|
||||
#### Linux
|
||||
|
||||
##### Ubuntu
|
||||
|
||||
On Ubuntu 20.04 and 22.04 you can use the glib that comes with the distribution. Just install with the `apt` package manager:
|
||||
On Ubuntu 18.04 and 16.04 you can use the gtk that comes with the distribution. Just install with the `apt` package manager:
|
||||
|
||||
sudo apt update
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libcogl-dev gir1.2-cogl-1.0 libcogl-pango-dev gir1.2-coglpango-1.0 libgdk-pixbuf2.0-dev gir1.2-gdkpixbuf-2.0 libgirepository1.0-dev libxml2-dev
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libgirepository1.0-dev libxml2-dev
|
||||
|
||||
If you prefer a newer version of gtk, you can also install it from the GNOME 3 Staging PPA (see https://launchpad.net/~gnome3-team/+archive/ubuntu/gnome3-staging), but be aware that this can be a bit dangerous (as this removes packages that can be vital, particularly if you use a GNOME-based desktop), so only do this if you know what you are doing:
|
||||
|
||||
sudo add-apt-repository ppa:gnome3-team/gnome3-staging
|
||||
sudo apt update
|
||||
sudo apt dist-upgrade
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libgirepository1.0-dev libxml2-dev
|
||||
|
||||
##### Fedora
|
||||
|
||||
On Fedora, you can use the gtk that comes with the distribution. Just install with the `dnf` package manager:
|
||||
On Fedora 29, you can use the gtk that comes with the distribution. Just install with the `dnf` package manager:
|
||||
|
||||
sudo dnf install gtk3-devel pango-devel cogl-devel gdk-pixbuf2-devel cairo-devel cairo-gobject-devel glib2-devel gobject-introspection-devel libxml2-devel
|
||||
sudo dnf install gtk3-devel pango-devel cairo-devel cairo-gobject-devel glib2-devel gobject-introspection-devel libxml2-devel
|
||||
|
||||
#### macOS
|
||||
|
||||
|
@ -63,22 +102,16 @@ On macOS, you can install gdk and gtk using HomeBrew (for setup instructions, se
|
|||
Normally, you don't build this package directly (but for testing you can - see 'Building' below). Instead you need to embed SwiftGdk into your own project using the [Swift Package Manager](https://swift.org/package-manager/). After installing the prerequisites (see 'Prerequisites' below), add `SwiftGdk` as a dependency to your `Package.swift` file, e.g.:
|
||||
|
||||
```Swift
|
||||
// swift-tools-version:5.6
|
||||
// swift-tools-version:5.3
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(name: "MyPackage",
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/rhx/gir2swift.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftGdk.git", branch: "gtk3"),
|
||||
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("main")),
|
||||
.package(name: "Gdk", url: "https://github.com/rhx/SwiftGdk.git", .branch("gtk3")),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "MyPackage",
|
||||
dependencies: [
|
||||
.product(name: "Gdk", package: "SwiftGdk")
|
||||
]
|
||||
)
|
||||
]
|
||||
targets: [.target(name: "MyPackage", dependencies: ["Gdk"])]
|
||||
)
|
||||
```
|
||||
|
||||
|
@ -90,9 +123,18 @@ Normally, you don't build this package directly, but you embed it into your own
|
|||
|
||||
git clone https://github.com/rhx/SwiftGdk.git
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
swift build
|
||||
swift test
|
||||
|
||||
Please note that on macOS, due to a bug in the Swift Package Manager prior to Swift 5.4,
|
||||
if you have Xcode-12.4 or older, you need to pass in the build flags manually,
|
||||
i.e. instead of `swift build` and `swift test` you can run
|
||||
|
||||
swift build `./run-gir2swift.sh flags -noUpdate`
|
||||
swift test `./run-gir2swift.sh flags -noUpdate`
|
||||
|
||||
|
||||
### Xcode
|
||||
|
||||
On macOS, you can build the project using Xcode instead. To do this, you need to create an Xcode project first, then open the project in the Xcode IDE:
|
||||
|
@ -103,27 +145,25 @@ On macOS, you can build the project using Xcode instead. To do this, you need t
|
|||
|
||||
After that, use the (usual) Build and Test buttons to build/test this package.
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
You can generate documentation using the [DocC plugin](https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/). To preview documentation matching your local installation, simply run
|
||||
You can find reference documentation inside the [docs](https://rhx.github.io/SwiftGLib/) folder.
|
||||
This was generated using the [jazzy](https://github.com/realm/jazzy) tool.
|
||||
If you want to generate your own documentation, matching your local installation,
|
||||
you can use the `generate-documentation.sh` script in the repository.
|
||||
Make sure you have [sourcekitten](https://github.com/jpsim/SourceKitten) and [jazzy](https://github.com/realm/jazzy) installed, e.g. on macOS:
|
||||
|
||||
swift package --disable-sandbox preview-documentation
|
||||
|
||||
then navigate to the URL shown for the local preview server. Make sure you have JavaScript enabled in your browser.
|
||||
|
||||
Alternatively, you can create static documentation using [jazzy](https://github.com/realm/jazzy).
|
||||
Make sure you have [sourcekitten](https://github.com/jpsim/SourceKitten) and [jazzy](https://github.com/realm/jazzy) installed, e.g. on macOS (x86_64):
|
||||
|
||||
brew install ruby sourcekitten
|
||||
/usr/local/opt/ruby/bin/gem install jazzy
|
||||
./generate-jazzy.sh
|
||||
brew install sourcekitten
|
||||
sudo gem install jazzy
|
||||
./run-gir2swift.sh
|
||||
./generate-documentation.sh
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Here are some common errors you might encounter and how to fix them.
|
||||
|
||||
### Missing `.gir` Files
|
||||
|
||||
If you get an error such as
|
||||
|
||||
Girs located at
|
||||
|
@ -132,15 +172,23 @@ If you get an error such as
|
|||
Make sure that you have the relevant `gobject-introspection` packages installed (as per the Pre-requisites section), including their `.gir` and `.pc` files.
|
||||
|
||||
### Old Swift toolchain or Xcode
|
||||
|
||||
If, when you run `swift build`, you get a `Segmentation fault (core dumped)` or circular dependency error such as
|
||||
|
||||
warning: circular dependency detected while parsing pangocairo: harfbuzz -> freetype2 -> harfbuzz
|
||||
|
||||
this probably means that your Swift toolchain is too old, particularly on Linux.
|
||||
Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).
|
||||
this probably means that your Swift toolchain is too old, particularly on Linux (at the time of this writing, some Linux distributions require at least Swift 5.5). Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).
|
||||
|
||||
If you get an older version, make sure that the right version of the swift compiler is found first in your `PATH`. On macOS, use xcode-select to select and install the latest version, e.g.:
|
||||
|
||||
sudo xcode-select -s /Applications/Xcode.app
|
||||
xcode-select --install
|
||||
|
||||
### Known Issues
|
||||
|
||||
* When building, a lot of warnings appear. This is largely an issue with automatic `RawRepresentable` conformance in the Swift Standard library. As a workaround, you can turn this off by passing the `-Xswiftc -suppress-warnings` parameter when building.
|
||||
|
||||
* The current build system does not support directory paths with spaces (e.g. the `My Drive` directory used by Google Drive File Stream).
|
||||
|
||||
* BUILD_DIR is not supported in the current build system.
|
||||
|
||||
As a workaround, you can use the old build scripts, e.g. `./build.sh` (instead of `run-gir2swift.sh` and `swift build`) to build a package.
|
||||
|
|
|
@ -29,3 +29,13 @@ class GdkTests: XCTestCase {
|
|||
XCTAssertEqual(done, true)
|
||||
}
|
||||
}
|
||||
|
||||
extension GdkTests {
|
||||
static var allTests : [(String, (GdkTests) -> () throws -> Void)] {
|
||||
return [
|
||||
("testEvent", testEvent),
|
||||
("testEventType", testEventType),
|
||||
("testThreadsAddIdle", testThreadsAddIdle),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import XCTest
|
||||
@testable import GdkTests
|
||||
|
||||
XCTMain([
|
||||
testCase(GdkTests.allTests),
|
||||
])
|
1
build.sh
1
build.sh
|
@ -4,4 +4,5 @@
|
|||
# to determine compiler and linker flags
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
exec swift build --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#
|
||||
VER=3.0
|
||||
GLIB_VER=2.0
|
||||
JAZZY_VER=3.24.33
|
||||
JAZZY_VER=3.24.30
|
||||
Mod=Gdk
|
||||
Module=${Mod}-$VER
|
||||
module=`echo "${Module}" | tr '[:upper:]' '[:lower:]'`
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
#
|
||||
. ./config.sh
|
||||
./clean.sh
|
||||
exec rm -rf .swiftpm Package.pins Packages Package.resolved docs .docs.old Sources/${Mod}/*-*.swift Sources/${Mod}/${Module}.swift Sources/${Mod}/Swift${Mod}.swift ${Mod}.xcodeproj
|
||||
exec rm -rf Package.pins Packages Package.resolved Sources/${Mod}/*-*.swift Sources/${Mod}/${Module}.swift Sources/${Mod}/Swift${Mod}.swift ${Mod}.xcodeproj
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# to determine compiler and linker flags
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
if [ -z "$@" ]; then
|
||||
JAZZY_ARGS="--theme fullwidth --author René Hexel --author_url https://experts.griffith.edu.au/9237-rene-hexel --github_url https://github.com/rhx/Swift$Mod --github-file-prefix https://github.com/rhx/Swift$Mod/tree/generated --root-url http://rhx.github.io/Swift$Mod/ --output docs"
|
||||
fi
|
||||
|
@ -15,3 +16,4 @@ sourcekitten doc --spm --module-name $Mod -- --build-path "$BUILD_DIR" \
|
|||
$CCFLAGS $LINKFLAGS > "$BUILD_DIR/$Mod-doc.json"
|
||||
jazzy --sourcekitten-sourcefile "$BUILD_DIR/$Mod-doc.json" --clean \
|
||||
--module-version $JAZZY_VER --module $Mod $JAZZY_ARGS "$@"
|
||||
rm -f .build 2>/dev/null
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Recursive swift code wrapper generator for gobject-introspection (.gir) files.
|
||||
# This calls the non-recursive gir-to-swift.sh to do the heavy lifting.
|
||||
#
|
||||
. ./config.sh
|
||||
./package.sh update
|
||||
if [ ! -x "${GIR2SWIFT_PATH}/gir2swift" -a \
|
||||
! -e "$BUILD_DIR/checkouts/gir2swift" ] ; then
|
||||
mkdir -p "$BUILD_DIR/checkouts" 2>/dev/null
|
||||
pushd "$BUILD_DIR/checkouts" >/dev/null
|
||||
git clone https://github.com/rhx/gir2swift.git
|
||||
popd >/dev/null 2>&1
|
||||
fi
|
||||
if [ ! -x "${GIR2SWIFT_PATH}/gir2swift" ] &&
|
||||
! -e "$BUILD_DIR/checkouts/gir2swift/.build/release/gir2swift" >/dev/null 2>&1 ; then
|
||||
pushd "$BUILD_DIR/checkouts/gir2swift" >/dev/null
|
||||
./build.sh
|
||||
fi
|
||||
export PATH="$PWD/.build/release:${PATH}"
|
||||
popd >/dev/null 2>&1
|
||||
export PACKAGES="${BUILD_DIR}/checkouts"
|
||||
[ -e $PACKAGES ] || export PACKAGES=Packages
|
||||
if which parallel >/dev/null ; then
|
||||
for gen in $PACKAGES/*/gir-to-swift.sh ; do \
|
||||
echo echo \"Generate Swift Wrapper for `basename $(dirname $gen) | cut -d- -f1`\" \; \
|
||||
"( cd `dirname $gen` && ./`basename $gen` $@ )" ; \
|
||||
done | $TAC | parallel
|
||||
else
|
||||
for gen in $PACKAGES/*/gir-to-swift.sh ; do
|
||||
echo "Generate Swift Wrapper for `basename $(dirname $gen) | cut -d- -f1`"
|
||||
( cd `dirname $gen` && ./`basename $gen` "$@" )
|
||||
done
|
||||
fi
|
||||
. ./gir-to-swift.sh "$@"
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Swift code wrapper generator for gobject-introspection (.gir) files.
|
||||
# This needs an installed `gir2swift' executable (github.com/rhx/gir2swift)
|
||||
#
|
||||
. ./config.sh
|
||||
mkdir -p Sources/${Mod}
|
||||
GOBJECT_LIBDIR=`pkg-config --libs-only-L gobject-introspection-1.0 2>/dev/null | tr ' ' '\n' | grep gobject-introspection | tail -n1 | cut -c3-`
|
||||
GOBJECT_DIR=`dirname "${GOBJECT_LIBDIR}"`
|
||||
for prefix in $PREFIX /opt/homebrew /usr/local /usr $GOBJECT_DIR ; do
|
||||
gir_dir=${prefix}/share/gir-1.0
|
||||
gir=${gir_dir}/${Module}.gir
|
||||
if [ -e "${gir}" ] ; then
|
||||
export GIR=${gir}
|
||||
export GIR_DIR=${gir_dir}
|
||||
fi
|
||||
done
|
||||
if [ ! -e "${GIR}" ] ; then
|
||||
echo "*** ${GIR} does not exist!"
|
||||
echo "Make sure libgirepository1.0-dev is installed"
|
||||
echo "and can be found in /usr /usr/local or by pkg-config!"
|
||||
exit 1
|
||||
fi
|
||||
gir2swift -o Sources/${Mod} -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}"
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
GIR_NAME="Gdk-3.0"
|
||||
|
||||
function generate_arg-path_arg-g2s-exec_arg-gir-pre_arg-gir-path {
|
||||
local PACKAGE_PATH=$1
|
||||
local G2S_EXEC=$2
|
||||
local GIR_PRE=$3
|
||||
local GIR_PATH=$4
|
||||
|
||||
local CALLER=$PWD
|
||||
|
||||
cd $PACKAGE_PATH
|
||||
|
||||
local NAME=$(package_name)
|
||||
local GIR_PRE_ARGS=`for FILE in ${GIR_PRE}; do echo -n "-p ${GIR_PATH}/${FILE}.gir "; done`
|
||||
|
||||
bash -c "${G2S_EXEC} -o Sources/${NAME} ${GIR_PRE_ARGS} ${GIR_PATH}/${GIR_NAME}.gir"
|
||||
|
||||
cd $CALLER
|
||||
}
|
||||
|
||||
case $1 in
|
||||
gir-name) echo $GIR_NAME;;
|
||||
generate) echo $(generate_arg-path_arg-g2s-exec_arg-gir-pre_arg-gir-path "$2" "$3" "$4" "$5");;
|
||||
esac
|
|
@ -1,5 +0,0 @@
|
|||
version: 1
|
||||
gir-name: Gdk-3.0
|
||||
pkg-config: gdk-3.0
|
||||
output-directory: Sources/Gdk
|
||||
alpha-names: true
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
## Swift package with fetched dependencies is required to run scipt in gir2swift package. Use option -noUpdate to prevent update.
|
||||
if ! [[ $@ == *'-noUpdate'* ]]
|
||||
then
|
||||
swift package update
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
## Returns flags needed for macOS compilation (experimental)
|
||||
flags) .build/checkouts/gir2swift/gir2swift-generation-driver.sh c-flags $PWD ;;
|
||||
## Removes all generaed files
|
||||
clean) .build/checkouts/gir2swift/gir2swift-generation-driver.sh remove-generated $PWD ;;
|
||||
## Defaults to generation
|
||||
*) .build/checkouts/gir2swift/gir2swift-generation-driver.sh generate $PWD ;;
|
||||
esac
|
1
test.sh
1
test.sh
|
@ -4,4 +4,5 @@
|
|||
# that the swift wrapper code exists
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
exec swift test --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# and pass them to subprojects, based on the configured -I flags.
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
./package.sh generate-xcodeproj "$@"
|
||||
[ ! -e ${Mod}.xcodeproj/Configs ] || \
|
||||
( cd ${Mod}.xcodeproj/Configs && \
|
||||
|
|
Loading…
Reference in New Issue