mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-13 18:25:45 +00:00
Print a friendlier message when Xcode/iPhone SDK are not installed
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
parent
a09ff50583
commit
4041a12612
@ -1,5 +1,5 @@
|
||||
|
||||
{ buildGoPackage, go, xcodeWrapper, pkgs, stdenv }:
|
||||
{ buildGoPackage, go, xcodeWrapper, pkgs, stdenv, utils }:
|
||||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
with stdenv;
|
||||
|
||||
let
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; };
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
|
||||
|
||||
args = removeAttrs args' [ "goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem" ]; # Remove desktop-only arguments from args
|
||||
buildStatusGoDesktopLib = buildStatusGo (args // {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
{ buildGoPackage, go, gomobile, openjdk, xcodeWrapper, pkgs, stdenv }:
|
||||
{ buildGoPackage, go, gomobile, openjdk, xcodeWrapper, pkgs, stdenv, utils }:
|
||||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
|
||||
@ -11,7 +11,7 @@ with stdenv;
|
||||
|
||||
let
|
||||
targetConfig = config;
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; };
|
||||
buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; };
|
||||
|
||||
args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ]; # Remove mobile-only arguments from args
|
||||
buildStatusGoMobileLib = buildStatusGo (args // {
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ buildGoPackage, go, xcodeWrapper, stdenv }:
|
||||
{ buildGoPackage, go, xcodeWrapper, stdenv, utils }:
|
||||
|
||||
{ owner, repo, rev, version, goPackagePath, src, host,
|
||||
nativeBuildInputs ? [],
|
||||
@ -40,10 +40,8 @@ let
|
||||
"var EnabledStr = \"true\""
|
||||
'';
|
||||
|
||||
# we print out the version so that we fail fast in case there's any problem running xcrun, instead of failing at the end of the build
|
||||
preConfigure = lib.optionalString isDarwin ''
|
||||
xcrun xcodebuild -version
|
||||
'';
|
||||
# Ensure XCode is present, instead of failing at the end of the build
|
||||
preConfigure = lib.optionalString isDarwin utils.enforceXCodeAvailable;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
@ -4,9 +4,10 @@ with stdenv;
|
||||
|
||||
let
|
||||
platform = pkgs.callPackage ../platform.nix { inherit target-os; };
|
||||
gomobile = pkgs.callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit composeXcodeWrapper xcodewrapperArgs; };
|
||||
buildStatusGoDesktopLib = pkgs.callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go pkgs xcodeWrapper; };
|
||||
buildStatusGoMobileLib = pkgs.callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile pkgs xcodeWrapper; };
|
||||
utils = pkgs.callPackage ../utils.nix { inherit xcodeWrapper; };
|
||||
gomobile = pkgs.callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit composeXcodeWrapper xcodewrapperArgs utils; };
|
||||
buildStatusGoDesktopLib = pkgs.callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go pkgs xcodeWrapper utils; };
|
||||
buildStatusGoMobileLib = pkgs.callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile pkgs xcodeWrapper utils; };
|
||||
extractStatusGoConfig = f: lib.last (lib.splitString "\n" (lib.fileContents f));
|
||||
owner = lib.fileContents ../../STATUS_GO_OWNER;
|
||||
version = extractStatusGoConfig ../../STATUS_GO_VERSION; # TODO: Simplify this path search with lib.locateDominatingFile
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, pkgs, buildGoPackage, fetchgit,
|
||||
{ stdenv, pkgs, utils, buildGoPackage, fetchgit,
|
||||
glibc, ncurses5, zlib, makeWrapper, patchelf,
|
||||
platform-tools, composeXcodeWrapper, xcodewrapperArgs ? {}
|
||||
}:
|
||||
@ -20,10 +20,8 @@ in buildGoPackage rec {
|
||||
buildInputs = [ makeWrapper ]
|
||||
++ lib.optional isDarwin xcodeWrapper;
|
||||
|
||||
# we print out the version so that we fail fast in case there's any problem running xcrun, instead of failing at the end of the build
|
||||
preConfigure = lib.optionalString isDarwin ''
|
||||
PATH=${lib.makeBinPath [ xcodeWrapper ]}:$PATH xcrun xcodebuild -version
|
||||
'';
|
||||
# Ensure XCode and the iPhone SDK are present, instead of failing at the end of the build
|
||||
preConfigure = lib.optionalString isDarwin utils.enforceiPhoneSDKAvailable;
|
||||
|
||||
patches = [ ./ndk-search-path.patch ./resolve-nix-android-sdk.patch ]
|
||||
++ lib.optional isDarwin ./ignore-nullability-error-on-ios.patch;
|
||||
|
45
nix/utils.nix
Normal file
45
nix/utils.nix
Normal file
@ -0,0 +1,45 @@
|
||||
{ xcodeWrapper }:
|
||||
|
||||
let
|
||||
RED = "\\033[0;31m";
|
||||
GREEN="\\033[0;32m";
|
||||
NC = "\\033[0m";
|
||||
_xcodeToolsTest = ''
|
||||
xcode=0
|
||||
iPhoneSDK=0
|
||||
export PATH=${xcodeWrapper}/bin:$PATH
|
||||
[[ "$(xcrun xcodebuild -version)" == "Xcode ${_xcodeVersion}"* ]] && xcode=1
|
||||
[ $xcode -eq 1 ] && xcrun --sdk iphoneos --show-sdk-version > /dev/null && iPhoneSDK=1
|
||||
'';
|
||||
_xcodeToolReportScript = tool-name: ''[ $SELECTED -eq 0 ] && echo -e "${NC}- ${RED}[ ] ${tool-name}" || echo -e "${NC}- ${GREEN}[√] ${tool-name}${RED}"'';
|
||||
_xcodeToolsReportScript = ''
|
||||
echo -e "${RED}There are some required tools missing in the system:"
|
||||
export SELECTED=$xcode; ${_xcodeToolReportScript "Xcode ${_xcodeVersion}"}
|
||||
export SELECTED=$iPhoneSDK; ${_xcodeToolReportScript "iPhone SDK"}
|
||||
'';
|
||||
_xcodeVersion = builtins.replaceStrings ["xcode-wrapper-"] [""] xcodeWrapper.name;
|
||||
enforceXCodeAvailable = ''
|
||||
${_xcodeToolsTest}
|
||||
if [ $xcode -eq 0 ]; then
|
||||
${_xcodeToolsReportScript}
|
||||
echo -e "Please install Xcode ${_xcodeVersion} from the App Store.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
enforceiPhoneSDKAvailable = ''
|
||||
${_xcodeToolsTest}
|
||||
if [ $iPhoneSDK -eq 0 ]; then
|
||||
${_xcodeToolsReportScript}
|
||||
if [ $xcode -eq 1 ]; then
|
||||
echo -e "Please install the iPhone SDK in Xcode.${NC}""
|
||||
else
|
||||
echo -e "Please install Xcode ${_xcodeVersion} from the App Store, and then the iPhone SDK.${NC}""
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
in {
|
||||
inherit enforceXCodeAvailable
|
||||
enforceiPhoneSDKAvailable;
|
||||
}
|
@ -23,7 +23,7 @@ setup_header "Checking prerequisites..."
|
||||
_need_curl=0
|
||||
! is_nixos && ! program_exists nix && _need_curl=1
|
||||
|
||||
if _need_curl && ! program_exists "curl"; then
|
||||
if [ $_need_curl -eq 1 ] && ! program_exists "curl"; then
|
||||
cecho "@b@yellow[[Please install curl before running setup.]]"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user