|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [ -z $1 ] || [ -z $2 ]; then |
| 4 | + echo -e "Please specify OS ARCH. Example:\nbash $0 linux amd64" |
| 5 | + exit 1 |
| 6 | +fi; |
| 7 | + |
| 8 | +WXGO_SUFFIX=$1_$2 |
| 9 | + |
| 10 | +wxGoTmpDir="/tmp/wxGo_tmp_$WXGO_SUFFIX" |
| 11 | + |
| 12 | +if [ -e $wxGoTmpDir ]; then |
| 13 | + rm -r $wxGoTmpDir |
| 14 | +fi; |
| 15 | + |
| 16 | + |
| 17 | +mkdir -p $wxGoTmpDir/pkg/$WXGO_SUFFIX/github.com/dontpanic92/wxGo/ |
| 18 | +mkdir -p $wxGoTmpDir/src/github.com/dontpanic92/wxGo/wx |
| 19 | +cp $GOPATH/src/github.com/dontpanic92/wxGo/wx/$WXGO_SUFFIX/lib/*.a $wxGoTmpDir |
| 20 | + |
| 21 | +cd $wxGoTmpDir |
| 22 | + |
| 23 | +for file in `ls *.a`; do |
| 24 | + ar x $file; |
| 25 | +done; |
| 26 | + |
| 27 | +if [ "$1" == "darwin" ]; then |
| 28 | + # cocoa/power.mm compiled twice! Delete one of them |
| 29 | + rm baselib_cocoa_power_darwin_amd64.o |
| 30 | +fi; |
| 31 | + |
| 32 | +# Windows has a limit of maximum command line characers. If we simply copy |
| 33 | +# these .o file, the length of the link command will longer than the limit. |
| 34 | +# So here we use * to link them into one object file first to workaround. |
| 35 | +# Also, in Linux / Mac OS X, there is a limit of open files. You can use |
| 36 | +# ulimit -a to check the limit, and use ulimit -n to modify the maximum files |
| 37 | +# a process can open. On Mac OS X El Capitan the default value of this limit is |
| 38 | +# 256 and it is toooo small. |
| 39 | + |
| 40 | +if [ "$1" == windows ]; then |
| 41 | + a=0 |
| 42 | + for file in `ls *.o`; do |
| 43 | + new=$(printf "%d.o" "$a") |
| 44 | + mv -- "$file" "$new" |
| 45 | + let a=a+1 |
| 46 | + done; |
| 47 | + if [ "$2" == "386" ]; then |
| 48 | + ld -m i386pe -r -o everything_$WXGO_SUFFIX.syso *.o |
| 49 | + else |
| 50 | + ld -r -o everything_$WXGO_SUFFIX.syso *.o |
| 51 | + fi; |
| 52 | + rm *.o |
| 53 | +else |
| 54 | + for file in `ls *.o`; do |
| 55 | + mv "${file}" "${file/%.o/_$WXGO_SUFFIX.syso}" |
| 56 | + done; |
| 57 | +fi; |
| 58 | + |
| 59 | +rm *.a |
| 60 | +mv *.syso $GOPATH/src/github.com/dontpanic92/wxGo/wx/ |
| 61 | + |
| 62 | +go env |
| 63 | +go install -tags "wxgo_binary_package_build" -x github.com/dontpanic92/wxGo/wx |
| 64 | + |
| 65 | + |
| 66 | +cp $GOPATH/pkg/$WXGO_SUFFIX/github.com/dontpanic92/wxGo/wx.a $wxGoTmpDir/pkg/$WXGO_SUFFIX/github.com/dontpanic92/wxGo/wx.a |
| 67 | + |
| 68 | +echo -e "//go:binary-only-package\n\npackage wx" > $wxGoTmpDir/src/github.com/dontpanic92/wxGo/wx/binary_only_package_$WXGO_SUFFIX.go |
| 69 | + |
| 70 | +rm $GOPATH/src/github.com/dontpanic92/wxGo/wx/*_$WXGO_SUFFIX.syso |
| 71 | + |
| 72 | +zip -9 wxGo_$WXGO_SUFFIX.zip -r pkg src |
| 73 | + |
| 74 | +cd - |
| 75 | + |
| 76 | +if [ -e wxGo_$WXGO_SUFFIX.zip ]; then |
| 77 | + rm wxGo_$WXGO_SUFFIX.zip |
| 78 | +fi; |
| 79 | + |
| 80 | +mv $wxGoTmpDir/wxGo_$WXGO_SUFFIX.zip . |
| 81 | + |
| 82 | +rm -r $wxGoTmpDir |
| 83 | + |
0 commit comments