From ae62ee28816c3dd7952c3ad3001e7edbb565c551 Mon Sep 17 00:00:00 2001 From: Rene Hexel Date: Wed, 12 Dec 2018 11:56:41 +1000 Subject: [PATCH] Update to Swift 4 package format --- Package.swift | 14 +++++++++++--- Sources/{ => Atk}/Atk.swift | 0 config.sh | 5 +++-- distclean.sh | 2 +- gir-to-swift.sh | 4 ++-- xcodegen.sh | 2 +- 6 files changed, 18 insertions(+), 9 deletions(-) rename Sources/{ => Atk}/Atk.swift (100%) diff --git a/Package.swift b/Package.swift index cafd5d8..2b36c3c 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,18 @@ +// swift-tools-version:4.0 + import PackageDescription let package = Package( name: "Atk", + products: [ + .library(name: "Atk", targets: ["Atk"]), + ], dependencies: [ - .Package(url: "https://github.com/rhx/CAtk.git", majorVersion: 1), - .Package(url: "https://github.com/rhx/SwiftGObject.git", majorVersion: 2) + .package(url: "https://github.com/rhx/CAtk.git", .branch("master")), + .package(url: "https://github.com/rhx/SwiftGObject.git", .branch("master")) ], - swiftLanguageVersions: [3, 4] + targets: [ + .target(name: "Atk", dependencies: ["GLibObject"]), + .testTarget(name: "AtkTests", dependencies: ["Atk"]), + ] ) diff --git a/Sources/Atk.swift b/Sources/Atk/Atk.swift similarity index 100% rename from Sources/Atk.swift rename to Sources/Atk/Atk.swift diff --git a/config.sh b/config.sh index ecd0595..db77c9b 100755 --- a/config.sh +++ b/config.sh @@ -3,8 +3,9 @@ # Configuration for the module to compile, the Swift toolchain, and # the compiler and linker flags to use. # -Mod=Atk -Module=${Mod}-1.0 +VER=1.0 +Mod=`grep name: Package.swift | head -n1 | cut -d'"' -f2` +Module=${Mod}-${VER} module=`echo "${Module}" | tr '[:upper:]' '[:lower:]'` mod=`echo "${Mod}" | tr '[:upper:]' '[:lower:]'` BUILD_DIR=`pwd`/.build diff --git a/distclean.sh b/distclean.sh index 1c0d897..c753c90 100755 --- a/distclean.sh +++ b/distclean.sh @@ -4,4 +4,4 @@ # . ./config.sh ./clean.sh -exec rm -rf Package.pins Packages Sources/${Module}.swift Sources/Swift${Mod}.swift ${Mod}.xcodeproj +exec rm -rf Package.pins Packages Sources/${Mod}/${Module}.swift Sources/${Mod}/Swift${Mod}.swift ${Mod}.xcodeproj diff --git a/gir-to-swift.sh b/gir-to-swift.sh index 38be484..fc81982 100755 --- a/gir-to-swift.sh +++ b/gir-to-swift.sh @@ -21,8 +21,8 @@ if [ ! -e "${GIR}" ] ; then echo "and can be found in /usr /usr/local or by pkg-config!" exit 1 fi -gir2swift -o Sources -m ${Module}.module -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/GModule-2.0.gir -p ${GIR_DIR}/Gio-2.0.gir "${GIR}" -for src in Sources/*-*.swift ; do +gir2swift -o Sources/${Mod} -m ${Module}.module -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/GModule-2.0.gir -p ${GIR_DIR}/Gio-2.0.gir "${GIR}" +for src in Sources/${Mod}/*-*.swift ; do sed -f ${Module}.sed < ${src} > ${src}.out mv ${src}.out ${src} done diff --git a/xcodegen.sh b/xcodegen.sh index f97027d..61c62aa 100755 --- a/xcodegen.sh +++ b/xcodegen.sh @@ -5,7 +5,7 @@ # and pass them to subprojects, based on the configured -I flags. # . ./config.sh -[ -e Sources/${Module}.swift ] || ./generate-wrapper.sh +[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh ./package.sh generate-xcodeproj "$@" [ ! -e ${Mod}.xcodeproj/Configs ] || \ ( cd ${Mod}.xcodeproj/Configs && \