mirror of
https://github.com/tpoechtrager/osxcross.git
synced 2024-08-16 20:10:35 +03:00
* Add xcodebuild stub tool. Only '-version' is supported.
* build_compiler_rt.sh: Change git repository. The llvm.org one is no longer synced. * build_compiler_rt.sh: Add check for os/lock.h. * xcrun: "Support" -show-sdk-platform-path. * sw_vers: Output 0CFFFF for Build Version.
This commit is contained in:
parent
952985fee3
commit
6edf1ca936
@ -35,22 +35,23 @@ CLANG_DARWIN_LIB_DIR="${CLANG_LIB_DIR}/lib/darwin"
|
||||
USE_CMAKE=0
|
||||
|
||||
case $CLANG_VERSION in
|
||||
3.2* ) BRANCH=release_32 ;;
|
||||
3.3* ) BRANCH=release_33 ;;
|
||||
3.4* ) BRANCH=release_34 ;;
|
||||
3.5* ) BRANCH=release_35 ;;
|
||||
3.6* ) BRANCH=release_36 ;;
|
||||
3.7* ) BRANCH=release_37 ;;
|
||||
3.8* ) BRANCH=release_38; USE_CMAKE=1; ;;
|
||||
3.9* ) BRANCH=release_39; USE_CMAKE=1; ;;
|
||||
4.0* ) BRANCH=release_40; USE_CMAKE=1; ;;
|
||||
5.0* ) BRANCH=release_50; USE_CMAKE=1; ;;
|
||||
6.0* ) BRANCH=release_60; USE_CMAKE=1; ;;
|
||||
7.* ) BRANCH=release_70; USE_CMAKE=1; ;;
|
||||
8.* ) BRANCH=release_80; USE_CMAKE=1; ;;
|
||||
9.* ) BRANCH=release_90; USE_CMAKE=1; ;;
|
||||
10.* ) BRANCH=master; USE_CMAKE=1; ;;
|
||||
* ) echo "Unsupported Clang version, must be >= 3.2 and <= 10.0" 1>&2; exit 1;
|
||||
3.2* ) BRANCH=release/3.2.x ;;
|
||||
3.3* ) BRANCH=release/3.3.x ;;
|
||||
3.4* ) BRANCH=release/3.4.x ;;
|
||||
3.5* ) BRANCH=release/3.5.x ;;
|
||||
3.6* ) BRANCH=release/3.6.x ;;
|
||||
3.7* ) BRANCH=release/3.7.x ;;
|
||||
3.8* ) BRANCH=release/3.8.x; USE_CMAKE=1; ;;
|
||||
3.9* ) BRANCH=release/3.9.x; USE_CMAKE=1; ;;
|
||||
4.0* ) BRANCH=release/4.x; USE_CMAKE=1; ;;
|
||||
5.0* ) BRANCH=release/5.x; USE_CMAKE=1; ;;
|
||||
6.0* ) BRANCH=release/6.x; USE_CMAKE=1; ;;
|
||||
7.* ) BRANCH=release/7.x; USE_CMAKE=1; ;;
|
||||
8.* ) BRANCH=release/8.x; USE_CMAKE=1; ;;
|
||||
9.* ) BRANCH=release/9.x; USE_CMAKE=1; ;;
|
||||
10.* ) BRANCH=release/10.x; USE_CMAKE=1; ;;
|
||||
11.* ) BRANCH=master; USE_CMAKE=1; ;;
|
||||
* ) echo "Unsupported Clang version, must be >= 3.2 and <= 11.0" 1>&2; exit 1;
|
||||
esac
|
||||
|
||||
if [ $(osxcross-cmp $CLANG_VERSION ">=" 3.5) -eq 1 ]; then
|
||||
@ -66,13 +67,19 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HAVE_OS_LOCK=0
|
||||
|
||||
if echo "#include <os/lock.h>" | xcrun clang -E - &>/dev/null; then
|
||||
HAVE_OS_LOCK=1
|
||||
fi
|
||||
|
||||
pushd $BUILD_DIR &>/dev/null
|
||||
|
||||
FULL_CLONE=1 \
|
||||
get_sources https://git.llvm.org/git/compiler-rt.git $BRANCH
|
||||
get_sources https://github.com/llvm/llvm-project.git $BRANCH "compiler-rt"
|
||||
|
||||
if [ $f_res -eq 1 ]; then
|
||||
pushd $CURRENT_BUILD_PROJECT_NAME &>/dev/null
|
||||
pushd "$CURRENT_BUILD_PROJECT_NAME/compiler-rt" &>/dev/null
|
||||
|
||||
if [ $(osxcross-cmp $SDK_VERSION "<=" 10.11) -eq 1 ]; then
|
||||
# https://github.com/tpoechtrager/osxcross/issues/178
|
||||
@ -115,6 +122,11 @@ if [ $f_res -eq 1 ]; then
|
||||
$SED -i "s/COMMAND codesign /COMMAND true /g" \
|
||||
cmake/Modules/AddCompilerRT.cmake
|
||||
|
||||
if [ $HAVE_OS_LOCK -eq 0 ]; then
|
||||
$SED -i "s/COMPILER_RT_HAS_TSAN TRUE/COMPILER_RT_HAS_TSAN FALSE/g" \
|
||||
cmake/config-ix.cmake
|
||||
fi
|
||||
|
||||
mkdir build
|
||||
pushd build &>/dev/null
|
||||
|
||||
@ -177,14 +189,14 @@ echo ""
|
||||
|
||||
echo "mkdir -p ${CLANG_INCLUDE_DIR}"
|
||||
echo "mkdir -p ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -rv $BUILD_DIR/compiler-rt/include/sanitizer ${CLANG_INCLUDE_DIR}"
|
||||
echo "cp -rv $BUILD_DIR/compiler-rt/compiler-rt/include/sanitizer ${CLANG_INCLUDE_DIR}"
|
||||
|
||||
if [ $USE_CMAKE -eq 1 ]; then
|
||||
|
||||
### CMAKE ###
|
||||
|
||||
echo "cp -v $BUILD_DIR/compiler-rt/build/lib/darwin/*.a ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -v $BUILD_DIR/compiler-rt/build/lib/darwin/*.dylib ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -v $BUILD_DIR/compiler-rt/compiler-rt/build/lib/darwin/*.a ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -v $BUILD_DIR/compiler-rt/compiler-rt/build/lib/darwin/*.dylib ${CLANG_DARWIN_LIB_DIR}"
|
||||
|
||||
### CMAKE END ###
|
||||
|
||||
@ -196,7 +208,7 @@ else
|
||||
|
||||
function print_install_command() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "cp $PWD/$1 ${CLANG_DARWIN_LIB_DIR}/$2"
|
||||
echo "cp $PWD/compiler-rt/$1 ${CLANG_DARWIN_LIB_DIR}/$2"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ source tools/tools.sh
|
||||
# (<4.7 will not work properly with libc++)
|
||||
if [ -z "$GCC_VERSION" ]; then
|
||||
GCC_VERSION=9.2.0
|
||||
#GCC_VERSION=5-20140928 # snapshot
|
||||
#GCC_VERSION=5-20200228 # snapshot
|
||||
fi
|
||||
|
||||
# GCC mirror
|
||||
|
@ -296,18 +296,20 @@ function git_clone_repository
|
||||
fi
|
||||
|
||||
if [ ! -d $project_name ]; then
|
||||
local args=""
|
||||
if [ -z "$FULL_CLONE" ] && [ $branch == "master" ]; then
|
||||
args="--depth 1"
|
||||
fi
|
||||
git clone $url $args
|
||||
git clone $url $args $project_name --depth 1
|
||||
fi
|
||||
|
||||
pushd $project_name &>/dev/null
|
||||
|
||||
git reset --hard &>/dev/null
|
||||
git clean -fdx &>/dev/null
|
||||
git fetch origin
|
||||
|
||||
if git show-ref refs/heads/$branch &>/dev/null; then
|
||||
git fetch origin $branch
|
||||
else
|
||||
git fetch origin $branch:$branch --depth 1
|
||||
fi
|
||||
|
||||
git checkout $branch
|
||||
git pull origin $branch
|
||||
|
||||
@ -366,9 +368,13 @@ function get_sources()
|
||||
{
|
||||
local url=$1
|
||||
local branch=$2
|
||||
local project_name=$(get_project_name_from_url $url)
|
||||
local project_name=$3
|
||||
local build_complete_file="$BUILD_DIR/.${project_name}_build_complete"
|
||||
|
||||
if [ -z "$project_name" ]; then
|
||||
project_name=$(get_project_name_from_url $url)
|
||||
fi
|
||||
|
||||
CURRENT_BUILD_PROJECT_NAME=$project_name
|
||||
|
||||
build_msg $project_name $branch
|
||||
|
@ -62,6 +62,7 @@ SRCS= \
|
||||
programs/sw_vers.cpp \
|
||||
programs/pkg-config.cpp \
|
||||
programs/xcrun.cpp \
|
||||
programs/xcodebuild.cpp \
|
||||
programs/dsymutil.cpp
|
||||
|
||||
OBJS=$(subst .cpp,.o,$(SRCS))
|
||||
|
@ -190,6 +190,7 @@ if [ "$PLATFORM" != "Darwin" ]; then
|
||||
fi
|
||||
|
||||
create_wrapper_link xcrun 1
|
||||
create_wrapper_link xcodebuild 1
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************
|
||||
* OSXCross Compiler Wrapper *
|
||||
* Copyright (C) 2014-2016 by Thomas Poechtrager *
|
||||
* Copyright (C) 2014-2020 by Thomas Poechtrager *
|
||||
* t.poechtrager@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -28,20 +28,6 @@ namespace program {
|
||||
|
||||
int sw_vers(int argc, char **argv, Target &target) {
|
||||
|
||||
auto genFakeBuildVer = [](std::string & build)->std::string & {
|
||||
std::stringstream tmp;
|
||||
|
||||
srand(static_cast<unsigned int>(getNanoSeconds()));
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
tmp << std::hex << (rand() % 16 + 1);
|
||||
|
||||
build = tmp.str();
|
||||
build.resize(5);
|
||||
|
||||
return build;
|
||||
};
|
||||
|
||||
auto getProductVer = [&]()->OSVersion {
|
||||
char *p = getenv("OSXCROSS_SW_VERS_OSX_VERSION");
|
||||
OSVersion OSNum;
|
||||
@ -68,19 +54,16 @@ int sw_vers(int argc, char **argv, Target &target) {
|
||||
} else if (!strcmp(argv[1], "-productVersion")) {
|
||||
str << getProductVer().shortStr();
|
||||
} else if (!strcmp(argv[1], "-buildVersion")) {
|
||||
std::string build;
|
||||
str << genFakeBuildVer(build);
|
||||
str << "0CFFFF";
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << str.str() << std::endl;
|
||||
} else if (argc == 1) {
|
||||
std::string build;
|
||||
|
||||
std::cout << "ProductName: Mac OS X" << std::endl;
|
||||
std::cout << "ProductVersion: " << getProductVer().shortStr() << std::endl;
|
||||
std::cout << "BuildVersion: " << genFakeBuildVer(build) << std::endl;
|
||||
std::cout << "BuildVersion: 0CFFFF" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
81
wrapper/programs/xcodebuild.cpp
Normal file
81
wrapper/programs/xcodebuild.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/***********************************************************************
|
||||
* OSXCross Compiler Wrapper *
|
||||
* Copyright (C) 2014-2020 by Thomas Poechtrager *
|
||||
* t.poechtrager@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software *
|
||||
* Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "proginc.h"
|
||||
|
||||
using namespace tools;
|
||||
using namespace target;
|
||||
|
||||
namespace program {
|
||||
namespace {
|
||||
|
||||
int version(Target*, char**) {
|
||||
std::cout << "Xcode 10.2.1" << std::endl;
|
||||
std::cout << "Build version 0CFFFF" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int help(Target* = nullptr, char** = nullptr) {
|
||||
std::cerr << "Only '-version' is supported by this stub tool" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int xcodebuild(int argc, char **argv, Target &target) {
|
||||
auto dummy = [](Target*, char**) { return 0; };
|
||||
|
||||
ArgParser<int (*)(Target*, char**), 3> argParser = {{
|
||||
{"version", version},
|
||||
{"sdk", dummy},
|
||||
{"help", help}
|
||||
}};
|
||||
|
||||
if (argc == 1)
|
||||
help();
|
||||
|
||||
int retVal = 1;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
auto b = argParser.parseArg(argc, argv, i);
|
||||
|
||||
if (!b) {
|
||||
if (argv[i][0] == '-') {
|
||||
err << "xcodebuild: unknown argument: '" << argv[i] << "'" << err.endl();
|
||||
retVal = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
retVal = b->fun(&target, &argv[i + 1]);
|
||||
|
||||
if (retVal != 0)
|
||||
break;
|
||||
|
||||
i += b->numArgs;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
} // namespace program
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************
|
||||
* OSXCross Compiler Wrapper *
|
||||
* Copyright (C) 2014-2016 by Thomas Poechtrager *
|
||||
* Copyright (C) 2014-2020 by Thomas Poechtrager *
|
||||
* t.poechtrager@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -47,7 +47,7 @@ bool isXcodeTool(const char *tool) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getToolPath(Target &target, std::string &toolpath, const char *tool) {
|
||||
bool getToolPath(Target *target, std::string &toolpath, const char *tool) {
|
||||
const char *filename = getFileName(tool);
|
||||
bool isxcodetool = isXcodeTool(filename);
|
||||
|
||||
@ -61,9 +61,9 @@ bool getToolPath(Target &target, std::string &toolpath, const char *tool) {
|
||||
}
|
||||
|
||||
if (toolpath.empty()) {
|
||||
toolpath = target.execpath;
|
||||
toolpath = target->execpath;
|
||||
toolpath += PATHDIV;
|
||||
toolpath += getArchName(target.arch);
|
||||
toolpath += getArchName(target->arch);
|
||||
toolpath += "-";
|
||||
toolpath += getDefaultVendor();
|
||||
toolpath += "-";
|
||||
@ -84,18 +84,18 @@ bool getToolPath(Target &target, std::string &toolpath, const char *tool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int help(Target&, char**) {
|
||||
int help(Target* = nullptr, char** = nullptr) {
|
||||
std::cerr << "https://developer.apple.com/library/mac/documentation/Darwin/"
|
||||
"Reference/ManPages/man1/xcrun.1.html" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int version(Target&, char**) {
|
||||
int version(Target*, char**) {
|
||||
std::cout << "xcrun version: 0." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sdk(Target&, char **argv) {
|
||||
int sdk(Target*, char **argv) {
|
||||
const char *SDK = argv[0];
|
||||
|
||||
if (!strcmp(SDK, "macosx") || !strcmp(SDK, "macosx.internal"))
|
||||
@ -133,12 +133,12 @@ int sdk(Target&, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int log(Target&, char**) {
|
||||
int log(Target*, char**) {
|
||||
showCommand = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int find(Target &target, char **argv) {
|
||||
int find(Target *target, char **argv) {
|
||||
if (argv[1])
|
||||
return 1;
|
||||
std::string toolpath;
|
||||
@ -148,7 +148,7 @@ int find(Target &target, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run(Target &target, char **argv) {
|
||||
int run(Target *target, char **argv) {
|
||||
std::string toolpath;
|
||||
std::string command;
|
||||
|
||||
@ -181,16 +181,21 @@ int run(Target &target, char **argv) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int showSDKPath(Target &target, char**) {
|
||||
int showSDKPath(Target *target, char**) {
|
||||
std::string SDKPath;
|
||||
if (!target.getSDKPath(SDKPath))
|
||||
if (!target->getSDKPath(SDKPath))
|
||||
return 1;
|
||||
std::cout << SDKPath << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int showSDKVersion(Target &target, char**) {
|
||||
std::cout << target.getSDKOSNum().shortStr() << std::endl;
|
||||
int showSDKVersion(Target *target, char**) {
|
||||
std::cout << target->getSDKOSNum().shortStr() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int showPlatformPath(Target *target, char**) {
|
||||
std::cout << target->execpath << "/.." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -216,12 +221,12 @@ int xcrun(int argc, char **argv, Target &target) {
|
||||
if (char *SDK = getenv("SDKROOT")) {
|
||||
unsetenv("OSXCROSS_SDKROOT");
|
||||
char *argv[1] = { SDK };
|
||||
sdk(target, argv);
|
||||
sdk(&target, argv);
|
||||
}
|
||||
|
||||
auto dummy = [](Target&, char**) { return 0; };
|
||||
auto dummy = [](Target*, char**) { return 0; };
|
||||
|
||||
ArgParser<int (*)(Target&, char**), 19> argParser = {{
|
||||
ArgParser<int (*)(Target*, char**), 20> argParser = {{
|
||||
{"h", help},
|
||||
{"help", help},
|
||||
{"version", version},
|
||||
@ -240,9 +245,13 @@ int xcrun(int argc, char **argv, Target &target) {
|
||||
{"r", run, 1},
|
||||
{"run", run, 1},
|
||||
{"show-sdk-path", showSDKPath},
|
||||
{"show-sdk-version", showSDKVersion}
|
||||
{"show-sdk-version", showSDKVersion},
|
||||
{"show-sdk-platform-path", showPlatformPath}
|
||||
}};
|
||||
|
||||
if (argc == 1)
|
||||
help();
|
||||
|
||||
int retVal = 1;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
@ -255,10 +264,10 @@ int xcrun(int argc, char **argv, Target &target) {
|
||||
break;
|
||||
}
|
||||
|
||||
run(target, &argv[i]);
|
||||
run(&target, &argv[i]);
|
||||
}
|
||||
|
||||
retVal = b->fun(target, &argv[i + 1]);
|
||||
retVal = b->fun(&target, &argv[i + 1]);
|
||||
|
||||
if (retVal != 0)
|
||||
break;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************
|
||||
* OSXCross Compiler Wrapper *
|
||||
* Copyright (C) 2014-2016 by Thomas Poechtrager *
|
||||
* Copyright (C) 2014-2020 by Thomas Poechtrager *
|
||||
* t.poechtrager@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -78,6 +78,7 @@ private:
|
||||
|
||||
int sw_vers(int argc, char **argv, target::Target &target);
|
||||
int xcrun(int argc, char **argv, Target &target);
|
||||
int xcodebuild(int argc, char **argv, Target &target);
|
||||
int dsymutil(int argc, char **argv, target::Target &target);
|
||||
|
||||
namespace osxcross {
|
||||
@ -94,6 +95,7 @@ static int dummy() { return 0; }
|
||||
constexpr prog programs[] = {
|
||||
{ "sw_vers", sw_vers },
|
||||
{ "xcrun", xcrun },
|
||||
{ "xcodebuild", xcodebuild },
|
||||
{ "dsymutil", dsymutil },
|
||||
{ "osxcross", osxcross::version },
|
||||
{ "osxcross-env", osxcross::env },
|
||||
|
@ -789,6 +789,7 @@ bool Target::setup() {
|
||||
case Arch::i586:
|
||||
case Arch::i686:
|
||||
is32bit = true;
|
||||
// falls through
|
||||
case Arch::x86_64:
|
||||
case Arch::x86_64h:
|
||||
if (isGCC()) {
|
||||
|
Loading…
Reference in New Issue
Block a user