Add --os:ios switch and docs. (#12204)

This commit is contained in:
treeform 2019-09-18 11:03:51 -07:00 • committed by Andreas Rumpf
commit a948deebb3
3 changed files with 17 additions and 4 deletions

View file

@ -397,7 +397,7 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
result = conf.target.targetOS in {osLinux, osMorphos, osSkyos, osIrix, osPalmos, result = conf.target.targetOS in {osLinux, osMorphos, osSkyos, osIrix, osPalmos,
osQnx, osAtari, osAix, osQnx, osAtari, osAix,
osHaiku, osVxWorks, osSolaris, osNetbsd, osHaiku, osVxWorks, osSolaris, osNetbsd,
osFreebsd, osOpenbsd, osDragonfly, osMacosx, osFreebsd, osOpenbsd, osDragonfly, osMacosx, osIos,
osAndroid, osNintendoSwitch} osAndroid, osNintendoSwitch}
of "linux": of "linux":
result = conf.target.targetOS in {osLinux, osAndroid} result = conf.target.targetOS in {osLinux, osAndroid}
@ -407,8 +407,10 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
result = platform.OS[conf.target.targetOS].props.contains(ospLacksThreadVars) result = platform.OS[conf.target.targetOS].props.contains(ospLacksThreadVars)
of "msdos": result = conf.target.targetOS == osDos of "msdos": result = conf.target.targetOS == osDos
of "mswindows", "win32": result = conf.target.targetOS == osWindows of "mswindows", "win32": result = conf.target.targetOS == osWindows
of "macintosh": result = conf.target.targetOS in {osMacos, osMacosx} of "macintosh":
of "osx": result = conf.target.targetOS == osMacosx result = conf.target.targetOS in {osMacos, osMacosx, osIos}
of "osx":
result = conf.target.targetOS in {osMacosx, osIos}
of "sunos": result = conf.target.targetOS == osSolaris of "sunos": result = conf.target.targetOS == osSolaris
of "nintendoswitch": of "nintendoswitch":
result = conf.target.targetOS == osNintendoSwitch result = conf.target.targetOS == osNintendoSwitch

View file

@ -21,7 +21,7 @@ type
# conditionals to condsyms (end of module). # conditionals to condsyms (end of module).
osNone, osDos, osWindows, osOs2, osLinux, osMorphos, osSkyos, osSolaris, osNone, osDos, osWindows, osOs2, osLinux, osMorphos, osSkyos, osSolaris,
osIrix, osNetbsd, osFreebsd, osOpenbsd, osDragonfly, osAix, osPalmos, osQnx, osIrix, osNetbsd, osFreebsd, osOpenbsd, osDragonfly, osAix, osPalmos, osQnx,
osAmiga, osAtari, osNetware, osMacos, osMacosx, osHaiku, osAndroid, osVxWorks osAmiga, osAtari, osNetware, osMacos, osMacosx, osIos, osHaiku, osAndroid, osVxWorks
osGenode, osJS, osNimVM, osStandalone, osNintendoSwitch osGenode, osJS, osNimVM, osStandalone, osNintendoSwitch
type type
@ -139,6 +139,10 @@ const
objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/", objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/",
scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".",
props: {ospNeedsPIC, ospPosix, ospLacksThreadVars}), props: {ospNeedsPIC, ospPosix, ospLacksThreadVars}),
(name: "iOS", parDir: "..", dllFrmt: "lib$1.so", altDirSep: "/",
objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/",
scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".",
props: {ospNeedsPIC, ospPosix}),
(name: "Haiku", parDir: "..", dllFrmt: "lib$1.so", altDirSep: ":", (name: "Haiku", parDir: "..", dllFrmt: "lib$1.so", altDirSep: ":",
objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/", objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/",
scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".",

View file

@ -295,6 +295,13 @@ Android apps are written in Java, to use Nim inside an Android app you need a sm
Use ``nim c -c --cpu:arm --os:android -d:androidNDK`` to generate the C source files you need to include in your Android Studio project. Add the generated C files to CMake build script. Then do the final compile with Android Studio which uses gradle to call CMake to compile the project. Use ``nim c -c --cpu:arm --os:android -d:androidNDK`` to generate the C source files you need to include in your Android Studio project. Add the generated C files to CMake build script. Then do the final compile with Android Studio which uses gradle to call CMake to compile the project.
Cross compilation for iOS
=========================
To cross compile for iOS you need to be on a MacOS computer use XCode. Normal languages for iOS development is Swift or Objective C. Both of these use llvm and can be compiled into object files linked together with C, C++ or Objective C code produced by Nim.
Use ``nim c -c --os:ios`` to generate C files and include them in your XCode project. Then you can use XCode to compile, link, package and code sign everything.
Cross compilation for Nintendo Switch Cross compilation for Nintendo Switch
===================================== =====================================