From 3c627cb0a07fb8a2569cf306f23ba652247a7bc6 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 21 Sep 2015 18:31:04 -0400 Subject: [PATCH] append MASON_STDLIB_VERSION to binary if MASON_CXX_PACKAGE == true respect CXX env var add script to print c++ stdlib version include instead of because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65473 --- .gitignore | 3 ++- mason.sh | 10 ++++++++-- stdlib.cpp | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 stdlib.cpp diff --git a/.gitignore b/.gitignore index 9b00ebb5d..b383015a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*-*/ \ No newline at end of file +*-*/ +stdlib.o diff --git a/mason.sh b/mason.sh index 12514217c..915d53a08 100644 --- a/mason.sh +++ b/mason.sh @@ -38,6 +38,8 @@ case ${MASON_ROOT} in *\ * ) mason_error "Directory '${MASON_ROOT} contains spaces."; exit ;; esac +export MASON_STDLIB_VERSION="-"`${CXX:-c++} ${MASON_DIR}/stdlib.cpp -o ${MASON_DIR}/stdlib.o && ${MASON_DIR}/stdlib.o` + if [ ${MASON_PLATFORM} = 'osx' ]; then export MASON_HOST_ARG="--host=x86_64-apple-darwin" export MASON_PLATFORM_VERSION=`xcrun --sdk macosx --show-sdk-version` @@ -86,7 +88,6 @@ elif [ ${MASON_PLATFORM} = 'ios' ]; then export MASON_ISIM_CFLAGS="${MIN_SDK_VERSION_FLAG} -isysroot ${MASON_SDK_PATH} -arch i386 -arch x86_64" elif [ ${MASON_PLATFORM} = 'linux' ]; then - export MASON_DYNLIB_SUFFIX="so" # Assume current system is the target platform @@ -243,7 +244,12 @@ else MASON_PLATFORM_ID=${MASON_PLATFORM}-${MASON_PLATFORM_VERSION} fi MASON_PREFIX=${MASON_ROOT}/${MASON_PLATFORM_ID}/${MASON_NAME}/${MASON_VERSION} -MASON_BINARIES=${MASON_PLATFORM_ID}/${MASON_NAME}/${MASON_VERSION}.tar.gz +MASON_BINARIES_PREFIX=${MASON_PLATFORM_ID}/${MASON_NAME}/${MASON_VERSION} +if [[ ${MASON_CXX_PACKAGE} == true ]]; then + MASON_BINARIES=${MASON_BINARIES_PREFIX}${MASON_STDLIB_VERSION}.tar.gz +else + MASON_BINARIES=${MASON_BINARIES_PREFIX}.tar.gz +fi MASON_BINARIES_PATH=${MASON_ROOT}/.binaries/${MASON_BINARIES} diff --git a/stdlib.cpp b/stdlib.cpp new file mode 100644 index 000000000..02113f62d --- /dev/null +++ b/stdlib.cpp @@ -0,0 +1,16 @@ +#include + +#include +#include + +#define PRINT(name, version) printf("%s-%d\n", name, version); + +int main(int argc, char *argv[]) { + #ifdef _LIBCPP_VERSION + PRINT("libc++", _LIBCPP_ABI_VERSION) + #elif __GLIBCXX__ + PRINT("libstdc++", __GLIBCXX__) + #endif + + exit(EXIT_SUCCESS); +}