From 379f7648c379b19d7b2bf72f22a9ad6783bd14ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Wed, 23 Oct 2019 16:06:00 +0200 Subject: [PATCH] Make TARGET_DIR configurable (#108, #137, #201) --- build_compiler_rt.sh | 2 +- build_gcc.sh | 8 ++++---- tools/tools.sh | 4 ++-- wrapper/programs/osxcross-conf.cpp | 27 ++++++++++++--------------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/build_compiler_rt.sh b/build_compiler_rt.sh index 407dd25..80ef706 100755 --- a/build_compiler_rt.sh +++ b/build_compiler_rt.sh @@ -76,7 +76,7 @@ if [ $f_res -eq 1 ]; then if [ $(osxcross-cmp $OSXCROSS_SDK_VERSION "<=" 10.11) -eq 1 ]; then # https://github.com/tpoechtrager/osxcross/issues/178 - patch -p1 < $PATCH_DIR/compiler-rt_clock-gettime.patch + patch -p1 < $OSXCROSS_PATCH_DIR/compiler-rt_clock-gettime.patch fi EXTRA_MAKE_FLAGS="" diff --git a/build_gcc.sh b/build_gcc.sh index 70e3b80..bc17eb4 100755 --- a/build_gcc.sh +++ b/build_gcc.sh @@ -62,18 +62,18 @@ rm -f $OSXCROSS_TARGET_DIR/bin/*-g++* if [ $(osxcross-cmp $GCC_VERSION '>' 5.0.0) -eq 1 ] && [ $(osxcross-cmp $GCC_VERSION '<' 5.3.0) -eq 1 ]; then # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66035 - patch -p1 < $PATCH_DIR/gcc-pr66035.patch + patch -p1 < $OSXCROSS_PATCH_DIR/gcc-pr66035.patch fi if [ $(osxcross-cmp $GCC_VERSION '>=' 6.1.0) -eq 1 ] && [ $(osxcross-cmp $GCC_VERSION '<=' 6.3.0) -eq 1 ]; then # https://gcc.gnu.org/ml/gcc-patches/2016-09/msg00129.html - patch -p1 < $PATCH_DIR/gcc-6-buildfix.patch + patch -p1 < $OSXCROSS_PATCH_DIR/gcc-6-buildfix.patch fi if [ $(osxcross-cmp $GCC_VERSION '==' 6.3.0) -eq 1 ]; then # https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/darwin-driver.c?r1=244010&r2=244009&pathrev=244010 - patch -p1 < $PATCH_DIR/darwin-driver.c.patch + patch -p1 < $OSXCROSS_PATCH_DIR/darwin-driver.c.patch fi if [ $(osxcross-cmp $OSXCROSS_SDK_VERSION '>=' 10.14) -eq 1 ] && @@ -152,7 +152,7 @@ GCC_VERSION=`echo $GCC_VERSION | tr '-' ' ' | awk '{print $1}'` pushd $OSXCROSS_TARGET_DIR/x86_64-apple-$OSXCROSS_TARGET/include &>/dev/null pushd c++/${GCC_VERSION}* &>/dev/null -cat $OSXCROSS_TARGET_DIR/../patches/libstdcxx.patch | \ +cat $OSXCROSS_PATCH_DIR/libstdcxx.patch | \ $SED "s/darwin13/$OSXCROSS_TARGET/g" | \ patch -p0 -l &>/dev/null || true diff --git a/tools/tools.sh b/tools/tools.sh index 236a9b9..e051521 100644 --- a/tools/tools.sh +++ b/tools/tools.sh @@ -6,7 +6,7 @@ BASE_DIR=$PWD TARBALL_DIR=$BASE_DIR/tarballs BUILD_DIR=$BASE_DIR/build -TARGET_DIR=$BASE_DIR/target +TARGET_DIR=${TARGET_DIR:-$BASE_DIR/target} TARGET_DIR_SDK_TOOLS=$TARGET_DIR/SDK/tools PATCH_DIR=$BASE_DIR/patches SDK_DIR=$TARGET_DIR/SDK @@ -122,7 +122,7 @@ function guess_sdk_version() 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)' + echo '(for example: SDK_VERSION=10.x [OSX_VERSION_MIN=10.x] [TARGET_DIR=...] ./build.sh)' exit 1 else sdk=$(find -L tarballs/ -type f | grep MacOSX) diff --git a/wrapper/programs/osxcross-conf.cpp b/wrapper/programs/osxcross-conf.cpp index d499224..c2376d3 100644 --- a/wrapper/programs/osxcross-conf.cpp +++ b/wrapper/programs/osxcross-conf.cpp @@ -31,7 +31,12 @@ int conf(Target &target) { std::string SDKPath; OSVersion OSXVersionMin = getDefaultMinTarget(); const char *ltopath = getLibLTOPath(); - const char *builddir = getBuildDir(); + std::string BuildDir = getBuildDir(); + + if (BuildDir.empty()) { + BuildDir += target.execpath; + BuildDir += "/../../build"; + } if (!target.getSDKPath(SDKPath)) return 1; @@ -52,24 +57,16 @@ int conf(Target &target) { << std::endl; std::cout << "export OSXCROSS_SDK=" << SDKPath << std::endl; - std::cout << "export OSXCROSS_TARBALL_DIR=" << target.execpath - << "/../../tarballs" + std::cout << "export OSXCROSS_TARBALL_DIR=" << BuildDir.c_str() + << "/../tarballs" << std::endl; - std::cout << "export OSXCROSS_PATCH_DIR=" << target.execpath - << "/../../patches" + std::cout << "export OSXCROSS_PATCH_DIR=" << BuildDir.c_str() + << "/../patches" << std::endl; std::cout << "export OSXCROSS_TARGET_DIR=" << target.execpath << "/.." << std::endl; - - std::cout << "export OSXCROSS_BUILD_DIR="; - - if (builddir[0]) - std::cout << builddir; - else - std::cout << target.execpath << "/../../build"; - - std::cout << std::endl; - + std::cout << "export OSXCROSS_BUILD_DIR=" << BuildDir.c_str() + << std::endl; std::cout << "export OSXCROSS_CCTOOLS_PATH=" << target.execpath << std::endl; std::cout << "export OSXCROSS_LIBLTO_PATH=" << ltopath