first working version using both methods

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-06-10 15:27:04 +02:00
parent 6dff469edc
commit 44ba85f436
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
3 changed files with 80 additions and 21 deletions

View File

@ -1,5 +1,7 @@
#{ pkgs ? import <nixpkgs> {
{ pkgs ? import ../../nixpkgs {
config.android_sdk.accept_license = true;
} }:
pkgs.callPackage ./mobile.nix { }
#pkgs.callPackage ./mobile_pkg.nix { }
pkgs.callPackage ./mobile_mod.nix { }

60
nix/mobile_mod.nix Normal file
View File

@ -0,0 +1,60 @@
{ lib, pkgs, callPackage, buildGoModule }:
let
androidPkgs = pkgs.androidenv.composeAndroidPackages {
platformVersions = [ "23" ];
ndkVersion = "22.1.7171670";
includeNDK = true;
};
androidSdk = androidPkgs.androidsdk;
#gomobile = pkgs.gomobile.override { inherit androidPkgs; };
in buildGoModule {
pname = "go-waku";
version = "devel";
vendorSha256 = "sha256-+U8mlEK7HvCtssI8VDqxGaOvi+IU0+cr4isZLl9sB4o=";
deleteVendor = true;
doCheck = false;
src = ./..;
nativeBuildInputs = [ pkgs.gomobile pkgs.openjdk8 ];
# We can't symlink gomobile src in vendor created by buildGoModule.
proxyVendor = true;
ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
# Correct GOPATH necessary to avoid error:
# `no exported names in the package "_/build/go-waku/mobile"`
preBuild = ''
export GO111MODULE=off
mkdir -p /build/go/src/github.com/status-im
mv /build/go-waku /build/go/src/github.com/status-im/
cd /build/go/src/github.com/status-im/go-waku
'';
buildPhase = ''
runHook preBuild
gomobile bind -x \
-target=android/arm64 \
-androidapi=23 \
-ldflags="-s -w" \
-o go-waku.aar \
./mobile
'';
installPhase = ''
mkdir -p $out
mv go-waku.aar $out/
'';
#buildPhase = ''
# echo $ANDROID_HOME
# gomobile bind -x \
# -target=ios \
# -iosversion=8.0 \
# -ldflags="-s -w" \
# -o ./build/lib/go-waku.xcframework \
# ./mobile
#'';
}

View File

@ -1,44 +1,41 @@
{ lib, pkgs, callPackage, buildGoModule }:
{ lib, pkgs, callPackage, buildGoModule, buildGoPackage }:
let
androidPkgs = pkgs.androidenv.composeAndroidPackages {
includeNDK = true;
toolsVersion = "26.1.1";
platformToolsVersion = "33.0.1";
buildToolsVersions = [ "31.0.0" ];
platformVersions = [ "30" ];
cmakeVersions = [ "3.18.1" ];
ndkVersion = "22.1.7171670";
includeNDK = true;
};
androidSdk = androidPkgs.androidsdk;
gomobile = pkgs.gomobile.override { inherit androidPkgs; };
in buildGoModule {
in buildGoPackage rec {
pname = "go-waku";
version = "devel";
vendorSha256 = "sha256-+W5PnVmD4oPh3a8Ik9Xn3inCI8shqEsdlkG/d6PQntk=";
GIT_COMMIT = "TODO";
doCheck = false;
goPackagePath = "github.com/status-im/go-waku";
src = ./..;
extraSrcPaths = [ gomobile ];
nativeBuildInputs = [ gomobile pkgs.openjdk8 ];
# We can't symlink gomobile src in vendor created by buildGoModule.
proxyVendor = true;
ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
GO111MODULE = "off";
GOMOBILE = gomobile;
shellHook = ''
env | grep -E '^(ANDROID|GO)'
'';
buildPhase = ''
runHook shellHook
unset GOARCH
gomobile bind -x \
-target=android/arm64 \
-androidapi=23 \
-ldflags="-s -w" \
-o ./build/lib/gowaku.aar \
./mobile
-o go-waku.aar \
${goPackagePath}/mobile
'';
installPhase = ''
mkdir -p $out
mv go-waku.aar $out/
'';
#buildPhase = ''
@ -47,7 +44,7 @@ in buildGoModule {
# -target=ios \
# -iosversion=8.0 \
# -ldflags="-s -w" \
# -o ./build/lib/Gowaku.xcframework \
# -o ./build/lib/go-waku.xcframework \
# ./mobile
#'';
}