From c1e2c3a6d63e922925ef3f5d873ee1ea7dc1912f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Sun, 21 Jun 2015 19:35:09 +0200 Subject: [PATCH] build.sh: ignore directories in tarballs/ (#37) build.sh, tools.sh: add UNATTENDED option (#37) xcrun.cpp: make local functions static --- README.md | 2 +- build.sh | 16 ++++++++++------ tools/tools.sh | 9 +++++++-- wrapper/programs/xcrun.cpp | 5 ++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d727170..3a17f2e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ On debian like systems you can also use [llvm.org/apt](http://llvm.org/apt) to g But be careful, that repository is known to cause [troubles](https://github.com/tpoechtrager/osxcross/issues/16). \-- -Then run `./build.sh` to build the cross toolchain. +Then run `[UNATTENDED=1] ./build.sh` to build the cross toolchain. (It will search 'tarballs' for your SDK and then build in its own directory.) **Do not forget** to add `/target/bin` to your PATH variable. diff --git a/build.sh b/build.sh index de988aa..c2aa44e 100755 --- a/build.sh +++ b/build.sh @@ -18,14 +18,14 @@ function guess_sdk_version() echo no SDK found in 'tarballs/'. please see README.md exit 1 elif [ $sdkcount -gt 1 ]; then - sdks=`find tarballs/ | grep MacOSX` + sdks=`find tarballs/ -type f | grep MacOSX` for sdk in $sdks; do echo $sdk; done echo 'more than one MacOSX SDK tarball found. please set' echo 'SDK_VERSION environment variable for the one you want' echo '(for example: SDK_VERSION=10.x [OSX_VERSION_MIN=10.x] ./build.sh)' exit 1 else - sdk=`find tarballs/ | grep MacOSX` + sdk=`find tarballs/ -type f | grep MacOSX` tmp2=`echo ${sdk/bz2/} | sed s/[^0-9.]//g` tmp3=`echo $tmp2 | sed s/\\\.*$//g` guess_sdk_version_result=$tmp3 @@ -44,7 +44,7 @@ function verify_sdk_version() { sdkv=$1 for file in tarballs/*; do - if [ `echo $file | grep OSX.*$sdkv` ]; then + if [ -f "$file" ] && [ `echo $file | grep OSX.*$sdkv` ]; then echo "verified at "$file sdk=$file fi @@ -104,8 +104,10 @@ echo "Tarball Directory: $TARBALL_DIR" echo "Build Directory: $BUILD_DIR" echo "Install Directory: $TARGET_DIR" echo "SDK Install Directory: $SDK_DIR" -echo "" -read -p "Press enter to start building" +if [ -z "$UNATTENDED" ]; then + echo "" + read -p "Press enter to start building" +fi echo "" export PATH=$TARGET_DIR/bin:$PATH @@ -267,7 +269,9 @@ do echo "You can press ctrl-c to break the build process," echo "if you restart ./build.sh then we will continue from here" echo "" - read -p "Press enter to continue" + if [ -z "$UNATTENDED" ]; then + read -p "Press enter to continue" + fi ls $TARBALL_DIR/MacOSX$SDK_VERSION* &>/dev/null done set -e diff --git a/tools/tools.sh b/tools/tools.sh index eb0f664..2087e4a 100755 --- a/tools/tools.sh +++ b/tools/tools.sh @@ -48,8 +48,13 @@ function require() which $1 &>/dev/null while [ $? -ne 0 ] do - echo "" - read -p "Please install $1 then press enter" + if [ -z "$UNATTENDED" ]; then + echo "" + read -p "Please install '$1' then press enter" + else + echo "Required dependency '$1' is not installed" 1>&2 + exit 1 + fi which $1 &>/dev/null done set -e diff --git a/wrapper/programs/xcrun.cpp b/wrapper/programs/xcrun.cpp index e9ede49..8e77c65 100644 --- a/wrapper/programs/xcrun.cpp +++ b/wrapper/programs/xcrun.cpp @@ -29,8 +29,9 @@ using namespace tools; using namespace target; namespace program { +namespace { -static bool showCommand = false; +bool showCommand = false; bool getToolPath(Target &target, std::string &toolpath, const char *tool) { toolpath = target.execpath; @@ -130,6 +131,8 @@ int showSDKVersion(Target &target, char **) { return 0; } +} // anonymous namespace + int xcrun(int argc, char **argv, Target &target) { if (getenv("xcrun_log")) showCommand = true;