2021-04-12 14:07:55 +00:00
|
|
|
{ stdenv, lib, utils, callPackage, fetchgit, buildGo114Package,
|
2020-04-22 17:05:18 +00:00
|
|
|
ncurses5, zlib, makeWrapper, patchelf, androidPkgs, xcodeWrapper
|
2019-03-25 16:35:01 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-06-04 16:50:29 +00:00
|
|
|
inherit (stdenv) isDarwin;
|
2021-04-12 14:07:55 +00:00
|
|
|
inherit (lib) optional optionalString strings;
|
2020-08-27 14:21:48 +00:00
|
|
|
in buildGo114Package rec {
|
2019-07-19 18:40:03 +00:00
|
|
|
pname = "gomobile";
|
2020-08-27 14:21:48 +00:00
|
|
|
version = "20200622-${strings.substring 0 7 rev}";
|
|
|
|
# WARNING: Next commit removes support for ARM 32 bit builds for iOS
|
|
|
|
rev = "33b80540585f2b31e503da24d6b2a02de3c53ff5";
|
|
|
|
sha256 = "0c9map2vrv34wmaycsv71k4day3b0z5p16yzxmlp8amvqb38zwlm";
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
goPackagePath = "golang.org/x/mobile";
|
|
|
|
subPackages = [ "bind" "cmd/gobind" "cmd/gomobile" ];
|
2020-04-15 11:12:56 +00:00
|
|
|
goDeps = ./deps.nix;
|
2019-03-25 16:35:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-08-01 17:28:08 +00:00
|
|
|
patches = [ ./resolve-nix-android-sdk.patch ];
|
2019-03-25 16:35:01 +00:00
|
|
|
|
2019-07-18 11:52:17 +00:00
|
|
|
postPatch = ''
|
2020-04-22 17:05:18 +00:00
|
|
|
substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${androidPkgs}/bin/adb\`"
|
2019-07-18 11:52:17 +00:00
|
|
|
|
2019-05-14 17:29:36 +00:00
|
|
|
# Prevent a non-deterministic temporary directory from polluting the resulting object files
|
2019-07-29 11:42:34 +00:00
|
|
|
substituteInPlace cmd/gomobile/env.go \
|
|
|
|
--replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir("", "gomobile-work-")' \
|
|
|
|
"tmpdir = filepath.Join(os.Getenv(\"NIX_BUILD_TOP\"), \"gomobile-work\")" \
|
2019-05-14 17:29:36 +00:00
|
|
|
--replace '"io/ioutil"' ""
|
2019-07-29 11:42:34 +00:00
|
|
|
substituteInPlace cmd/gomobile/init.go \
|
|
|
|
--replace \
|
|
|
|
'tmpdir, err = ioutil.TempDir(gomobilepath, "work-")' \
|
|
|
|
"tmpdir = filepath.Join(os.Getenv(\"NIX_BUILD_TOP\"), \"work\")"
|
2019-03-25 16:35:01 +00:00
|
|
|
'';
|
|
|
|
|
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
|
|
|
'';
|
|
|
|
|
2020-08-05 14:06:56 +00:00
|
|
|
# Necessary for GOPATH when using gomobile.
|
|
|
|
postInstall = ''
|
|
|
|
echo "Creating $out"
|
|
|
|
mkdir -p $out/src/$goPackagePath
|
|
|
|
echo "Copying from $src"
|
|
|
|
cp -a $src/. $out/src/$goPackagePath
|
2019-03-25 16:35:01 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
inherit rev sha256;
|
2020-04-15 11:12:56 +00:00
|
|
|
name = "gomobile";
|
2019-03-25 16:35:01 +00:00
|
|
|
url = "https://go.googlesource.com/mobile";
|
|
|
|
};
|
|
|
|
|
2021-04-12 14:07:55 +00:00
|
|
|
meta = with 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
|
|
|
};
|
|
|
|
}
|