2019-05-02 18:13:16 +00:00
|
|
|
|
2019-05-17 08:55:24 +00:00
|
|
|
{ stdenv, utils, callPackage,
|
|
|
|
buildGoPackage, go, gomobile, openjdk, xcodeWrapper }:
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
{ owner, repo, rev, version, goPackagePath, src, host,
|
2019-05-06 14:52:02 +00:00
|
|
|
|
|
|
|
# mobile-only arguments
|
2019-05-02 18:13:16 +00:00
|
|
|
goBuildFlags, goBuildLdFlags,
|
|
|
|
config } @ args':
|
|
|
|
|
|
|
|
let
|
2019-06-04 16:50:29 +00:00
|
|
|
inherit (stdenv.lib) concatStringsSep makeBinPath optional;
|
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
targetConfig = config;
|
2019-05-17 08:55:24 +00:00
|
|
|
buildStatusGo = callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-05-06 14:52:02 +00:00
|
|
|
args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ]; # Remove mobile-only arguments from args
|
2019-05-02 18:13:16 +00:00
|
|
|
buildStatusGoMobileLib = buildStatusGo (args // {
|
2019-06-04 16:50:29 +00:00
|
|
|
nativeBuildInputs = [ gomobile ] ++ optional (targetConfig.name == "android") openjdk;
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-05-06 14:52:02 +00:00
|
|
|
buildMessage = "Building mobile library for ${targetConfig.name}";
|
|
|
|
# Build mobile libraries
|
2019-07-18 11:52:17 +00:00
|
|
|
buildPhase =
|
|
|
|
let
|
|
|
|
NIX_GOWORKDIR = "$NIX_BUILD_TOP/go-build";
|
|
|
|
in ''
|
|
|
|
mkdir ${NIX_GOWORKDIR}
|
2019-05-14 17:29:36 +00:00
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
GOPATH=${gomobile.dev}:$GOPATH \
|
2019-06-04 16:50:29 +00:00
|
|
|
PATH=${makeBinPath [ gomobile.bin ]}:$PATH \
|
2019-07-18 11:52:17 +00:00
|
|
|
NIX_GOWORKDIR=${NIX_GOWORKDIR} \
|
2019-06-04 16:50:29 +00:00
|
|
|
${concatStringsSep " " targetConfig.envVars} \
|
|
|
|
gomobile bind ${goBuildFlags} -target=${targetConfig.name} ${concatStringsSep " " targetConfig.gomobileExtraFlags} \
|
2019-05-02 18:13:16 +00:00
|
|
|
-o ${targetConfig.outputFileName} \
|
|
|
|
${goBuildLdFlags} \
|
|
|
|
${goPackagePath}/mobile
|
2019-05-14 17:29:36 +00:00
|
|
|
|
2019-07-18 11:52:17 +00:00
|
|
|
rm -rf ${NIX_GOWORKDIR}
|
2019-05-02 18:13:16 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
mv ${targetConfig.outputFileName} $out/lib/
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
meta = {
|
2019-06-04 16:50:29 +00:00
|
|
|
platforms = with stdenv.lib.platforms; linux ++ darwin;
|
2019-05-02 18:13:16 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2019-07-29 08:33:35 +00:00
|
|
|
in buildStatusGoMobileLib
|