Improve buildbot script, integrate android buildbot into it

This commit is contained in:
UnknownShadow200 2021-02-07 14:05:31 +11:00
parent b0f41513fa
commit 3c25686757
3 changed files with 92 additions and 87 deletions

View File

@ -7,83 +7,83 @@
# First you need to install these packages: gcc, i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc
#
# You then need to install these packages: libx11-dev and libgl1-mesa-dev
# - if 32 bit, then install the 64 bit variants of all these packages (e.g. libx11-dev:amd64)
# - if 64 bit, then install the 32 bit variants of all these packages (e.g. libx11-dev:i386)
# - if 32 bit, also install the 64 bit variants of all these packages (e.g. libx11-dev:amd64)
# - if 64 bit, also install the 32 bit variants of all these packages (e.g. libx11-dev:i386)
#
# However! You may find that installing the alternate bit variant of libgl1-mesa-dev uninstalls your current package
# However! You may find that with some ubuntu versions, installing the alternate
# bit variant of libgl1-mesa-dev uninstalls your current package.
# To fix this, first reinstall the normal libgl1-mesa-dev package
# The alternate bit .so files should have been left behind in the mesa folder, so adding a symlink should make it compile again
# - for 32 bit: ln -sf /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so
# - for 64 bit: ln -sf /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
# paths, change these as needed
SOURCE_DIR=~/client
WEB_CC="~/emsdk/emscripten/1.38.31/emcc"
MAC32_CC="~/osx/target/bin/o32-clang"
MAC64_CC="~/osx/target/bin/o64-clang"
ROOT_DIR=~/client # can be changed
ALL_FLAGS="-O1 -s -fno-stack-protector -fno-math-errno -Qn -w"
# ----------------------------- compile windows
WIN32_CC="i686-w64-mingw32-gcc"
WIN64_CC="x86_64-w64-mingw32-gcc"
# to simplify stuff
ALL_FLAGS="-O1 -s -fno-stack-protector -fno-math-errno -Qn -w"
WIN32_FLAGS="-mwindows -nostartfiles -Wl,-e_main_real -DCC_NOMAIN"
WIN64_FLAGS="-mwindows -nostartfiles -Wl,-emain_real -DCC_NOMAIN"
NIX32_FLAGS="-no-pie -fno-pie -m32 -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
NIX64_FLAGS="-no-pie -fno-pie -m64 -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
RPI32_FLAGS="-I ~/rpi/include -L ~/rpi/lib -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
MACOS_FLAGS="-fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
# I cloned https://github.com/raspberrypi/tools to get prebuilt cross compilers
# Then I copied across various files/folders from /usr/include and /usr/lib from a real Raspberry pi as needed
RPI_CC=~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc-4.8.3
# -----------------------------
build_win32() {
echo "Building win32.."
cp $SOURCE_DIR/misc/CCicon_32.res $SOURCE_DIR/src/CCicon_32.res
cp $ROOT_DIR/misc/CCicon_32.res $ROOT_DIR/src/CCicon_32.res
rm cc-w32-d3d.exe cc-w32-ogl.exe
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-ogl.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32
}
build_win64() {
echo "Building win64.."
cp $SOURCE_DIR/misc/CCicon_64.res $SOURCE_DIR/src/CCicon_64.res
cp $ROOT_DIR/misc/CCicon_64.res $ROOT_DIR/src/CCicon_64.res
rm cc-w64-d3d.exe cc-w64-ogl.exe
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-ogl.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32
}
# ----------------------------- compile linux
NIX32_FLAGS="-no-pie -fno-pie -m32 -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
NIX64_FLAGS="-no-pie -fno-pie -m64 -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
build_nix32() {
echo "Building linux32.."
cp $SOURCE_DIR/misc/CCicon_nix32 $SOURCE_DIR/src/CCicon_nix32.o
cp $ROOT_DIR/misc/CCicon_nix32 $ROOT_DIR/src/CCicon_nix32.o
rm cc-nix32
gcc *.c $ALL_FLAGS $NIX32_FLAGS CCicon_nix32.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-nix32 -lX11 -lXi -lpthread -lGL -lm -ldl
}
build_nix64() {
echo "Building linux64.."
cp $SOURCE_DIR/misc/CCicon_nix64 $SOURCE_DIR/src/CCicon_nix64.o
cp $ROOT_DIR/misc/CCicon_nix64 $ROOT_DIR/src/CCicon_nix64.o
rm cc-nix64
gcc *.c $ALL_FLAGS $NIX64_FLAGS CCicon_nix64.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-nix64 -lX11 -lXi -lpthread -lGL -lm -ldl
}
# ----------------------------- compile macOS
MAC32_CC="~/osx/target/bin/o32-clang"
MAC64_CC="~/osx/target/bin/o64-clang"
MACOS_FLAGS="-fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
build_mac32() {
echo "Building mac32.."
cp $SOURCE_DIR/misc/CCicon_mac32 $SOURCE_DIR/src/CCicon_mac32.o
cp $ROOT_DIR/misc/CCicon_mac32 $ROOT_DIR/src/CCicon_mac32.o
rm cc-osx32
$MAC32_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac32.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx32 -framework Carbon -framework AGL -framework OpenGL -framework IOKit -lgcc_s.1
}
build_mac64() {
echo "Building mac64.."
cp $SOURCE_DIR/misc/CCicon_mac64 $SOURCE_DIR/src/CCicon_mac64.o
cp $ROOT_DIR/misc/CCicon_mac64 $ROOT_DIR/src/CCicon_mac64.o
rm cc-osx64
$MAC64_CC *.c interop_cocoa.m $ALL_FLAGS $MACOS_FLAGS CCicon_mac64.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx64 -framework Cocoa -framework OpenGL -framework IOKit -lobjc
}
# ----------------------------- compile web
WEB_CC="~/emsdk/emscripten/1.38.31/emcc"
build_web() {
echo "Building web.."
rm cc.js
@ -95,15 +95,73 @@ build_web() {
sed -i 's#eventHandler.useCapture);#{ useCapture: eventHandler.useCapture, passive: false });#g' cc.js
}
# ----------------------------- compile raspberry pi
# I cloned https://github.com/raspberrypi/tools to get prebuilt cross compilers
# Then I copied across various files/folders from /usr/include and /usr/lib from a real Raspberry pi as needed
RPI_CC=~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc-4.8.3
RPI_FLAGS="-I ~/rpi/include -L ~/rpi/lib -fvisibility=hidden -rdynamic -DCC_BUILD_ICON"
build_rpi() {
echo "Building rpi.."
cp $SOURCE_DIR/misc/CCicon_rpi $SOURCE_DIR/src/CCicon_rpi.o
cp $ROOT_DIR/misc/CCicon_rpi $ROOT_DIR/src/CCicon_rpi.o
rm cc-rpi
$RPI_CC *.c $ALL_FLAGS $RPI32_FLAGS CCicon_rpi.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi -DCC_BUILD_RPI -lGLESv2 -lEGL -lX11 -lXi -lm -lpthread -ldl -lrt -Wl,-rpath-link ~/rpi/lib
$RPI_CC *.c $ALL_FLAGS $RPI_FLAGS CCicon_rpi.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-rpi -DCC_BUILD_RPI -lGLESv2 -lEGL -lX11 -lXi -lm -lpthread -ldl -lrt -Wl,-rpath-link ~/rpi/lib
}
# -----------------------------
cd $SOURCE_DIR/src/
# ----------------------------- compile android
DROID_FLAGS="-fPIC -shared -s -O1 -fvisibility=hidden -rdynamic"
DROID_LIBS="-lGLESv2 -lEGL -lm -landroid -llog"
NDK_ROOT="/home/buildbot/android/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin"
TOOLS_ROOT="/home/buildbot/android/sdk/build-tools/26.0.0"
SDK_ROOT="/home/buildbot/android/sdk/platforms/android-26"
build_android() {
echo "Building android.."
$NDK_ROOT/armv7a-linux-androideabi16-clang *.c $DROID_FLAGS -march=armv5 $DROID_LIBS -o cc-droid-arm_16
$NDK_ROOT/armv7a-linux-androideabi16-clang *.c $DROID_FLAGS $DROID_LIBS -o cc-droid-arm_32
$NDK_ROOT/aarch64-linux-android21-clang *.c $DROID_FLAGS $DROID_LIBS -o cc-droid-arm_64
$NDK_ROOT/i686-linux-android16-clang *.c $DROID_FLAGS $DROID_LIBS -o cc-droid-x86_32
$NDK_ROOT/x86_64-linux-android21-clang *.c $DROID_FLAGS $DROID_LIBS -o cc-droid-x86_64
cd $ROOT_DIR/android/app/src/main
# remove old java temp files
rm -rf obj
mkdir obj
rm classes.dex
# copy required native libraries
rm -rf lib
mkdir lib lib/armeabi lib/armeabi-v7a lib/arm64-v8alib/x86 lib/x86_64
cp $ROOT_DIR/src/cc-droid-arm_16 lib/armeabi/libclassicube.so
cp $ROOT_DIR/src/cc-droid-arm_32 lib/armeabi-v7a/libclassicube.so
cp $ROOT_DIR/src/cc-droid-arm_64 lib/arm64-v8a/libclassicube.so
cp $ROOT_DIR/src/cc-droid-x86_32 lib/x86/libclassicube.so
cp $ROOT_DIR/src/cc-droid-x86_64 lib/x86_64/libclassicube.so
# The following commands are for manually building an .apk, see
# https://spin.atomicobject.com/2011/08/22/building-android-application-bundles-apks-by-hand/
# https://github.com/cnlohr/rawdrawandroid/blob/master/Makefile
# https://stackoverflow.com/questions/41132753/how-can-i-build-an-android-apk-without-gradle-on-the-command-line
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/Makefile
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/CMakeLists.txt
# compile interop java file into its multiple .class files
javac java/com/classicube/MainActivity.java -d ./obj -classpath $SDK_ROOT/android.jar
# compile the multiple .class files into one .dex file
$TOOLS_ROOT/dx --dex --output=obj/classes.dex ./obj
# create initial .apk with packaged version of resources
$TOOLS_ROOT/aapt package -f -M AndroidManifest.xml -S res -F obj/cc-unsigned.apk -I $SDK_ROOT/android.jar
# and add all the required files
cp obj/classes.dex classes.dex
$TOOLS_ROOT/aapt add -f obj/cc-unsigned.apk classes.dex lib/armeabi/libclassicube.so lib/armeabi-v7a/libclassicube.so lib/arm64-v8a/libclassicube.so lib/x86/libclassicube.so lib/x86_64/libclassicube.so
# sign the apk with debug key (https://stackoverflow.com/questions/16711233/)
cp obj/cc-unsigned.apk obj/cc-signed.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore -storepass android -keypass android obj/cc-signed.apk androiddebugkey
# create aligned .apk file
$TOOLS_ROOT/zipalign -f -v 4 obj/cc-signed.apk $ROOT_DIR/src/cc.apk
}
# ----------------------------- driver
cd $ROOT_DIR/src/
echo $PWD
git pull https://github.com/UnknownShadow200/ClassiCube.git
git fetch --all
@ -118,6 +176,7 @@ build_mac32
build_mac64
build_web
build_rpi
build_android
cd ~
python3 notify.py

View File

@ -1,54 +0,0 @@
FLAGS="-fPIC -shared -s -O1 -fvisibility=hidden -rdynamic"
LIBS="-lGLESv2 -lEGL -lm -landroid -llog"
NDK_ROOT="/home/buildbot/android/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin"
TOOLS_ROOT="/home/buildbot/android/sdk/build-tools/26.0.0"
SDK_ROOT="/home/buildbot/android/sdk/platforms/android-26"
cd /home/buildbot/client/src
$NDK_ROOT/armv7a-linux-androideabi16-clang *.c $FLAGS -march=armv5 $LIBS -o cc-droid-arm_16
$NDK_ROOT/armv7a-linux-androideabi16-clang *.c $FLAGS $LIBS -o cc-droid-arm_32
$NDK_ROOT/aarch64-linux-android21-clang *.c $FLAGS $LIBS -o cc-droid-arm_64
$NDK_ROOT/i686-linux-android16-clang *.c $FLAGS $LIBS -o cc-droid-x86_32
$NDK_ROOT/x86_64-linux-android21-clang *.c $FLAGS $LIBS -o cc-droid-x86_64
cd ../android/app/src/main
# remove old java temp files
rm -rf obj
mkdir obj
rm classes.dex
# copy required native libraries
rm -rf lib
mkdir lib
mkdir lib/armeabi
mkdir lib/armeabi-v7a
mkdir lib/arm64-v8a
mkdir lib/x86
mkdir lib/x86_64
cp ~/client/src/cc-droid-arm_16 lib/armeabi/libclassicube.so
cp ~/client/src/cc-droid-arm_32 lib/armeabi-v7a/libclassicube.so
cp ~/client/src/cc-droid-arm_64 lib/arm64-v8a/libclassicube.so
cp ~/client/src/cc-droid-x86_32 lib/x86/libclassicube.so
cp ~/client/src/cc-droid-x86_64 lib/x86_64/libclassicube.so
# The following commands are for manually building an .apk, see
# https://spin.atomicobject.com/2011/08/22/building-android-application-bundles-apks-by-hand/
# https://github.com/cnlohr/rawdrawandroid/blob/master/Makefile
# https://stackoverflow.com/questions/41132753/how-can-i-build-an-android-apk-without-gradle-on-the-command-line
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/Makefile
# https://github.com/skanti/Android-Manual-Build-Command-Line/blob/master/hello-jni/CMakeLists.txt
# compile interop java file into its multiple .class files
javac java/com/classicube/MainActivity.java -d ./obj -classpath $SDK_ROOT/android.jar
# compile the multiple .class files into one .dex file
$TOOLS_ROOT/dx --dex --output=obj/classes.dex ./obj
# create initial .apk with packaged version of resources
$TOOLS_ROOT/aapt package -f -M AndroidManifest.xml -S res -F obj/cc-unsigned.apk -I $SDK_ROOT/android.jar
# and add all the required files
cp obj/classes.dex classes.dex
$TOOLS_ROOT/aapt add -f obj/cc-unsigned.apk classes.dex lib/armeabi/libclassicube.so lib/armeabi-v7a/libclassicube.so lib/arm64-v8a/libclassicube.so lib/x86/libclassicube.so lib/x86_64/libclassicube.so
# sign the apk with debug key (https://stackoverflow.com/questions/16711233/)
cp obj/cc-unsigned.apk obj/cc-signed.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore -storepass android -keypass android obj/cc-signed.apk androiddebugkey
# create aligned .apk file
$TOOLS_ROOT/zipalign -f -v 4 obj/cc-signed.apk ~/client/src/cc.apk

View File

@ -17,7 +17,7 @@ typedef unsigned __int64 cc_uint64;
#ifdef _WIN64
typedef unsigned __int64 cc_uintptr;
#else
typedef unsigned int cc_uintptr;
typedef unsigned __int32 cc_uintptr;
#endif
#define CC_INLINE inline