2019-05-17 08:55:24 +00:00
|
|
|
{ target-os, stdenv, callPackage,
|
|
|
|
buildGoPackage, go, fetchFromGitHub, openjdk,
|
|
|
|
androidPkgs, composeXcodeWrapper, xcodewrapperArgs ? {} }:
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
with stdenv;
|
|
|
|
|
|
|
|
let
|
2019-05-17 08:55:24 +00:00
|
|
|
platform = callPackage ../platform.nix { inherit target-os; };
|
|
|
|
utils = callPackage ../utils.nix { inherit xcodeWrapper; };
|
2019-07-04 14:31:34 +00:00
|
|
|
gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit target-os composeXcodeWrapper xcodewrapperArgs 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-05-02 18:13:16 +00:00
|
|
|
extractStatusGoConfig = f: lib.last (lib.splitString "\n" (lib.fileContents f));
|
2019-04-09 20:04:45 +00:00
|
|
|
owner = lib.fileContents ../../STATUS_GO_OWNER;
|
2019-05-02 11:29:10 +00:00
|
|
|
version = extractStatusGoConfig ../../STATUS_GO_VERSION; # TODO: Simplify this path search with lib.locateDominatingFile
|
|
|
|
sha256 = extractStatusGoConfig ../../STATUS_GO_SHA256;
|
2019-04-09 20:04:45 +00:00
|
|
|
repo = "status-go";
|
|
|
|
rev = version;
|
2019-05-02 11:29:10 +00:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
2019-05-08 11:48:18 +00:00
|
|
|
src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-source"; };
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-04-09 20:04:45 +00:00
|
|
|
mobileConfigs = {
|
|
|
|
android = {
|
|
|
|
name = "android";
|
|
|
|
outputFileName = "status-go-${version}.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"
|
|
|
|
"PATH=${lib.makeBinPath [ openjdk ]}:$PATH"
|
|
|
|
];
|
|
|
|
gomobileExtraFlags = [];
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
currentHostConfig = if 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";
|
|
|
|
goBuildLdFlags = "-ldflags=-s";
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
|
2019-04-12 07:38:08 +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";
|
|
|
|
hostSystem = hostPlatform.system;
|
|
|
|
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-05-13 09:22:29 +00:00
|
|
|
buildInputs = if target-os == "android" then [ status-go-packages.android ] else
|
|
|
|
if target-os == "ios" then [ status-go-packages.ios ] else
|
|
|
|
if target-os == "all" then currentHostConfig.allTargets else
|
|
|
|
if platform.targetDesktop then [ status-go-packages.desktop ] else
|
|
|
|
throw "Unexpected target platform ${target-os}";
|
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-05-02 18:13:16 +00:00
|
|
|
|
2019-04-12 07:38:08 +00:00
|
|
|
shellHook =
|
2019-05-02 18:13:16 +00:00
|
|
|
lib.optionalString platform.targetIOS ''
|
|
|
|
# These variables are used by the iOS build preparation section in scripts/prepare-for-platform.sh
|
|
|
|
export RCTSTATUS_FILEPATH=${status-go-packages.ios}/lib/Statusgo.framework
|
|
|
|
'' +
|
|
|
|
lib.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
|
|
|
|
'' +
|
|
|
|
lib.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
|
2019-04-12 07:38:08 +00:00
|
|
|
'';
|
2019-03-25 16:35:01 +00:00
|
|
|
}
|