I'm adding a
Package.json file to Signal's libsignal-protocol-c.
They use CMake, so I'm translating CMake to SwiftPM.
CMakeLists.txt file uses the CMake
check_symbol_exists command to define a macro named
memset_s is available in the system's libc
string.h header file.
Is it possible to do that with Swift Package Manger?
On macOS, I ran
find /Applications/Xcode.app -name 'string.h' | xargs fgrep memset_s
and saw that the macOS, iOS, tvOS, and watchOS SDKs each has the following line in their
string.h header file:
memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
So, I'm not sure about Linux, but I guess I'll do the following for now:
let package = Package(
products: [.library(name: "SignalProtocol", targets: ["SignalProtocol"])],
You can use build setting conditions to set this per-platform, but I don't think there's a good way to determine this automatically.
Yeah, I saw that. OK. Thanks, @NeoNacho. I was also wondering if it's possible to define a macro if the system is big endian, but I guess not. Oh well.
I don't think there is. The main conceptual issue with a query like this is while the manifest can run arbitrary Swift code, it will be run on the host, so any sort of queries like that would give you answers about macOS/Linux, not necessarily the target platform you are building for.
Wow, I didn't know the manifest could run arbitrary Swift code. I initially figured it could, but then I got a parse error or something when I tried it. But I just tried it again, and it worked! That's so awesome! Thanks! :-) Oh yeah, good point. Hmm... maybe the
test_big_endian commands in libsignal-protocol-c's CMakeLists.txt file have the same issue. By the way, I just realized that I've seen you talking about the Swift Package Manager from Apple's WWDC videos. Great job! I thought you seemed familiar. Thanks for your contributions. :-) And thanks so much for answering my questions. SwiftPM is really cool!