diff options
author | Fredrik Høisæther Rasch <fredrik.rasch@gmail.com> | 2017-08-06 02:18:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-08-06 02:18:15 +0200 |
commit | c39e2029762387d05f7b3d81490c6129703c1b60 (patch) | |
tree | 68b9b76672de12c670808f882a014f77d7c40eb9 /tools/niminst | |
parent | bbeadf184e613d6ae476fe4252d60b1e3a92e7dd (diff) | |
download | Nim-c39e2029762387d05f7b3d81490c6129703c1b60.tar.gz |
Introduce first class support for Android (#5772)
Diffstat (limited to 'tools/niminst')
-rw-r--r-- | tools/niminst/buildsh.tmpl | 44 | ||||
-rw-r--r-- | tools/niminst/makefile.tmpl | 6 |
2 files changed, 48 insertions, 2 deletions
diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl index 956c5ead8..faa8a47d0 100644 --- a/tools/niminst/buildsh.tmpl +++ b/tools/niminst/buildsh.tmpl @@ -1,4 +1,4 @@ -#? stdtmpl(subsChar='?') | standard +#? stdtmpl(subsChar='?') | standard #proc generateBuildShellScript(c: ConfigData): string = # result = "#! /bin/sh\n# Generated from niminst\n" & # "# Template is in tools/niminst/buildsh.tmpl\n" & @@ -9,6 +9,18 @@ set -e while : do case "$1" in + --os) + optos=$2 + shift 2 + ;; + --cpu) + optcpu=$2 + shift 2 + ;; + --osname) + optosname=$2 + shift 2 + ;; --extraBuildArgs) extraBuildArgs=" $2" shift 2 @@ -35,6 +47,7 @@ PS4="" # add(result, "# platform detection\n") ucpu=`uname -m` uos=`uname` +uosname=`uname -o` # add(result, "# bin dir detection\n") binDir=?{firstBinPath(c).toUnix} @@ -46,9 +59,21 @@ if [ ! -d $binDir ]; then mkdir $binDir fi +# add(result, "# override OS, CPU and OS Name with command-line arguments\n") +if [ -n "$optos" ]; then + uos="$optos" +fi +if [ -n "$optcpu" ]; then + ucpu="$optcpu" +fi +if [ -n "$optcpu" ]; then + uosname="$optosname" +fi + # add(result, "# convert to lower case:\n") ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"` uos=`echo $uos | tr "[:upper:]" "[:lower:]"` +uosname=`echo $uosname | tr "[:upper:]" "[:lower:]"` case $uos in *linux* ) @@ -97,6 +122,11 @@ case $uos in *mingw* ) myos="windows" ;; + *android* ) + myos="android" + LINK_FLAGS="$LINK_FLAGS -ldl -lm -lrt" + LINK_FLAGS="$LINK_FLAGS -landroid-glob" + ;; *) echo 2>&1 "Error: unknown operating system: $uos" exit 1 @@ -132,7 +162,7 @@ case $ucpu in exit 1 esac ;; - *arm*|*armv6l* ) + *arm*|*armv6l*|*armv71* ) mycpu="arm" ;; *aarch64* ) mycpu="arm64" ;; @@ -142,7 +172,17 @@ case $ucpu in ;; esac +case $uosname in + *android* ) + LINK_FLAGS="$LINK_FLAGS -landroid-glob" + myosname="android" + myos="android" + ;; +esac + # add(result, "# call the compiler:\n") +echo \# OS: $myos +echo \# CPU: $mycpu case $myos in # for osA in 1..c.oses.len: diff --git a/tools/niminst/makefile.tmpl b/tools/niminst/makefile.tmpl index 2203d05e9..4a20680e0 100644 --- a/tools/niminst/makefile.tmpl +++ b/tools/niminst/makefile.tmpl @@ -17,6 +17,7 @@ endif ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"') uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"') +uosname := $(shell sh -c 'uname -o | tr "[:upper:]" "[:lower:]"') ifeq ($(uos),linux) myos = linux @@ -68,6 +69,11 @@ ifndef uos $(error unknown operating system: $(uos)) endif +ifeq ($(uosname),android) + myos = android + LINK_FLAGS += -landroid-glob +endif + ifeq ($(ucpu),i386) mycpu = i386 endif |