diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-02 19:27:48 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-02 19:27:48 -0300 |
| commit | 8dd1e1460282f5fc992d838ec2411f4d1bc7b2b7 (patch) | |
| tree | 5b6e88d37869bad4a23cfd52424e91fa34d34176 /binary/static-gcc | |
| parent | 672b4f191ac5723ee460e469d58fff2ca2cb386b (diff) | |
| download | luarocks-8dd1e1460282f5fc992d838ec2411f4d1bc7b2b7.tar.gz luarocks-8dd1e1460282f5fc992d838ec2411f4d1bc7b2b7.tar.bz2 luarocks-8dd1e1460282f5fc992d838ec2411f4d1bc7b2b7.zip | |
Experimental Windows cross-compiled binary build
This commit consolidates the work that has been ongoing over the
last few weeks in producing the single-binary builds of LuaRocks
based on the new distribution model described in
https://github.com/luarocks/luarocks/wiki/Project:-LuaRocks-new-distribution-model
The single-binary build is in a good shape for Linux,
it's a work-in-progress for Windows (binaries do build,
but some work on the dependencies is still necessary),
and is untested in macOS.
Diffstat (limited to 'binary/static-gcc')
| -rwxr-xr-x | binary/static-gcc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/binary/static-gcc b/binary/static-gcc index a4d865d5..c08f24b2 100755 --- a/binary/static-gcc +++ b/binary/static-gcc | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | 2 | ||
| 3 | STATIC_GCC_AR=${STATIC_GCC_AR:-ar} | ||
| 4 | STATIC_GCC_RANLIB=${STATIC_GCC_RANLIB:-ranlib} | ||
| 5 | STATIC_GCC_CC=${STATIC_GCC_CC:-gcc} | ||
| 6 | STATIC_GCC_LIBDIR=${STATIC_GCC_LIBDIR:-/usr/lib} | ||
| 7 | |||
| 3 | DIR="$( cd "$( dirname "$0" )" && pwd )" | 8 | DIR="$( cd "$( dirname "$0" )" && pwd )" |
| 4 | 9 | ||
| 5 | function log() { echo -- "$@" >> $DIR/log.txt; } | 10 | function log() { echo -- "$@" >> $DIR/log.txt; } |
| @@ -13,7 +18,7 @@ allargs=() | |||
| 13 | sources=() | 18 | sources=() |
| 14 | objects=() | 19 | objects=() |
| 15 | etc=() | 20 | etc=() |
| 16 | libdirs=("/usr/lib") | 21 | libdirs=("$STATIC_GCC_LIBDIR") |
| 17 | incdirs=() | 22 | incdirs=() |
| 18 | 23 | ||
| 19 | linking=0 | 24 | linking=0 |
| @@ -94,15 +99,22 @@ done | |||
| 94 | staticlibs=() | 99 | staticlibs=() |
| 95 | for lib in "${libs[@]}" | 100 | for lib in "${libs[@]}" |
| 96 | do | 101 | do |
| 102 | found=0 | ||
| 97 | for libdir in "${libdirs[@]}" | 103 | for libdir in "${libdirs[@]}" |
| 98 | do | 104 | do |
| 99 | staticlib="$libdir/lib$lib.a" | 105 | staticlib="$libdir/lib$lib.a" |
| 100 | if [ -e "$staticlib" ] | 106 | if [ -e "$staticlib" ] |
| 101 | then | 107 | then |
| 102 | staticlibs+=("$staticlib") | 108 | staticlibs+=("$staticlib") |
| 109 | found=1 | ||
| 103 | break | 110 | break |
| 104 | fi | 111 | fi |
| 105 | done | 112 | done |
| 113 | if [ "$found" = 0 ] | ||
| 114 | then | ||
| 115 | log "STATICLIB not found for $lib" | ||
| 116 | runlog exit 1 | ||
| 117 | fi | ||
| 106 | done | 118 | done |
| 107 | 119 | ||
| 108 | oflag=() | 120 | oflag=() |
| @@ -119,7 +131,7 @@ then | |||
| 119 | for source in "${sources[@]}" | 131 | for source in "${sources[@]}" |
| 120 | do | 132 | do |
| 121 | object="${source%.c}.o" | 133 | object="${source%.c}.o" |
| 122 | runlog gcc "${incdirs[@]}" "${etc[@]}" -c -o "$object" "$source" | 134 | runlog $STATIC_GCC_CC "${incdirs[@]}" "${etc[@]}" -c -o "$object" "$source" |
| 123 | [ "$?" = 0 ] || runlog exit $? | 135 | [ "$?" = 0 ] || runlog exit $? |
| 124 | objects+=("$object") | 136 | objects+=("$object") |
| 125 | done | 137 | done |
| @@ -137,22 +149,23 @@ then | |||
| 137 | done | 149 | done |
| 138 | echo "SAVE" >> ar.script | 150 | echo "SAVE" >> ar.script |
| 139 | echo "END" >> ar.script | 151 | echo "END" >> ar.script |
| 140 | cat ar.script | ar -M | 152 | cat ar.script >> "$DIR/log.txt" |
| 153 | cat ar.script | $STATIC_GCC_AR -M | ||
| 141 | [ "$?" = 0 ] || runlog exit $? | 154 | [ "$?" = 0 ] || runlog exit $? |
| 142 | 155 | ||
| 143 | [ -e "$output" ] || { | 156 | [ -e "$output" ] || { |
| 144 | exit 1 | 157 | exit 1 |
| 145 | } | 158 | } |
| 146 | 159 | ||
| 147 | runlog ranlib "$output" | 160 | runlog $STATIC_GCC_RANLIB "$output" |
| 148 | runlog exit $? | 161 | runlog exit $? |
| 149 | elif [ "$object" = 1 ] | 162 | elif [ "$object" = 1 ] |
| 150 | then | 163 | then |
| 151 | log OBJECT | 164 | log OBJECT |
| 152 | runlog gcc "${oflag[@]}" "${incdirs[@]}" "${etc[@]}" "${sources[@]}" | 165 | runlog $STATIC_GCC_CC "${oflag[@]}" "${incdirs[@]}" "${etc[@]}" "${sources[@]}" |
| 153 | runlog exit $? | 166 | runlog exit $? |
| 154 | else | 167 | else |
| 155 | log EXECUTABLE | 168 | log EXECUTABLE |
| 156 | runlog gcc "${allargs[@]}" | 169 | runlog $STATIC_GCC_CC "${allargs[@]}" |
| 157 | runlog exit $? | 170 | runlog exit $? |
| 158 | fi | 171 | fi |
