2019-05-17 08:55:24 +00:00
|
|
|
{ target-os, stdenv, callPackage,
|
|
|
|
buildGoPackage, go, fetchFromGitHub, openjdk,
|
2019-06-04 16:50:29 +00:00
|
|
|
androidPkgs, xcodeWrapper }:
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
let
|
2019-10-22 11:56:13 +00:00
|
|
|
inherit (stdenv.lib)
|
|
|
|
catAttrs concatStrings fileContents importJSON makeBinPath
|
|
|
|
optional optionalString removePrefix strings attrValues mapAttrs;
|
|
|
|
|
2019-05-17 08:55:24 +00:00
|
|
|
platform = callPackage ../platform.nix { inherit target-os; };
|
|
|
|
utils = callPackage ../utils.nix { inherit xcodeWrapper; };
|
2019-06-04 16:50:29 +00:00
|
|
|
gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit target-os xcodeWrapper utils buildGoPackage; };
|
2019-05-17 08:55:24 +00:00
|
|
|
buildStatusGoDesktopLib = callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
|
|
|
|
buildStatusGoMobileLib = callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile xcodeWrapper utils; };
|
2019-07-19 18:42:16 +00:00
|
|
|
extractStatusGoConfig = callPackage ./extract-status-go-config.nix { inherit (stdenv) lib; };
|
|
|
|
versionJSON = importJSON ../../status-go-version.json; # TODO: Simplify this path search with lib.locateDominatingFile
|
|
|
|
owner = versionJSON.owner;
|
2019-07-22 03:31:47 +00:00
|
|
|
repo = versionJSON.repo;
|
2019-07-19 18:42:16 +00:00
|
|
|
version = versionJSON.version;
|
|
|
|
sha256 = versionJSON.src-sha256;
|
|
|
|
rev = versionJSON.commit-sha1;
|
2019-07-29 18:23:32 +00:00
|
|
|
shortRev = strings.substring 0 7 rev;
|
2019-05-02 11:29:10 +00:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
2019-07-29 18:23:32 +00:00
|
|
|
src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-${shortRev}-source"; };
|
2019-08-01 10:49:46 +00:00
|
|
|
# Replace src value with the path to a local status-go repository if you want to perform a build against it, e.g.
|
|
|
|
#src = /home/<user>/go/src/github.com/status-im/status-go;
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-04-09 20:04:45 +00:00
|
|
|
mobileConfigs = {
|
|
|
|
android = {
|
|
|
|
name = "android";
|
2019-07-29 18:23:32 +00:00
|
|
|
outputFileName = "status-go-${shortRev}.aar";
|
2019-05-02 18:13:16 +00:00
|
|
|
envVars = [
|
|
|
|
"ANDROID_HOME=${androidPkgs.androidsdk}/libexec/android-sdk"
|
|
|
|
"ANDROID_NDK_HOME=${androidPkgs.ndk-bundle}/libexec/android-sdk/ndk-bundle"
|
2019-06-04 16:50:29 +00:00
|
|
|
"PATH=${makeBinPath [ openjdk ]}:$PATH"
|
2019-05-02 18:13:16 +00:00
|
|
|
];
|
2019-08-07 10:08:36 +00:00
|
|
|
gomobileExtraFlags = [ "-androidapi 18" ];
|
2019-04-09 20:04:45 +00:00
|
|
|
};
|
|
|
|
ios = {
|
|
|
|
name = "ios";
|
|
|
|
outputFileName = "Statusgo.framework";
|
2019-05-02 18:13:16 +00:00
|
|
|
envVars = [];
|
|
|
|
gomobileExtraFlags = [ "-iosversion=8.0" ];
|
2019-04-09 20:04:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
hostConfigs = {
|
|
|
|
darwin = {
|
2019-05-02 18:13:16 +00:00
|
|
|
name = "macos";
|
|
|
|
allTargets = [ status-go-packages.desktop status-go-packages.ios status-go-packages.android ];
|
2019-04-09 20:04:45 +00:00
|
|
|
};
|
|
|
|
linux = {
|
2019-05-02 18:13:16 +00:00
|
|
|
name = "linux";
|
|
|
|
allTargets = [ status-go-packages.desktop status-go-packages.android ];
|
2019-04-09 20:04:45 +00:00
|
|
|
};
|
|
|
|
};
|
2019-06-04 16:50:29 +00:00
|
|
|
currentHostConfig = if stdenv.isDarwin then hostConfigs.darwin else hostConfigs.linux;
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-04-09 20:04:45 +00:00
|
|
|
goBuildFlags = "-v";
|
2019-10-22 11:56:13 +00:00
|
|
|
# status-go params to be set at build time, important for About section and metrics
|
|
|
|
goBuildParams = {
|
|
|
|
Version = removePrefix "v" version; # Geth forces a 'v' prefix
|
|
|
|
GitCommit = rev;
|
|
|
|
};
|
|
|
|
# These are necessary for status-go to show correct version
|
|
|
|
paramsLdFlags = attrValues (mapAttrs (name: value:
|
|
|
|
"-X github.com/status-im/status-go/params.${name}=${value}"
|
|
|
|
) goBuildParams);
|
|
|
|
|
|
|
|
goBuildLdFlags = paramsLdFlags ++ [
|
|
|
|
"-s" # -s disabled symbol table
|
|
|
|
"-w" # -w disables DWARF debugging information
|
|
|
|
];
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
statusGoArgs = { inherit owner repo rev version goPackagePath src goBuildFlags goBuildLdFlags; };
|
|
|
|
status-go-packages = {
|
|
|
|
desktop = buildStatusGoDesktopLib (statusGoArgs // {
|
|
|
|
outputFileName = "libstatus.a";
|
2019-06-04 16:50:29 +00:00
|
|
|
hostSystem = stdenv.hostPlatform.system;
|
2019-05-02 18:13:16 +00:00
|
|
|
host = currentHostConfig.name;
|
|
|
|
});
|
|
|
|
|
|
|
|
android = buildStatusGoMobileLib (statusGoArgs // {
|
|
|
|
host = mobileConfigs.android.name;
|
|
|
|
config = mobileConfigs.android;
|
|
|
|
});
|
|
|
|
|
|
|
|
ios = buildStatusGoMobileLib (statusGoArgs // {
|
|
|
|
host = mobileConfigs.ios.name;
|
|
|
|
config = mobileConfigs.ios;
|
|
|
|
});
|
2019-03-25 16:35:01 +00:00
|
|
|
};
|
2019-04-12 07:38:08 +00:00
|
|
|
|
2019-07-29 08:33:35 +00:00
|
|
|
buildInputs = if target-os == "android" then
|
|
|
|
android.buildInputs
|
|
|
|
else if target-os == "ios" then
|
|
|
|
ios.buildInputs
|
|
|
|
else if target-os == "all" then
|
|
|
|
currentHostConfig.allTargets
|
|
|
|
else if platform.targetDesktop then
|
|
|
|
desktop.buildInputs
|
|
|
|
else
|
|
|
|
throw "Unexpected target platform ${target-os}";
|
2019-06-04 16:50:29 +00:00
|
|
|
android = {
|
|
|
|
buildInputs = optional platform.targetAndroid [ status-go-packages.android ];
|
|
|
|
shellHook =
|
|
|
|
optionalString platform.targetAndroid ''
|
|
|
|
# These variables are used by the Status Android Gradle build script in android/build.gradle
|
|
|
|
export STATUS_GO_ANDROID_LIBDIR=${status-go-packages.android}/lib
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
ios = {
|
|
|
|
buildInputs = optional platform.targetIOS [ status-go-packages.ios ];
|
|
|
|
shellHook =
|
|
|
|
optionalString platform.targetIOS ''
|
|
|
|
# These variables are used by the iOS build preparation section in nix/mobile/ios/default.nix
|
|
|
|
export RCTSTATUS_FILEPATH=${status-go-packages.ios}/lib/Statusgo.framework
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
desktop = {
|
|
|
|
buildInputs = optional platform.targetDesktop [ status-go-packages.desktop ];
|
|
|
|
shellHook =
|
|
|
|
optionalString platform.targetDesktop ''
|
|
|
|
# These variables are used by the Status Desktop CMake build script in modules/react-native-status/desktop/CMakeLists.txt
|
|
|
|
export STATUS_GO_DESKTOP_INCLUDEDIR=${status-go-packages.desktop}/include
|
|
|
|
export STATUS_GO_DESKTOP_LIBDIR=${status-go-packages.desktop}/lib
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
platforms = [ android ios desktop ];
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-04-12 07:38:08 +00:00
|
|
|
in {
|
2019-05-13 09:22:29 +00:00
|
|
|
inherit buildInputs;
|
2019-06-04 16:50:29 +00:00
|
|
|
shellHook = concatStrings (catAttrs "shellHook" platforms);
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-06-04 16:50:29 +00:00
|
|
|
# CHILD DERIVATIONS
|
|
|
|
inherit android ios desktop;
|
2019-03-25 16:35:01 +00:00
|
|
|
}
|