mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-02-27 13:43:13 +00:00
nix: drop unnecessay asert for Android SDK on macOS
Newer nixpkgs should have Android SDK for aarch64. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
456ce53c0d
commit
307519076a
48
.github/workflows/ci-nix.yml
vendored
Normal file
48
.github/workflows/ci-nix.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
name: ci / nix
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
checks: write
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
system:
|
||||
- aarch64-darwin
|
||||
- x86_64-linux
|
||||
nixpkg:
|
||||
- libwaku
|
||||
- libwaku-android-arm64
|
||||
- wakucanary
|
||||
|
||||
exclude:
|
||||
# Android SDK limitation
|
||||
- system: aarch64-darwin
|
||||
nixpkg: libwaku-android-arm64
|
||||
|
||||
include:
|
||||
- system: aarch64-darwin
|
||||
runs_on: [self-hosted, macOS, ARM64]
|
||||
|
||||
- system: x86_64-linux
|
||||
runs_on: [self-hosted, Linux, X64]
|
||||
|
||||
name: '${{ matrix.system }} / ${{ matrix.nixpkg }}'
|
||||
runs-on: ${{ matrix.runs_on }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: 'Run Nix build for {{ matrix.nixpkg }}'
|
||||
shell: bash
|
||||
run: nix build -L '.?submodules=1#${{ matrix.nixpkg }}'
|
||||
|
||||
- name: 'Show result contents'
|
||||
shell: bash
|
||||
run: find result -type f
|
||||
60
Makefile
60
Makefile
@ -147,7 +147,7 @@ NIM_PARAMS := $(NIM_PARAMS) -d:disable_libbacktrace
|
||||
endif
|
||||
|
||||
# enable experimental exit is dest feature in libp2p mix
|
||||
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest
|
||||
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest
|
||||
|
||||
libbacktrace:
|
||||
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
||||
@ -186,9 +186,9 @@ LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit
|
||||
LIBRLN_VERSION := v0.9.0
|
||||
|
||||
ifeq ($(detected_OS),Windows)
|
||||
LIBRLN_FILE := rln.lib
|
||||
LIBRLN_FILE ?= rln.lib
|
||||
else
|
||||
LIBRLN_FILE := librln_$(LIBRLN_VERSION).a
|
||||
LIBRLN_FILE ?= librln_$(LIBRLN_VERSION).a
|
||||
endif
|
||||
|
||||
$(LIBRLN_FILE):
|
||||
@ -466,8 +466,13 @@ ifndef ANDROID_NDK_HOME
|
||||
endif
|
||||
|
||||
build-libwaku-for-android-arch:
|
||||
$(MAKE) rebuild-nat-libs CC=$(ANDROID_TOOLCHAIN_DIR)/bin/$(ANDROID_COMPILER) && \
|
||||
./scripts/build_rln_android.sh $(CURDIR)/build $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(CROSS_TARGET) $(ABIDIR) && \
|
||||
ifneq ($(findstring /nix/store,$(LIBRLN_FILE)),)
|
||||
mkdir -p $(CURDIR)/build/android/$(ABIDIR)/
|
||||
cp $(LIBRLN_FILE) $(CURDIR)/build/android/$(ABIDIR)/
|
||||
else
|
||||
./scripts/build_rln_android.sh $(CURDIR)/build $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(CROSS_TARGET) $(ABIDIR)
|
||||
endif
|
||||
$(MAKE) rebuild-nat-libs CC=$(ANDROID_TOOLCHAIN_DIR)/bin/$(ANDROID_COMPILER)
|
||||
CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_ARCH=$(ANDROID_ARCH) ANDROID_COMPILER=$(ANDROID_COMPILER) ANDROID_TOOLCHAIN_DIR=$(ANDROID_TOOLCHAIN_DIR) $(ENV_SCRIPT) nim libWakuAndroid $(NIM_PARAMS) waku.nims
|
||||
|
||||
libwaku-android-arm64: ANDROID_ARCH=aarch64-linux-android
|
||||
@ -504,6 +509,51 @@ libwaku-android:
|
||||
# It's likely this architecture is not used so we might just not support it.
|
||||
# $(MAKE) libwaku-android-arm
|
||||
|
||||
#################
|
||||
## iOS Bindings #
|
||||
#################
|
||||
.PHONY: libwaku-ios-precheck \
|
||||
libwaku-ios-device \
|
||||
libwaku-ios-simulator \
|
||||
libwaku-ios
|
||||
|
||||
IOS_DEPLOYMENT_TARGET ?= 18.0
|
||||
|
||||
# Get SDK paths dynamically using xcrun
|
||||
define get_ios_sdk_path
|
||||
$(shell xcrun --sdk $(1) --show-sdk-path 2>/dev/null)
|
||||
endef
|
||||
|
||||
libwaku-ios-precheck:
|
||||
ifeq ($(detected_OS),Darwin)
|
||||
@command -v xcrun >/dev/null 2>&1 || { echo "Error: Xcode command line tools not installed"; exit 1; }
|
||||
else
|
||||
$(error iOS builds are only supported on macOS)
|
||||
endif
|
||||
|
||||
# Build for iOS architecture
|
||||
build-libwaku-for-ios-arch:
|
||||
IOS_SDK=$(IOS_SDK) IOS_ARCH=$(IOS_ARCH) IOS_SDK_PATH=$(IOS_SDK_PATH) $(ENV_SCRIPT) nim libWakuIOS $(NIM_PARAMS) waku.nims
|
||||
|
||||
# iOS device (arm64)
|
||||
libwaku-ios-device: IOS_ARCH=arm64
|
||||
libwaku-ios-device: IOS_SDK=iphoneos
|
||||
libwaku-ios-device: IOS_SDK_PATH=$(call get_ios_sdk_path,iphoneos)
|
||||
libwaku-ios-device: | libwaku-ios-precheck build deps
|
||||
$(MAKE) build-libwaku-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
|
||||
# iOS simulator (arm64 - Apple Silicon Macs)
|
||||
libwaku-ios-simulator: IOS_ARCH=arm64
|
||||
libwaku-ios-simulator: IOS_SDK=iphonesimulator
|
||||
libwaku-ios-simulator: IOS_SDK_PATH=$(call get_ios_sdk_path,iphonesimulator)
|
||||
libwaku-ios-simulator: | libwaku-ios-precheck build deps
|
||||
$(MAKE) build-libwaku-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
|
||||
# Build all iOS targets
|
||||
libwaku-ios:
|
||||
$(MAKE) libwaku-ios-device
|
||||
$(MAKE) libwaku-ios-simulator
|
||||
|
||||
cwaku_example: | build libwaku
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
cc -o "build/$@" \
|
||||
|
||||
28
flake.lock
generated
28
flake.lock
generated
@ -2,17 +2,17 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1740603184,
|
||||
"narHash": "sha256-t+VaahjQAWyA+Ctn2idyo1yxRIYpaDxMgHkgCNiMJa4=",
|
||||
"lastModified": 1757590060,
|
||||
"narHash": "sha256-EWwwdKLMZALkgHFyKW7rmyhxECO74+N+ZO5xTDnY/5c=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f44bd8ca21e026135061a0a57dcf3d0775b67a49",
|
||||
"rev": "0ef228213045d2cdb5a169a95d63ded38670b293",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f44bd8ca21e026135061a0a57dcf3d0775b67a49",
|
||||
"rev": "0ef228213045d2cdb5a169a95d63ded38670b293",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@ -51,18 +51,18 @@
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1749115386,
|
||||
"narHash": "sha256-UexIE2D7zr6aRajwnKongXwCZCeRZDXOL0kfjhqUFSU=",
|
||||
"owner": "vacp2p",
|
||||
"repo": "zerokit",
|
||||
"rev": "dc0b31752c91e7b4fefc441cfa6a8210ad7dba7b",
|
||||
"type": "github"
|
||||
"lastModified": 1762211504,
|
||||
"narHash": "sha256-SbDoBElFYJ4cYebltxlO2lYnz6qOaDAVY6aNJ5bqHDE=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "3160d9504d07791f2fc9b610948a6cf9a58ed488",
|
||||
"revCount": 342,
|
||||
"type": "git",
|
||||
"url": "https://github.com/vacp2p/zerokit"
|
||||
},
|
||||
"original": {
|
||||
"owner": "vacp2p",
|
||||
"repo": "zerokit",
|
||||
"rev": "dc0b31752c91e7b4fefc441cfa6a8210ad7dba7b",
|
||||
"type": "github"
|
||||
"rev": "3160d9504d07791f2fc9b610948a6cf9a58ed488",
|
||||
"type": "git",
|
||||
"url": "https://github.com/vacp2p/zerokit"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -10,8 +10,9 @@
|
||||
# We are pinning the commit because ultimately we want to use same commit across different projects.
|
||||
# A commit from nixpkgs 24.11 release : https://github.com/NixOS/nixpkgs/tree/release-24.11
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/0ef228213045d2cdb5a169a95d63ded38670b293";
|
||||
# WARNING: Remember to update commit and use 'nix flake update' to update flake.lock.
|
||||
zerokit = {
|
||||
url = "github:vacp2p/zerokit?rev=dc0b31752c91e7b4fefc441cfa6a8210ad7dba7b";
|
||||
url = "git+https://github.com/vacp2p/zerokit?rev=3160d9504d07791f2fc9b610948a6cf9a58ed488";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
@ -60,8 +61,6 @@
|
||||
inherit stableSystems;
|
||||
src = self;
|
||||
targets = ["libwaku"];
|
||||
# We are not able to compile the code with nim-unwrapped-2_0
|
||||
useSystemNim = false;
|
||||
zerokitRln = zerokit.packages.${system}.rln;
|
||||
};
|
||||
|
||||
@ -69,12 +68,10 @@
|
||||
inherit stableSystems;
|
||||
src = self;
|
||||
targets = ["wakucanary"];
|
||||
# We are not able to compile the code with nim-unwrapped-2_0
|
||||
useSystemNim = false;
|
||||
zerokitRln = zerokit.packages.${system}.rln;
|
||||
};
|
||||
|
||||
default = libwaku-android-arm64;
|
||||
default = libwaku;
|
||||
});
|
||||
|
||||
devShells = forAllSystems (system: {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
{
|
||||
config ? {},
|
||||
pkgs ? import <nixpkgs> { },
|
||||
pkgs,
|
||||
src ? ../.,
|
||||
targets ? ["libwaku-android-arm64"],
|
||||
verbosity ? 2,
|
||||
verbosity ? 1,
|
||||
useSystemNim ? true,
|
||||
quickAndDirty ? true,
|
||||
stableSystems ? [
|
||||
@ -19,43 +18,31 @@ assert pkgs.lib.assertMsg ((src.submodules or true) == true)
|
||||
let
|
||||
inherit (pkgs) stdenv lib writeScriptBin callPackage;
|
||||
|
||||
revision = lib.substring 0 8 (src.rev or "dirty");
|
||||
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
tools = pkgs.callPackage ./tools.nix {};
|
||||
version = tools.findKeyValue "^version = \"([a-f0-9.-]+)\"$" ../waku.nimble;
|
||||
revision = lib.substring 0 8 (src.rev or src.dirtyRev or "00000000");
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "logos-messaging-nim";
|
||||
|
||||
version = "1.0.0-${revision}";
|
||||
version = "${version}-${revision}";
|
||||
|
||||
inherit src;
|
||||
|
||||
# Runtime dependencies
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
gmp
|
||||
zip
|
||||
openssl gmp zip
|
||||
];
|
||||
|
||||
# Dependencies that should only exist in the build environment.
|
||||
nativeBuildInputs = let
|
||||
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
|
||||
fakeGit = writeScriptBin "git" "echo ${version}";
|
||||
# Fix for the zerokit package that is built with cargo/rustup/cross.
|
||||
fakeCargo = writeScriptBin "cargo" "echo ${version}";
|
||||
# Fix for the zerokit package that is built with cargo/rustup/cross.
|
||||
fakeRustup = writeScriptBin "rustup" "echo ${version}";
|
||||
# Fix for the zerokit package that is built with cargo/rustup/cross.
|
||||
fakeCross = writeScriptBin "cross" "echo ${version}";
|
||||
in
|
||||
with pkgs; [
|
||||
cmake
|
||||
which
|
||||
lsb-release
|
||||
zerokitRln
|
||||
nim-unwrapped-2_0
|
||||
fakeGit
|
||||
fakeCargo
|
||||
fakeRustup
|
||||
fakeCross
|
||||
in with pkgs; [
|
||||
cmake which zerokitRln nim-unwrapped-2_2 fakeGit
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
pkgs.darwin.cctools gcc # Necessary for libbacktrace
|
||||
];
|
||||
|
||||
# Environment variables required for Android builds
|
||||
@ -63,14 +50,13 @@ in stdenv.mkDerivation rec {
|
||||
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
|
||||
|
||||
makeFlags = targets ++ [
|
||||
"V=${toString verbosity}"
|
||||
"QUICK_AND_DIRTY_COMPILER=${if quickAndDirty then "1" else "0"}"
|
||||
"QUICK_AND_DIRTY_NIMBLE=${if quickAndDirty then "1" else "0"}"
|
||||
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
|
||||
"LIBRLN_FILE=${zerokitRln}/target/release/librln.a"
|
||||
"LIBRLN_FILE=${zerokitRln}/lib/librln.${if abidir != null then "so" else "a"}"
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
@ -80,12 +66,8 @@ in stdenv.mkDerivation rec {
|
||||
'';
|
||||
|
||||
# For the Nim v2.2.4 built with NBS we added sat and zippy
|
||||
preBuild = ''
|
||||
ln -s waku.nimble waku.nims
|
||||
|
||||
${lib.optionalString (!useSystemNim) ''
|
||||
preBuild = lib.optionalString (!useSystemNim) ''
|
||||
pushd vendor/nimbus-build-system/vendor/Nim
|
||||
|
||||
mkdir dist
|
||||
mkdir -p dist/nimble/vendor/sat
|
||||
mkdir -p dist/nimble/vendor/checksums
|
||||
@ -98,9 +80,7 @@ in stdenv.mkDerivation rec {
|
||||
cp -r ${callPackage ./checksums.nix {}}/. dist/nimble/vendor/checksums
|
||||
cp -r ${callPackage ./zippy.nix {}}/. dist/nimble/vendor/zippy
|
||||
chmod 777 -R dist/nimble csources_v2
|
||||
|
||||
popd
|
||||
''}
|
||||
'';
|
||||
|
||||
installPhase = if abidir != null then ''
|
||||
@ -110,10 +90,10 @@ in stdenv.mkDerivation rec {
|
||||
cd $out && zip -r libwaku.aar *
|
||||
'' else ''
|
||||
mkdir -p $out/bin $out/include
|
||||
|
||||
|
||||
# Copy library files
|
||||
cp build/* $out/bin/ 2>/dev/null || true
|
||||
|
||||
|
||||
# Copy the header file
|
||||
cp library/libwaku.h $out/include/
|
||||
'';
|
||||
|
||||
@ -5,19 +5,16 @@
|
||||
|
||||
{ androidenv, lib, stdenv }:
|
||||
|
||||
assert lib.assertMsg (stdenv.system != "aarch64-darwin")
|
||||
"aarch64-darwin not supported for Android SDK. Use: NIXPKGS_SYSTEM_OVERRIDE=x86_64-darwin";
|
||||
|
||||
# The "android-sdk-license" license is accepted
|
||||
# by setting android_sdk.accept_license = true.
|
||||
androidenv.composeAndroidPackages {
|
||||
cmdLineToolsVersion = "9.0";
|
||||
toolsVersion = "26.1.1";
|
||||
platformToolsVersion = "33.0.3";
|
||||
platformToolsVersion = "34.0.5";
|
||||
buildToolsVersions = [ "34.0.0" ];
|
||||
platformVersions = [ "34" ];
|
||||
cmakeVersions = [ "3.22.1" ];
|
||||
ndkVersion = "25.2.9519653";
|
||||
ndkVersion = "27.2.12479018";
|
||||
includeNDK = true;
|
||||
includeExtras = [
|
||||
"extras;android;m2repository"
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
let
|
||||
optionalDarwinDeps = pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.libiconv
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
in
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.mkShell {
|
||||
inputsFrom = [
|
||||
pkgs.androidShell
|
||||
] ++ optionalDarwinDeps;
|
||||
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.libiconv
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
git
|
||||
@ -18,7 +14,6 @@ pkgs.mkShell {
|
||||
rustup
|
||||
rustc
|
||||
cmake
|
||||
nim-unwrapped-2_0
|
||||
nim-unwrapped-2_2
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@ -25,4 +25,3 @@ cargo clean
|
||||
cross rustc --release --lib --target=${android_arch} --crate-type=cdylib
|
||||
cp ../target/${android_arch}/release/librln.so ${output_dir}/.
|
||||
popd
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user