Skip to content

MxDany/easybuild

Repository files navigation

easybuild

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.

Step1: Configure cross toolchain

  1. Open scripts/platform file to add your own cross toolchain.

  2. Add your own platform name in var PLAT_LIST.

    such as, mingw32, Use MinGW compiler to cross compile windows program under linux.

  3. Add your supported CPU architecture in function get_devlist().

    such as, DEV_LIST="x86 x86_64", means supports win32 win64

  4. 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.

Step2: Create compilation script

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.gz

It will copy the source file to ./tarball, and generate a compilation script ./build_sqlite3.sh in current path.

Step3: Custom compilation script

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.shbuild_ffmpeg.shbuild_curl.sh, etc.

Step4: Enjoy easybuild

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 windows system with win32 share library(dll)

    ./build_sqlite3.sh -p=mingw32 -d=x86 -m=share
    
  • build for android system with arm64-v8a both 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.

About

easybuild is a cross-platform compilation tool template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages