mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-05 23:53:08 +00:00
adapt Makefile and sds.nimble to support iOS target
This commit is contained in:
parent
b643126011
commit
024b8c50e9
7
Makefile
7
Makefile
@ -73,6 +73,7 @@ ifeq ($(detected_OS),Windows)
|
|||||||
BUILD_COMMAND := $(BUILD_COMMAND)Windows
|
BUILD_COMMAND := $(BUILD_COMMAND)Windows
|
||||||
else ifeq ($(detected_OS),Darwin)
|
else ifeq ($(detected_OS),Darwin)
|
||||||
BUILD_COMMAND := $(BUILD_COMMAND)Mac
|
BUILD_COMMAND := $(BUILD_COMMAND)Mac
|
||||||
|
export IOS_SDK_PATH := $(shell xcrun --sdk iphoneos --show-sdk-path)
|
||||||
else ifeq ($(detected_OS),Linux)
|
else ifeq ($(detected_OS),Linux)
|
||||||
BUILD_COMMAND := $(BUILD_COMMAND)Linux
|
BUILD_COMMAND := $(BUILD_COMMAND)Linux
|
||||||
endif
|
endif
|
||||||
@ -171,3 +172,9 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Target iOS
|
||||||
|
|
||||||
|
libsds-ios: | deps
|
||||||
|
$(ENV_SCRIPT) nim libsdsIOS $(NIM_PARAMS) sds.nims
|
||||||
|
|
||||||
|
|||||||
42
sds.nimble
42
sds.nimble
@ -91,6 +91,48 @@ task libsdsStaticMac, "Generate bindings":
|
|||||||
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
"static"
|
"static"
|
||||||
|
|
||||||
|
# Build Mobile iOS
|
||||||
|
proc buildMobileIOS(srcDir = ".", sdkPath = "") =
|
||||||
|
echo "Building iOS libsds library"
|
||||||
|
|
||||||
|
let outDir = "build"
|
||||||
|
if not dirExists outDir:
|
||||||
|
mkDir outDir
|
||||||
|
|
||||||
|
if sdkPath.len == 0:
|
||||||
|
quit "Error: Xcode/iOS SDK not found"
|
||||||
|
|
||||||
|
# The output static library
|
||||||
|
let cFile = outDir & "/nimcache/@mlibsds.nim.c"
|
||||||
|
let oFile = outDir & "/libsds.o"
|
||||||
|
let aFile = outDir & "/libsds.a"
|
||||||
|
|
||||||
|
# 1) Generate C sources from Nim (no linking)
|
||||||
|
exec "nim c" &
|
||||||
|
" --nimcache:build/nimcache --os:ios --cpu:arm64" &
|
||||||
|
" --compileOnly:on" &
|
||||||
|
" --noMain --mm:refc" &
|
||||||
|
" --threads:on --opt:size --header" &
|
||||||
|
" --nimMainPrefix:libsds --skipParentCfg:on" &
|
||||||
|
" --cc:clang" &
|
||||||
|
" --out:" & cFile & " " &
|
||||||
|
srcDir & "/libsds.nim"
|
||||||
|
|
||||||
|
exec "clang -arch arm64" &
|
||||||
|
" -isysroot " & sdkPath &
|
||||||
|
" -I./vendor/nimbus-build-system/vendor/Nim/lib/" &
|
||||||
|
" -fembed-bitcode -c " & cFile &
|
||||||
|
" -o " & oFile
|
||||||
|
|
||||||
|
exec "ar rcs " & aFile & " " & oFile
|
||||||
|
|
||||||
|
echo "✔ iOS library created: " & aFile
|
||||||
|
|
||||||
|
task libsdsIOS, "Build the mobile bindings for iOS":
|
||||||
|
let srcDir = "./library"
|
||||||
|
let sdkPath = getEnv("IOS_SDK_PATH")
|
||||||
|
buildMobileIOS srcDir, sdkPath
|
||||||
|
|
||||||
### Mobile Android
|
### Mobile Android
|
||||||
proc buildMobileAndroid(srcDir = ".", params = "") =
|
proc buildMobileAndroid(srcDir = ".", params = "") =
|
||||||
let cpu = getEnv("CPU")
|
let cpu = getEnv("CPU")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user