aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Beusterien <paulbeusterien@google.com>2020-06-22 08:55:49 -0700
committerGitHub <noreply@github.com>2020-06-22 18:55:49 +0300
commit84265e68619921b6df9c9e9a75a45bd50718c9cf (patch)
tree8d5bad240d4ba7ecf358da49f25aed886a1d3113
parent63f8e5e4946a5f8f0211b454bd37187871c3d023 (diff)
downloadnanopb-c-84265e68619921b6df9c9e9a75a45bd50718c9cf.tar.gz
Swift package manager (#549)
Add build rules for Swift package manager
-rw-r--r--.github/workflows/spm.yml15
-rw-r--r--Package.swift63
-rw-r--r--SwiftPackage/module.modulemap5
-rw-r--r--SwiftPackage/nanopb.h4
-rw-r--r--spm-test/objc/c-header.c1
-rw-r--r--spm-test/objc/objc-header.m1
-rw-r--r--spm-test/objc/objc-module.m1
-rw-r--r--spm-test/swift/main.swift1
8 files changed, 91 insertions, 0 deletions
diff --git a/.github/workflows/spm.yml b/.github/workflows/spm.yml
new file mode 100644
index 0000000..999851a
--- /dev/null
+++ b/.github/workflows/spm.yml
@@ -0,0 +1,15 @@
+name: spm
+
+on:
+ push:
+ pull_request:
+
+jobs:
+ swift-build-run:
+ runs-on: macOS-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Build
+ run: swift build
+ - name: Run
+ run: swift test
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..828d5ed
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,63 @@
+// swift-tools-version:5.0
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+
+import PackageDescription
+
+let package = Package(
+ name: "nanopb",
+ platforms: [
+ .macOS(.v10_10),
+ .iOS(.v8),
+ .tvOS(.v9),
+ .watchOS(.v2)
+ ],
+
+ targets: [
+ .target(
+ name: "nanopb",
+ path: ".",
+ sources: [
+ "pb.h",
+ "pb_common.h",
+ "pb_common.c",
+ "pb_decode.h",
+ "pb_decode.c",
+ "pb_encode.h",
+ "pb_encode.c"
+ ],
+ publicHeadersPath: "SwiftPackage",
+ cSettings: [
+ .define("PB_FIELD_32BIT", to: "1"),
+ .define("PB_NO_PACKED_STRUCTS", to: "1"),
+ .define("PB_ENABLE_MALLOC", to: "1"),
+ ]
+ ),
+ .testTarget(
+ name: "swift-test",
+ dependencies: [
+ "nanopb",
+ ],
+ path: "spm-test/swift",
+ cSettings: [
+ .headerSearchPath("../"),
+ .define("PB_FIELD_32BIT", to: "1"),
+ .define("PB_NO_PACKED_STRUCTS", to: "1"),
+ .define("PB_ENABLE_MALLOC", to: "1"),
+ ]
+ ),
+ .testTarget(
+ name: "objc-test",
+ dependencies: [
+ "nanopb",
+ ],
+ path: "spm-test/objc",
+ cSettings: [
+ .headerSearchPath("../"),
+ .define("PB_FIELD_32BIT", to: "1"),
+ .define("PB_NO_PACKED_STRUCTS", to: "1"),
+ .define("PB_ENABLE_MALLOC", to: "1"),
+ ]
+ )
+ ]
+)
+
diff --git a/SwiftPackage/module.modulemap b/SwiftPackage/module.modulemap
new file mode 100644
index 0000000..0888ab1
--- /dev/null
+++ b/SwiftPackage/module.modulemap
@@ -0,0 +1,5 @@
+module nanopb {
+ umbrella header "nanopb.h"
+
+ export *
+} \ No newline at end of file
diff --git a/SwiftPackage/nanopb.h b/SwiftPackage/nanopb.h
new file mode 100644
index 0000000..d0666d7
--- /dev/null
+++ b/SwiftPackage/nanopb.h
@@ -0,0 +1,4 @@
+#import "../pb.h"
+#import "../pb_common.h"
+#import "../pb_decode.h"
+#import "../pb_encode.h"
diff --git a/spm-test/objc/c-header.c b/spm-test/objc/c-header.c
new file mode 100644
index 0000000..2995860
--- /dev/null
+++ b/spm-test/objc/c-header.c
@@ -0,0 +1 @@
+#include "nanopb.h"
diff --git a/spm-test/objc/objc-header.m b/spm-test/objc/objc-header.m
new file mode 100644
index 0000000..d8f79cf
--- /dev/null
+++ b/spm-test/objc/objc-header.m
@@ -0,0 +1 @@
+#import "nanopb.h"
diff --git a/spm-test/objc/objc-module.m b/spm-test/objc/objc-module.m
new file mode 100644
index 0000000..18b2833
--- /dev/null
+++ b/spm-test/objc/objc-module.m
@@ -0,0 +1 @@
+@import nanopb;
diff --git a/spm-test/swift/main.swift b/spm-test/swift/main.swift
new file mode 100644
index 0000000..97cf622
--- /dev/null
+++ b/spm-test/swift/main.swift
@@ -0,0 +1 @@
+import nanopb