From 99ff2e3eb8cf838201d52a73d7bbdd0c8ed15b20 Mon Sep 17 00:00:00 2001 From: neodiX Date: Wed, 20 Dec 2023 20:38:54 +0100 Subject: [PATCH] WIP jenkins pipeline: include mac nix build --- assembly/cicd/jenkins/test-builds.groovy | 46 +++-------------- assembly/nix/linux-x86-64-static.nix | 2 +- assembly/nix/linux-x86-64-tonlib.nix | 2 +- assembly/nix/macos-arm64-static.nix | 65 ++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 assembly/nix/macos-arm64-static.nix diff --git a/assembly/cicd/jenkins/test-builds.groovy b/assembly/cicd/jenkins/test-builds.groovy index 7e0a2c3b5..cf97aa4a1 100644 --- a/assembly/cicd/jenkins/test-builds.groovy +++ b/assembly/cicd/jenkins/test-builds.groovy @@ -26,22 +26,6 @@ pipeline { } } } - stage('Ubuntu 20.04 x86-64 (portable)') { - agent { - label 'Ubuntu_x86-64' - } - steps { - timeout(time: 90, unit: 'MINUTES') { - sh ''' - cp assembly/native/build-ubuntu-20.04-portable.sh . - chmod +x build-ubuntu-20.04-portable.sh - ./build-ubuntu-20.04-portable.sh -t -a - ''' - sh 'zip -r ton-x86_64-linux-portable ./artifacts/*' - archiveArtifacts artifacts: 'ton-x86_64-linux-portable.zip' - } - } - } stage('Ubuntu 20.04 x86-64 (nix)') { agent { label 'Ubuntu_x86-64' @@ -80,22 +64,6 @@ pipeline { } } } - stage('Ubuntu 20.04 aarch64 (portable)') { - agent { - label 'Ubuntu_arm64' - } - steps { - timeout(time: 90, unit: 'MINUTES') { - sh ''' - cp assembly/native/build-ubuntu-20.04-portable.sh . - chmod +x build-ubuntu-20.04-portable.sh - ./build-ubuntu-20.04-portable.sh -t -a - ''' - sh 'zip -r ton-arm64-linux-portable ./artifacts/*' - archiveArtifacts artifacts: 'ton-arm64-linux-portable.zip' - } - } - } stage('Ubuntu 20.04 aarch64 (nix)') { agent { label 'Ubuntu_arm64' @@ -141,18 +109,18 @@ pipeline { steps { timeout(time: 90, unit: 'MINUTES') { sh ''' - cp assembly/native/build-macos-portable.sh . - chmod +x build-macos-portable.sh - ./build-macos-portable.sh -t -a -o 12.7 + cp assembly/nix/macos-arm64-* . + export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.11.tar.gz + nix-build macos-arm64-static.nix ''' - sh 'zip -r ton-x86-64-macos-portable ./artifacts/*' - archiveArtifacts artifacts: 'ton-x86-64-macos-portable.zip' + sh 'zip -r ton-arm64-macos-portable ./artifacts/bin/*' + archiveArtifacts artifacts: 'ton-arm64-macos-portable.zip' } } } stage('macOS 12.6 aarch64 (shared)') { agent { - label 'macOS_12.6.3-arm64' + label 'macOS_12.6-arm64-m1' } steps { timeout(time: 90, unit: 'MINUTES') { @@ -168,7 +136,7 @@ pipeline { } stage('macOS 12.6 aarch64 (portable)') { agent { - label 'macOS_12.6.3-arm64' + label 'macOS_12.6-arm64-m1' } steps { timeout(time: 90, unit: 'MINUTES') { diff --git a/assembly/nix/linux-x86-64-static.nix b/assembly/nix/linux-x86-64-static.nix index 4d05c9a13..a368051ff 100644 --- a/assembly/nix/linux-x86-64-static.nix +++ b/assembly/nix/linux-x86-64-static.nix @@ -19,7 +19,7 @@ pkgs.stdenv.mkDerivation { # gcc buildInputs = with pkgs; [ - pkgsStatic.openssl pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static + pkgsStatic.openssl_3_0 pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1 glibc.static ]; makeStatic = true; diff --git a/assembly/nix/linux-x86-64-tonlib.nix b/assembly/nix/linux-x86-64-tonlib.nix index b87298582..103cd7b0b 100644 --- a/assembly/nix/linux-x86-64-tonlib.nix +++ b/assembly/nix/linux-x86-64-tonlib.nix @@ -34,7 +34,7 @@ stdenv227.mkDerivation { buildInputs = with pkgs; [ - pkgsStatic.openssl pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1 + pkgsStatic.openssl_3_0 pkgsStatic.zlib pkgsStatic.libmicrohttpd.dev pkgsStatic.libsodium.dev pkgsStatic.secp256k1 ]; dontAddStaticConfigureFlags = false; diff --git a/assembly/nix/macos-arm64-static.nix b/assembly/nix/macos-arm64-static.nix new file mode 100644 index 000000000..9aff71a93 --- /dev/null +++ b/assembly/nix/macos-arm64-static.nix @@ -0,0 +1,65 @@ +# export NIX_PATH=nixpkgs=https://github.com/nixOS/nixpkgs/archive/23.05.tar.gz + +{ pkgs ? import { system = builtins.currentSystem; } +, lib ? pkgs.lib +, stdenv ? pkgs.stdenv +}: + +pkgs.stdenv.mkDerivation { # clang default + pname = "ton"; + version = "dev-bin"; + + src = ./.; + + nativeBuildInputs = with pkgs; + [ cmake ninja git pkg-config ]; + + buildInputs = with pkgs; + lib.forEach [ + secp256k1 libsodium.dev libmicrohttpd.dev gmp.dev nettle.dev libtasn1.dev libidn2.dev libunistring.dev gettext (gnutls.override { withP11-kit = false; }).dev + ] + (x: x.overrideAttrs(oldAttrs: rec { configureFlags = (oldAttrs.configureFlags or []) ++ [ "--enable-static" "--disable-shared" "--disable-tests" ]; dontDisableStatic = true; })) + ++ [ + darwin.apple_sdk.frameworks.CoreFoundation + (openssl.override { static = true; }).dev + (zlib.override { shared = false; }).dev + (libiconv.override { enableStatic = true; enableShared = false; }) + ]; + + + dontAddStaticConfigureFlags = true; + doCheck = false; + makeStatic = true; + + + configureFlags = []; + + cmakeFlags = [ + "-DTON_USE_ABSEIL=OFF" + "-DNIX=ON" + "-DCMAKE_CROSSCOMPILING=OFF" + "-DCMAKE_LINK_SEARCH_START_STATIC=ON" + "-DCMAKE_LINK_SEARCH_END_STATIC=ON" + "-DBUILD_SHARED_LIBS=OFF" + "-DCMAKE_CXX_FLAGS=-stdlib=libc++" + "-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.3" + ]; + + LDFLAGS = [ + "-static-libstdc++" + "-framework CoreFoundation" + ]; + + postInstall = '' + moveToOutput bin "$bin" + ''; + + preFixup = '' + for fn in "$bin"/bin/* "$out"/lib/*.dylib; do + echo Fixing libc++ in "$fn" + install_name_tool -change "$(otool -L "$fn" | grep libc++.1 | cut -d' ' -f1 | xargs)" libc++.1.dylib "$fn" + install_name_tool -change "$(otool -L "$fn" | grep libc++abi.1 | cut -d' ' -f1 | xargs)" libc++abi.dylib "$fn" + done + ''; + outputs = [ "bin" "out" ]; +}