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':
|
|
|
|
|
|
|
|
with stdenv;
|
|
|
|
|
|
|
|
let
|
|
|
|
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 // {
|
|
|
|
nativeBuildInputs = [ gomobile ] ++ lib.optional (targetConfig.name == "android") openjdk;
|
|
|
|
|
2019-05-06 14:52:02 +00:00
|
|
|
buildMessage = "Building mobile library for ${targetConfig.name}";
|
|
|
|
# Build mobile libraries
|
|
|
|
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
2019-05-02 18:13:16 +00:00
|
|
|
buildPhase = ''
|
|
|
|
GOPATH=${gomobile.dev}:$GOPATH \
|
|
|
|
PATH=${lib.makeBinPath [ gomobile.bin ]}:$PATH \
|
|
|
|
${lib.concatStringsSep " " targetConfig.envVars} \
|
|
|
|
gomobile bind ${goBuildFlags} -target=${targetConfig.name} ${lib.concatStringsSep " " targetConfig.gomobileExtraFlags} \
|
|
|
|
-o ${targetConfig.outputFileName} \
|
|
|
|
${goBuildLdFlags} \
|
|
|
|
${goPackagePath}/mobile
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
mv ${targetConfig.outputFileName} $out/lib/
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = with lib.platforms; linux ++ darwin;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in buildStatusGoMobileLib
|