Compare commits

...

16 Commits

Author SHA1 Message Date
Rene Hexel 56901559e8 Fix typos 2022-04-27 06:24:19 +10:00
Rene Hexel 663e0f6de7 Add swift52 workflows 2022-04-26 06:25:29 +10:00
Rene Hexel 39d120470b Swift 5.2 branch 2022-04-16 11:18:28 +10:00
Rene Hexel 64c2313f33 Update for Xcode-13.2.1 2022-01-20 08:55:39 +10:00
Rene Hexel e92c5e23b8 Bump JAZZY_VER to 3.24.30 2021-07-25 16:32:35 +10:00
Rene Hexel 5ae310fe26 Simplify manifest: let gir2swift do sed/awk post-processing 2021-07-25 16:15:33 +10:00
Rene Hexel de102e45c6 Only upload Sources 2021-07-25 16:15:33 +10:00
Rene Hexel 2edf31f4b5 Merge branch 'main' of github.com:rhx/SwiftGdk 2021-07-10 09:35:04 +10:00
Rene Hexel 53fc9b41f0 Update Xcode versions 2021-07-10 09:34:09 +10:00
Rene Hexel ad3fe5d750 Note Swift 5.5 and update Troubleshooting section 2021-06-10 20:02:54 +10:00
Rene Hexel 9d93b500cf Correct gir2swift path 2021-06-10 20:02:09 +10:00
Rene Hexel a6b4a318e0 Merge branch 'development' 2021-05-09 13:20:57 +10:00
Rene Hexel d003d8f6e0 s/development/main/ 2021-05-09 12:06:05 +10:00
Rene Hexel d6e4daf0df Merge branch 'development' 2021-05-09 12:05:36 +10:00
Rene Hexel 5ed52785ff Add /opt/homebrew to GIR search path prefix 2021-01-28 06:25:11 +10:00
Rene Hexel b707ba62b3 Add gir2swift to example Package.swift 2021-01-17 10:36:36 +10:00
10 changed files with 53 additions and 100 deletions

View File

@ -7,12 +7,10 @@ env:
on:
push:
branches:
- development
- main
- swift52
pull_request:
branches:
- development
- main
- swift52
jobs:
# macOS tasks
@ -23,7 +21,7 @@ jobs:
uses: actions/checkout@v2
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '12.3'
xcode-version: '13.2.1'
- name: Print Swift version to confirm
run: swift --version
@ -34,6 +32,7 @@ jobs:
- name: Checkout SwiftGdk
uses: actions/checkout@v2
with:
ref: swift52
path: SwiftGdk
- name: Build Swift Wrappers
@ -61,11 +60,3 @@ 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/
retention-days: 1

View File

@ -19,6 +19,11 @@ 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
@ -33,23 +38,16 @@ 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 -Xswiftc -suppress-warnings
swift build
cd ..
- name: Test SwiftGdk
run: |
cd SwiftGdk
swift test -Xswiftc -suppress-warnings
swift test
cd ..
- name: Remove unneeded files and archive artefacts
@ -64,5 +62,5 @@ jobs:
with:
name: build-artefact-18.04-5.3
path: |
SwiftGdk/
SwiftGdk/Sources/
retention-days: 1

View File

@ -7,12 +7,10 @@ env:
on:
push:
branches:
- development
- main
- swift52
pull_request:
branches:
- development
- main
- swift52
jobs:
# macOS tasks
@ -23,7 +21,7 @@ jobs:
uses: actions/checkout@v2
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '12.3'
xcode-version: '12.4'
- name: Print Swift version to confirm
run: swift --version
@ -34,6 +32,7 @@ jobs:
- name: Checkout SwiftGdk
uses: actions/checkout@v2
with:
ref: swift52
path: SwiftGdk
- name: Build Swift Wrappers
@ -61,11 +60,3 @@ jobs:
swift package clean
rm -rf .build/repositories
cd ..
- name: 'Upload Artefact'
uses: actions/upload-artifact@v2
with:
name: build-artefact-catalina
path: |
SwiftGdk/
retention-days: 1

View File

@ -19,6 +19,11 @@ 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
@ -33,23 +38,16 @@ 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 -Xswiftc -suppress-warnings
swift build
cd ..
- name: Test SwiftGdk
run: |
cd SwiftGdk
swift test -Xswiftc -suppress-warnings
swift test
cd ..
- name: Remove unneeded files and archive artefacts
@ -64,5 +62,5 @@ jobs:
with:
name: build-artefact-20.04-5.3
path: |
SwiftGdk/
SwiftGdk/Sources/
retention-days: 1

View File

@ -17,13 +17,13 @@ on:
jobs:
# macOS tasks
build-mac-gtk4-swift-latest:
runs-on: macos-latest
runs-on: macos-12.0
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '12.3'
xcode-version: '13.3'
- name: Print Swift version to confirm
run: swift --version
@ -44,23 +44,16 @@ 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 -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
swift build
cd ..
- name: Test SwiftGdk
run: |
cd SwiftGdk
swift test -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
swift test
cd ..
- name: Remove unneeded files and archive artefacts
@ -75,5 +68,5 @@ jobs:
with:
name: build-artefact-macos-gtk4
path: |
SwiftGdk/
SwiftGdk/Sources/
retention-days: 1

View File

