Only bring in Android dependencies in gomobile if targetting Android

This commit is contained in:
Pedro Pombeiro 2019-07-04 16:31:34 +02:00
parent 9b7b5b9608
commit 8d8ef4d263
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
9 changed files with 22 additions and 59 deletions

View File

@ -1,5 +1,4 @@
android-sdk-build-tools;28.0.1; android-sdk-build-tools;28.0.1;
android-sdk-platform;android-27;
android-sdk;4333796;aa190cfd7299cd6a1c687355bb2764e4 android-sdk;4333796;aa190cfd7299cd6a1c687355bb2764e4
nix;2.2.1; nix;2.2.1;
node;10.15.0; node;10.15.0;

View File

@ -1,4 +1,4 @@
# This file has been generated by node2nix 1.6.1. Do not edit! # This file has been generated by node2nix 1.7.0. Do not edit!
{pkgs ? import <nixpkgs> { {pkgs ? import <nixpkgs> {
inherit system; inherit system;

View File

@ -11,7 +11,7 @@ let
cat > $out/bin/tar <<EOF cat > $out/bin/tar <<EOF
#! ${stdenv.shell} -e #! ${stdenv.shell} -e
$(type -p tar) "\$@" --warning=no-unknown-keyword $(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
EOF EOF
chmod +x $out/bin/tar chmod +x $out/bin/tar
@ -219,7 +219,16 @@ let
packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads. packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
} }
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories. if(dependency.resolved) {
packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
} else {
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
}
if(dependency.from !== undefined) { // Adopt from property if one has been provided
packageObj["_from"] = dependency.from;
}
fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2)); fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
} }
@ -385,7 +394,7 @@ let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ]; extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = "node-${name}-${version}"; name = "node_${name}-${version}";
buildInputs = [ tarWrapper python nodejs ] buildInputs = [ tarWrapper python nodejs ]
++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ stdenv.lib.optional (stdenv.isLinux) utillinux
++ stdenv.lib.optional (stdenv.isDarwin) libtool ++ stdenv.lib.optional (stdenv.isDarwin) libtool

View File

@ -1,4 +1,4 @@
# This file has been generated by node2nix 1.6.1. Do not edit! # This file has been generated by node2nix 1.7.0. Do not edit!
{nodeEnv, fetchurl, fetchgit, globalBuildInputs ? []}: {nodeEnv, fetchurl, fetchgit, globalBuildInputs ? []}:

View File

@ -1,4 +1,4 @@
# This file has been generated by node2nix 1.6.1. Do not edit! # This file has been generated by node2nix 1.7.0. Do not edit!
{nodeEnv, fetchurl, fetchgit, globalBuildInputs ? []}: {nodeEnv, fetchurl, fetchgit, globalBuildInputs ? []}:

View File

@ -7,7 +7,7 @@ with stdenv;
let let
platform = callPackage ../platform.nix { inherit target-os; }; platform = callPackage ../platform.nix { inherit target-os; };
utils = callPackage ../utils.nix { inherit xcodeWrapper; }; utils = callPackage ../utils.nix { inherit xcodeWrapper; };
gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit composeXcodeWrapper xcodewrapperArgs utils buildGoPackage; }; gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit target-os composeXcodeWrapper xcodewrapperArgs utils buildGoPackage; };
buildStatusGoDesktopLib = callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; }; 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; }; buildStatusGoMobileLib = callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile xcodeWrapper utils; };
extractStatusGoConfig = f: lib.last (lib.splitString "\n" (lib.fileContents f)); extractStatusGoConfig = f: lib.last (lib.splitString "\n" (lib.fileContents f));

View File

@ -1,4 +1,4 @@
{ stdenv, utils, fetchgit, { stdenv, target-os, callPackage, utils, fetchgit,
buildGoPackage, glibc, ncurses5, zlib, makeWrapper, patchelf, buildGoPackage, glibc, ncurses5, zlib, makeWrapper, patchelf,
platform-tools, composeXcodeWrapper, xcodewrapperArgs ? {} platform-tools, composeXcodeWrapper, xcodewrapperArgs ? {}
}: }:
@ -7,6 +7,7 @@ with stdenv;
let let
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs; xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
platform = callPackage ../../platform.nix { inherit target-os; };
in buildGoPackage rec { in buildGoPackage rec {
name = "gomobile-${version}"; name = "gomobile-${version}";
@ -26,9 +27,10 @@ in buildGoPackage rec {
patches = [ ./ndk-search-path.patch ./resolve-nix-android-sdk.patch ] patches = [ ./ndk-search-path.patch ./resolve-nix-android-sdk.patch ]
++ lib.optional isDarwin ./ignore-nullability-error-on-ios.patch; ++ lib.optional isDarwin ./ignore-nullability-error-on-ios.patch;
postPatch = '' postPatch =
lib.optionalString platform.targetAndroid ''
substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`" substituteInPlace cmd/gomobile/install.go --replace "\`adb\`" "\`${platform-tools}/bin/adb\`"
'' + ''
echo "Creating $dev" echo "Creating $dev"
mkdir -p $dev/src/$goPackagePath mkdir -p $dev/src/$goPackagePath
echo "Copying from $src" echo "Copying from $src"

View File

@ -1,47 +0,0 @@
#!/usr/bin/env bash
################################################################################
# This tool fetches versions of build tools from the .TOOLVERSIONS
# file in project root and calculates a single hash that represents
# the combined versions of all the specified tools.
################################################################################
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
toolversion="${GIT_ROOT}/scripts/toolversion"
usage () {
echo "Usage: gen-deps-hash [-b <base_hash>] -d <dep-name-1> [-d <dep-name-n>]" >&2
echo
echo "This script calculates a hash representing the required versions of the specified tools"
exit 0
}
# some options parsing
deps=()
while getopts "hb:d:" opt; do
case $opt in
b) base_hash="${base_hash}${OPTARG}";;
d)
version=$($toolversion "$OPTARG")
if [ $? -ne 0 ]; then
echo "ERROR: $OPTARG not found in .TOOLVERSIONS"
exit 1
fi
deps+=("$OPTARG $version")
;;
h) usage;;
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;;
esac
done
if [ ${#deps[@]} -eq 0 ]; then
echo "ERROR: No dependencies specified"
echo
usage
fi
IFS=$'\n' sorted_deps=($(sort <<<"${deps[*]}"))
unset IFS
hash=$(echo "${base_hash}${sorted_deps[@]}" | md5sum | cut -f1 -d" ")
echo "${hash:0:8}"

View File

@ -28,7 +28,7 @@ if [ $_need_curl -eq 1 ] && ! program_exists "curl"; then
exit 1 exit 1
fi fi
if is_linux && [ -z "$JENKINS_URL" ]; then if is_linux && [ -z "$IN_CI_ENVIRONMENT" ]; then
watches=$(cat /proc/sys/fs/inotify/max_user_watches) watches=$(cat /proc/sys/fs/inotify/max_user_watches)
required_watches=524288 required_watches=524288
if [ $watches -lt $required_watches ]; then if [ $watches -lt $required_watches ]; then