easybuild is a cross-platform compilation tool template. You can build a cross-compilation environment by simply configuring your own cross-toolchain, to compile various open source code and their dependent libraries.
-
Open
scripts/platformfile to add your own cross toolchain. -
Add your own platform name in var
PLAT_LIST.such as,
mingw32, UseMinGWcompiler to cross compile windows program under linux. -
Add your supported CPU architecture in function
get_devlist().such as,
DEV_LIST="x86 x86_64", means supportswin32 win64 -
Add your toolchain infomation in function
parse_platform().BUILD_OS="linux" BUILD_CROSS=true CC_TYPE="gcc" THREAD_MODEL="posix" case "$DEV_ARCH" in x86) BUILD_ARCH="x86" BUILD_CPU="i686" BUILD_HOST="i686-w64-mingw32" ;; x86_64) BUILD_ARCH="x86_64" BUILD_CPU="x86_64" BUILD_HOST="x86_64-w64-mingw32" ;; esac BUILD_PREFIX="${BUILD_HOST}-" AR="${BUILD_HOST}-ar" AS="${BUILD_HOST}-as" CC="${BUILD_HOST}-gcc-$THREAD_MODEL" CXX="${BUILD_HOST}-g++-$THREAD_MODEL" CPP="$CC -E" LD="${BUILD_HOST}-ld" RANLIB="${BUILD_HOST}-ranlib" STRIP="${BUILD_HOST}-strip" BUILD_SYSROOT=$(cd $($CC -print-sysroot) && pwd)
In the above configuration as you can see, the default MinGW thread model is
posix.
Use make_template.sh to create your compilation script, It uses autoconfig rules to create template by default.
make_template.sh
Usage:
Universal multi-platform quick compile tools. run make_template.sh to quickly create your own compile script.
./scripts/make_template.sh [template name] [tarball Relative Path]For example, you want to You want to cross compile sqlite3, and you have the source code /home/lihan/download/sqlite-autoconf-3310100.tar.gz, you could run script to make sqlite3 compile template.
./scripts/make_template.sh sqlite3 /home/lihan/download/sqlite-autoconf-3310100.tar.gzIt will copy the source file to ./tarball, and generate a compilation script ./build_sqlite3.sh in current path.
If you need to add dependent libraries, then you need to modify the script ./build_sqlite3.sh yourself.
You can refer to several other compilation scripts to learn how to add dependent libraries, such as, build_python.sh、build_ffmpeg.sh、build_curl.sh, etc.
Once you have completed the configuration, You can quickly compile open source code for different platforms very easily.
lihan@Xx-PC:/mnt/c/Users/Xx/Desktop/repos/github/easybuild$ ./build_sqlite3.sh -h
Usage:
Universal multi-platform quick compile tools. Run make_template.sh to quickly create your own compile script.
-m,--share-mode Build Link Mode(static,share,both).
-t,--tag User Custom Tag(1.x.x,3310100).
-p,--platform Platform(local,Dev,generic,android-ndk-r21,mingw32).
-a,--arch Device/Arch.
-d,--device Device/Arch.
clean Clear files generated by the specified Platform and Device/Arch.
distclean Clear all files generated by the current project.
clear Clear all files generated by the all projects, typically delete the 'output_*' dirs.
test Only show command and generate Help Documents in 'src', not to compile.
clone Clone current project, separate it from mixed project.
-h,--help Display this help and exit.
Supported Mode:
- static|share|both
Supported Tag:
- 1.x.x|3310100
Supported Platform(Dev/Arch):
- local(x86_64)
- Dev(Dev01|Dev02|Dev03|Dev04|Dev05)
- generic(armv2|armv5te)
- android-ndk-r21(armeabi-v7a|arm64-v8a|x86|x86_64)
- mingw32(x86|x86_64)
Typical Usage:
- ./build_sqlite3.sh -p=mingw32 -d=x86
- ./build_sqlite3.sh -p=mingw32 -d=x86 -m=share
- ./build_sqlite3.sh -p=mingw32 -d=x86 -m=share -t=yourtag
Current Setting:[Mode:static, Tag:3310100, Platform:local, Device/Arch:x86_64]
-
build for local system with static library
./build_sqlite3.sh
-
build for local system with share library
./build_sqlite3.sh -m=share
-
build for
windowssystem withwin32share library(dll)./build_sqlite3.sh -p=mingw32 -d=x86 -m=share -
build for
androidsystem witharm64-v8aboth share and static library./build_sqlite3.sh -p=android-ndk-r21 -d=arm64-v8a -m=both
It will install the build file in path like this output_sqlite3/sqlite3-local-x86_64-static-3310100/install.
You can refer to the compilation script(./build_xxx.sh) in the current directory to learn how to use easybuild.