@ -6,9 +6,9 @@ let package = Package(
name: "Gdk",
products: [ .library(name: "Gdk", targets: ["Gdk"]) ],
dependencies: [
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("development")),
.package(name: "GdkPixbuf", url: "https://github.com/rhx/SwiftGdkPixbuf.git", .branch("development")),
.package(name: "PangoCairo", url: "https://github.com/rhx/SwiftPangoCairo.git", .branch("development")),
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("swift52")),
.package(name: "GdkPixbuf", url: "https://github.com/rhx/SwiftGdkPixbuf.git", .branch("swift52")),
.package(name: "PangoCairo", url: "https://github.com/rhx/SwiftPangoCairo.git", .branch("swift52")),
],
targets: [
.systemLibrary(name: "CGdk", pkgConfig: "gdk-3.0",

View File

@ -11,7 +11,10 @@ For up to date (auto-generated) reference documentation, see https://rhx.github.
## What is new?
Support for gtk 4 was added via the `gtk4` branch.
This branch supports Swift 5.2, but is now unmaintained.
The `main` and `development` branches will require newer versions of Swift.
Support for gtk 4 for Swift 5.2 is available via the `gtk4-swift52` branch.
Version 12 of gir2swift pulls in [PR#10](https://github.com/rhx/gir2swift/pull/10), addressing several issues:
@ -52,7 +55,7 @@ was compiled against libraries built with earlier versions of `gir2swift`.
### Swift
To build, you need at least Swift 5.2 (Swift 5.3 is required for `gtk4`), 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
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
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
@ -163,14 +166,20 @@ Make sure you have [sourcekitten](https://github.com/jpsim/SourceKitten) and [ja
Here are some common errors you might encounter and how to fix them.
### Old Swift toolchain or Xcode
### Missing `.gir` Files
If you get an error such as
$ ./build.sh
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-package (No such file or directory)
Girs located at
Cannot open '/GLib-2.0.gir': No such file or directory
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. 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.:

View File

@ -5,7 +5,7 @@
#
VER=3.0
GLIB_VER=2.0
JAZZY_VER=3.24.29
JAZZY_VER=3.24.30
Mod=Gdk
Module=${Mod}-$VER
module=`echo "${Module}" | tr '[:upper:]' '[:lower:]'`
@ -17,7 +17,7 @@ if [ -z "$BUILD_DIR" ]; then
export BUILD_DIR="$PWD/.build"
fi
fi
export PATH="${GIR2SWIFT_PATH}:${BUILD_DIR}/gir2swift/.build/release:${BUILD_DIR}/gir2swift/.build/debug:${PATH}:$PWD/.build/gir2swift/.build/release:$PWD/.build/gir2swift/.build/debug:${PATH}:/usr/local/opt/ruby/bin:`echo /usr/local/lib/ruby/gems/*/bin | tr ' ' '\n' | tail -n1`:${PATH}:`echo /var/lib/gems/*/gems/jazzy-*/bin/ | tr ' ' '\n' | tail -n1`:/usr/local/bin"
export PATH="${GIR2SWIFT_PATH}:${BUILD_DIR}/checkouts/gir2swift/.build/release:${BUILD_DIR}/checkouts/gir2swift/.build/debug:${PATH}:$PWD/.build/checkouts/gir2swift/.build/release:$PWD/.build/checkouts/gir2swift/.build/debug:${PATH}:/usr/local/opt/ruby/bin:`echo /usr/local/lib/ruby/gems/*/bin | tr ' ' '\n' | tail -n1`:${PATH}:`echo /var/lib/gems/*/gems/jazzy-*/bin/ | tr ' ' '\n' | tail -n1`:/usr/local/bin"
export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:${PKG_CONFIG_PATH}
LINKFLAGS=`pkg-config --libs $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
CCFLAGS=`pkg-config --cflags $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed 's/^/-Xcc /' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`

View File

@ -21,17 +21,4 @@ if [ ! -e "${GIR}" ] ; then
echo "and can be found in /usr /usr/local or by pkg-config!"
exit 1
fi
gir2swift -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}" | sed -f ${Module}.sed | awk -f ${Module}.awk > Sources/${Mod}/${Module}.swift
gir2swift -o Sources/${Mod} -m ${Module}.module -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}"
if which parallel >/dev/null ; then
for src in Sources/${Mod}/*-*.swift ; do \
echo "sed -f ${Module}.sed < ${src} |" \
"awk -f ${Module}.awk > ${src}.out" \; \
"mv ${src}.out ${src}" ; \
done | parallel
else
for src in Sources/${Mod}/*-*.swift ; do
sed -f ${Module}.sed < ${src} | awk -f ${Module}.awk > ${src}.out
mv ${src}.out ${src}
done
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}"

View File

@ -15,22 +15,8 @@ function generate_arg-path_arg-g2s-exec_arg-gir-pre_arg-gir-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} ${GIR_PRE_ARGS} ${GIR_PATH}/${GIR_NAME}.gir | sed -f ${GIR_NAME}.sed | awk -f ${GIR_NAME}.awk > Sources/${NAME}/${GIR_NAME}.swift"
bash -c "${G2S_EXEC} -o Sources/${NAME} -m ${GIR_NAME}.module ${GIR_PRE_ARGS} ${GIR_PATH}/${GIR_NAME}.gir"
if which parallel >/dev/null ; then
for src in Sources/${NAME}/*-*.swift ; do \
echo "sed -f ${GIR_NAME}.sed < ${src} |" \
"awk -f ${GIR_NAME}.awk > ${src}.out" \; \
"mv ${src}.out ${src}" ; \
done | parallel
else
for src in Sources/${NAME}/*-*.swift ; do
sed -f ${GIR_NAME}.sed < ${src} | awk -f ${GIR_NAME}.awk > ${src}.out
mv ${src}.out ${src}
done
fi
bash -c "${G2S_EXEC} -o Sources/${NAME} ${GIR_PRE_ARGS} ${GIR_PATH}/${GIR_NAME}.gir"
cd $CALLER
}