diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-09-21 11:53:09 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-09-21 11:53:09 +0200 |
commit | e0f2b3ba8fb23a37adffece73bdc466e3e0a7072 (patch) | |
tree | d91bf0aae25927ace8f7938955a1310bc651fa72 /doc/nimc.rst | |
parent | b04ef2973d5384e27197643303b1ea1c325d04f5 (diff) | |
download | Nim-e0f2b3ba8fb23a37adffece73bdc466e3e0a7072.tar.gz |
documentation updates
Diffstat (limited to 'doc/nimc.rst')
-rw-r--r-- | doc/nimc.rst | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/doc/nimc.rst b/doc/nimc.rst index 6ca4daa3d..ebdd00063 100644 --- a/doc/nimc.rst +++ b/doc/nimc.rst @@ -17,7 +17,7 @@ Introduction This document describes the usage of the *Nim compiler* on the different supported platforms. It is not a definition of the Nim -programming language (therefore is the `manual <manual.html>`_). +programming language (which is covered in the `manual <manual.html>`_). Nim is free software; it is licensed under the `MIT License <http://www.opensource.org/licenses/mit-license.php>`_. @@ -197,9 +197,8 @@ directory structure looks like this:: other.nim And ``main`` imports ``x``, ``foo/x`` is imported. If ``other`` imports ``x`` -then both ``$lib/x.nim`` and ``$lib/bar/x.nim`` match and so the compiler -should reject it. Currently however this check is not implemented and instead -the first matching file is used. +then both ``$lib/x.nim`` and ``$lib/bar/x.nim`` match but ``$lib/x.nim`` is used +as it is the first match. Generated C code directory @@ -213,10 +212,7 @@ The generated files that Nim produces all go into a subdirectory called The ``_r`` suffix is used for release builds, ``_d`` is for debug builds. -This makes it easy to delete all -generated files. Files generated in this directory follow a naming logic which -you can read about in the `Nim Backend Integration document -<backends.html#nimcache-naming-logic>`_. +This makes it easy to delete all generated files. The ``--nimcache`` `compiler switch <nimc.html#command-line-switches>`_ can be used to @@ -281,16 +277,17 @@ The MinGW-w64 toolchain can be installed as follows:: CentOS: yum install mingw32-gcc | mingw64-gcc - requires EPEL OSX: brew install mingw-w64 + Cross compilation for Android ============================= There are two ways to compile for Android: terminal programs (Termux) and with the NDK (Android Native Development Kit). -First one is to treat Android as a simple linux and use -`Termux <https://wiki.termux.com>`_ to connect and run the nim compiler -directly on android as if it was linux. These programs are console only -programs that can’t be distributed in the Play Store. +First one is to treat Android as a simple Linux and use +`Termux <https://wiki.termux.com>`_ to connect and run the Nim compiler +directly on android as if it was Linux. These programs are console only +programs that can't be distributed in the Play Store. Use regular ``nim c`` inside termux to make Android terminal programs. @@ -303,45 +300,51 @@ to have the Java stub be auto generated for you. Use ``nim c -c --cpu:arm --os:android -d:androidNDK --noMain:on`` to generate the C source files you need to include in your Android Studio project. Add the generated C files to CMake build script in your Android -project. Then do the final compile with Android Studio which uses gradle +project. Then do the final compile with Android Studio which uses Gradle to call CMake to compile the project. -Because nim is part of a library it can’t have its own c style `main()` -so you would need to define your own `android_main` and init the java -environment, or use a library like SDL2 or GLFM to do it. After android -stuff is done, It’s very important to call `NimMain()` to nim’s initialize -garbage collector memory, types and stack. +Because Nim is part of a library it can't have its own c style ``main()`` +so you would need to define your own ``android_main`` and init the Java +environment, or use a library like SDL2 or GLFM to do it. After the Android +stuff is done, it's very important to call ``NimMain()`` in order to +initialize Nim's garbage collector and to run the top level statements +of your program. .. code-block:: Nim + proc NimMain() {.importc.} proc glfmMain*(display: ptr GLFMDisplay) {.exportc.} = NimMain() # initialize garbage collector memory, types and stack + Cross compilation for iOS ========================= To cross compile for iOS you need to be on a MacOS computer and 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++ +Normal languages for iOS development are Swift and 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 --noMain:on`` to generate C files and include them in -your XCode project. Then you can use XCode to compile, link, package and code +your XCode project. Then you can use XCode to compile, link, package and sign everything. -Because nim is part of a library it can’t have its own c style `main()` so you -would need to define `main` that calls `autoreleasepool` and -`UIApplicationMain` to do it, or use a library like SDL2 or GLFM. After iOS -stuff is done, it's very important to call `NimMain()` to nim’s initialize -garbage collector memory, types and stack. +Because Nim is part of a library it can't have its own c style ``main()`` so you +would need to define `main` that calls ``autoreleasepool`` and +``UIApplicationMain`` to do it, or use a library like SDL2 or GLFM. After +the iOS setup is done, it's very important to call ``NimMain()`` in order to +initialize Nim's garbage collector and to run the top level statements +of your program. .. code-block:: Nim + proc NimMain() {.importc.} proc glfmMain*(display: ptr GLFMDisplay) {.exportc.} = NimMain() # initialize garbage collector memory, types and stack Note: XCodes "make clean" gets confused about the genreated nim.c files, -so you need to clean those with `rm` manually to do a clean build. +so you need to clean those files manually to do a clean build. + Cross compilation for Nintendo Switch ===================================== |