mirror of https://github.com/oxen-io/lokinet
Merge pull request #1849 from majestrate/dry-cross-2022-02-02
dry cross compile
This commit is contained in:
commit
65ef0e4bfb
|
@ -146,6 +146,36 @@ local windows_cross_pipeline(name,
|
|||
],
|
||||
};
|
||||
|
||||
// linux cross compile on debian
|
||||
local linux_cross_pipeline(name,
|
||||
cross_targets,
|
||||
arch='amd64',
|
||||
build_type='Release',
|
||||
cmake_extra='',
|
||||
extra_cmds=[],
|
||||
jobs=6,
|
||||
allow_fail=false) = {
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: name,
|
||||
platform: { arch: arch },
|
||||
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
|
||||
steps: [
|
||||
submodules,
|
||||
{
|
||||
name: 'build',
|
||||
image: docker_base + 'debian-stable-cross',
|
||||
pull: 'always',
|
||||
[if allow_fail then 'failure']: 'ignore',
|
||||
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, CROSS_TARGETS: std.join(':', cross_targets) },
|
||||
commands: [
|
||||
'echo "Building on ${DRONE_STAGE_MACHINE}"',
|
||||
'VERBOSE=1 JOBS=' + jobs + ' ./contrib/cross.sh ' + std.join(' ', cross_targets) + (if std.length(cmake_extra) > 0 then ' -- ' + cmake_extra else ''),
|
||||
] + extra_cmds,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// Builds a snapshot .deb on a debian-like system by merging into the debian/* or ubuntu/* branch
|
||||
local deb_builder(image, distro, distro_branch, arch='amd64', loki_repo=true) = {
|
||||
kind: 'pipeline',
|
||||
|
@ -310,6 +340,12 @@ local docs_pipeline(name, image, extra_cmds=[], allow_fail=false) = {
|
|||
// ARM builds (ARM64 and armhf)
|
||||
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64', jobs=4),
|
||||
debian_pipeline('Debian stable (armhf)', docker_base + 'debian-stable/arm32v7', arch='arm64', jobs=4),
|
||||
|
||||
// cross compile targets
|
||||
linux_cross_pipeline('Cross Compile (mips)', cross_targets=['mips-linux-gnu', 'mipsel-linux-gnu']),
|
||||
linux_cross_pipeline('Cross Compile (arm/arm64)', cross_targets=['arm-linux-gnueabihf', 'aarch64-linux-gnu']),
|
||||
linux_cross_pipeline('Cross Compile (ppc64le)', cross_targets=['powerpc64le-linux-gnu']),
|
||||
|
||||
// android apk builder
|
||||
apk_builder('android apk', docker_base + 'flutter', extra_cmds=['UPLOAD_OS=android ./contrib/ci/drone-static-upload.sh']),
|
||||
|
||||
|
|
|
@ -73,6 +73,9 @@ option(WITH_BOOTSTRAP "build lokinet-bootstrap tool" ${DEFAULT_WITH_BOOTSTRAP})
|
|||
|
||||
include(cmake/enable_lto.cmake)
|
||||
|
||||
option(CROSS_PLATFORM "cross compiler platform" "Linux")
|
||||
option(CROSS_PREFIX "toolchain cross compiler prefix" "")
|
||||
|
||||
option(BUILD_STATIC_DEPS "Download, build, and statically link against core dependencies" OFF)
|
||||
option(STATIC_LINK "link statically against dependencies" ${BUILD_STATIC_DEPS})
|
||||
if(BUILD_STATIC_DEPS AND NOT STATIC_LINK)
|
||||
|
|
|
@ -3,42 +3,62 @@
|
|||
# helper script for me for when i cross compile
|
||||
# t. jeff
|
||||
#
|
||||
set -e
|
||||
|
||||
die() {
|
||||
echo $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
platform=${PLATFORM:-Linux}
|
||||
root="$(readlink -e $(dirname $0)/../)"
|
||||
cd $root
|
||||
set -e
|
||||
set -x
|
||||
test $# = 0 && die no targets provided
|
||||
mkdir -p build-cross
|
||||
echo "all: $@" > build-cross/Makefile
|
||||
for targ in $@ ; do
|
||||
mkdir -p $root/build-cross/build-$targ
|
||||
cd $root/build-cross/build-$targ
|
||||
|
||||
cmake_opts="-DBUILD_STATIC_DEPS=ON \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DBUILD_LIBLOKINET=OFF \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DWITH_SYSTEMD=OFF \
|
||||
-DFORCE_OXENMQ_SUBMODULE=ON \
|
||||
-DSUBMODULE_CHECK=OFF \
|
||||
-DWITH_LTO=OFF \
|
||||
-DWITH_BOOTSTRAP=OFF \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDeb"
|
||||
|
||||
targets=()
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
if [ "$1" = "--" ]; then
|
||||
shift
|
||||
cmake_opts=$@
|
||||
break
|
||||
fi
|
||||
targets+=("$1")
|
||||
shift
|
||||
done
|
||||
test ${#targets[@]} = 0 && die no targets provided
|
||||
|
||||
archs="${targets[@]}"
|
||||
echo "all: $archs" > build-cross/Makefile
|
||||
for arch in $archs ; do
|
||||
mkdir -p $root/build-cross/build-$arch
|
||||
cd $root/build-cross/build-$arch
|
||||
cmake \
|
||||
-G 'Unix Makefiles' \
|
||||
-DCROSS_PLATFORM=$platform \
|
||||
-DCROSS_PREFIX=$arch \
|
||||
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \
|
||||
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always\
|
||||
-DCMAKE_TOOLCHAIN_FILE=$root/contrib/cross/$targ.toolchain.cmake\
|
||||
-DBUILD_STATIC_DEPS=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DBUILD_LIBLOKINET=OFF \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DWITH_SYSTEMD=OFF \
|
||||
-DFORCE_OXENMQ_SUBMODULE=ON \
|
||||
-DSUBMODULE_CHECK=OFF \
|
||||
-DWITH_LTO=OFF \
|
||||
-DWITH_BOOTSTRAP=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$root/contrib/cross/cross.toolchain.cmake \
|
||||
$cmake_opts \
|
||||
$root
|
||||
cd $root/build-cross
|
||||
echo -ne "$targ:\n\t\$(MAKE) -C build-$targ\n" >> $root/build-cross/Makefile
|
||||
echo -ne "$arch:\n\t\$(MAKE) -C build-$arch\n" >> $root/build-cross/Makefile
|
||||
|
||||
done
|
||||
cd $root
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
|
@ -1,13 +0,0 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
|
@ -1,7 +1,5 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX mips-linux-gnu)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME ${CROSS_PLATFORM})
|
||||
set(TOOLCHAIN_PREFIX ${CROSS_PREFIX})
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
@ -1,13 +0,0 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX mips64-linux-gnuabi64)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
|
@ -1,13 +0,0 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX mipsel-linux-gnu)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
|
@ -1,13 +0,0 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(TOOLCHAIN_PREFIX powerpc64le-linux-gnu)
|
||||
set(TOOLCHAIN_SUFFIX)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
|
||||
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})
|
12
readme.md
12
readme.md
|
@ -68,9 +68,19 @@ If you want to build from source:
|
|||
$ make -j$(nproc)
|
||||
$ sudo make install
|
||||
|
||||
|
||||
#### Cross Compile For Linux <span id="linux-cross" />
|
||||
|
||||
install the toolchain for `$arch` this example is `aarch64`
|
||||
current cross targets:
|
||||
|
||||
* aarch64-linux-gnu
|
||||
* arm-linux-gnueabihf
|
||||
* mips-linux-gnu
|
||||
* mips64-linux-gnuabi64
|
||||
* mipsel-linux-gnu
|
||||
* powerpc64le-linux-gnu
|
||||
|
||||
install the toolchain (this one is for `aarch64-linux-gnu`, you can provide your own toolchain if you want)
|
||||
|
||||
$ sudo apt install g{cc,++}-aarch64-linux-gnu
|
||||
|
||||
|
|
Loading…
Reference in New Issue