2019-07-04 14:31:34 +00:00
|
|
|
{ stdenv, target-os, callPackage, utils, fetchgit,
|
2019-05-17 08:55:24 +00:00
|
|
|
buildGoPackage, glibc, ncurses5, zlib, makeWrapper, patchelf,
|
2019-06-04 16:50:29 +00:00
|
|
|
platform-tools, xcodeWrapper
|
2019-03-25 16:35:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-06-04 16:50:29 +00:00
|
|
|
inherit (stdenv) isDarwin;
|
|
|
|
inherit (stdenv.lib) optional optionalString strings;
|
|
|
|
|
2019-07-04 14:31:34 +00:00
|
|
|
platform = callPackage ../../platform.nix { inherit target-os; };
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
in buildGoPackage rec {
|
|
|
|
name = "gomobile-${version}";
|
2019-06-04 16:50:29 +00:00
|
|
|
version = "20190319-${strings.substring 0 7 rev}";
|
2019-03-25 16:35:01 +00:00
|
|
|
rev = "167ebed0ec6dd457a6b24a4f61db913f0af11f70";
|
|
|
|
sha256 = "0lspdhikhnhbwv8v0q6fs3a0pd9sjnhkpg8z03m2dc5h6f84m38w";
|
|
|
|
|
|
|
|
goPackagePath = "golang.org/x/mobile";
|
|
|
|
subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
|
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ]
|
2019-06-04 16:50:29 +00:00
|
|
|
++ optional isDarwin xcodeWrapper;
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2019-05-09 16:16:15 +00:00
|
|
|
# Ensure XCode and the iPhone SDK are present, instead of failing at the end of the build
|
2019-06-04 16:50:29 +00:00
|
|
|
preConfigure = optionalString isDarwin utils.enforceiPhoneSDKAvailable;
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
patches = [ ./ndk-search-path.patch ./resolve-nix-android-sdk.patch ]
|
2019-06-04 16:50:29 +00:00
|
|
|
++ optional isDarwin ./ignore-nullability-error-on-ios.patch;
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2019-07-18 11:52:17 +00:00
|
|
|
postPatch = ''
|
|
|
|
${optionalString platform.targetAndroid ''substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`"''}
|
|
|
|
|
2019-05-14 17:29:36 +00:00
|
|
|
# Prevent a non-deterministic temporary directory from polluting the resulting object files
|
|
|
|
substituteInPlace cmd/gomobile/env.go --replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
|
2019-07-18 11:52:17 +00:00
|
|
|
"tmpdir = \"$NIX_BUILD_TOP/gomobile-work\"" \
|
2019-05-14 17:29:36 +00:00
|
|
|
--replace '"io/ioutil"' ""
|
2019-07-18 11:52:17 +00:00
|
|
|
substituteInPlace cmd/gomobile/init.go --replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
|
|
|
|
"tmpdir = \"$NIX_BUILD_TOP/work\""
|
2019-05-14 17:29:36 +00:00
|
|
|
|
2019-03-25 16:35:01 +00:00
|
|
|
echo "Creating $dev"
|
|
|
|
mkdir -p $dev/src/$goPackagePath
|
|
|
|
echo "Copying from $src"
|
|
|
|
cp -a $src/. $dev/src/$goPackagePath
|
|
|
|
'';
|
|
|
|
|
2019-05-14 17:29:36 +00:00
|
|
|
preBuild = ''
|
2019-07-18 11:52:17 +00:00
|
|
|
mkdir $NIX_BUILD_TOP/gomobile-work $NIX_BUILD_TOP/work
|
2019-05-14 17:29:36 +00:00
|
|
|
'';
|
|
|
|
|
2019-06-04 16:50:29 +00:00
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
inherit (stdenv.lib) makeBinPath makeLibraryPath;
|
|
|
|
in ''
|
2019-03-25 16:35:01 +00:00
|
|
|
mkdir -p $out $bin/lib
|
|
|
|
|
|
|
|
ln -s ${ncurses5}/lib/libncursesw.so.5 $bin/lib/libtinfo.so.5
|
2019-07-18 11:52:17 +00:00
|
|
|
${if isDarwin then ''
|
2019-03-25 16:35:01 +00:00
|
|
|
wrapProgram $bin/bin/gomobile \
|
2019-06-04 16:50:29 +00:00
|
|
|
--prefix "PATH" : "${makeBinPath [ xcodeWrapper ]}" \
|
|
|
|
--prefix "LD_LIBRARY_PATH" : "${makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
|
2019-04-03 11:06:42 +00:00
|
|
|
'' else ''
|
2019-03-25 16:35:01 +00:00
|
|
|
wrapProgram $bin/bin/gomobile \
|
2019-06-04 16:50:29 +00:00
|
|
|
--prefix "LD_LIBRARY_PATH" : "${makeLibraryPath [ ncurses5 zlib ]}:$bin/lib"
|
2019-07-18 11:52:17 +00:00
|
|
|
''}
|
2019-03-25 16:35:01 +00:00
|
|
|
$bin/bin/gomobile init
|
|
|
|
'';
|
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
inherit rev sha256;
|
|
|
|
url = "https://go.googlesource.com/mobile";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "bin" "dev" "out" ];
|
|
|
|
|
2019-06-04 16:50:29 +00:00
|
|
|
meta = with stdenv.lib; {
|
2019-03-25 16:35:01 +00:00
|
|
|
description = "A tool for building and running mobile apps written in Go.";
|
|
|
|
longDescription = "Gomobile is a tool for building and running mobile apps written in Go.";
|
|
|
|
homepage = https://go.googlesource.com/mobile;
|
2019-06-04 16:50:29 +00:00
|
|
|
license = licenses.bsdOriginal;
|
|
|
|
maintainers = with maintainers; [ sheenobu pombeirp ];
|
|
|
|
platforms = with platforms; linux ++ darwin;
|
2019-03-25 16:35:01 +00:00
|
|
|
};
|
|
|
|
}
|