From 91f7e0e26ee014df27ea34860b0adc324d1ef33e Mon Sep 17 00:00:00 2001 From: "Kasper F. Brandt" Date: Thu, 12 Feb 2015 16:59:43 +0100 Subject: [PATCH] Fix build on paths with spaces and with llvm path with spaces. Fixes #216 --- build.sh | 40 +++++++++++++++++------------------ src/pal/tools/gen-buildsys-clang.sh | 38 ++++++++++++++++----------------- src/pal/tools/setup-compiler-clang.sh | 4 ++-- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/build.sh b/build.sh index 61b3cbc..f8ce4aa 100755 --- a/build.sh +++ b/build.sh @@ -21,37 +21,37 @@ clean() # Cleanup the binaries drop folder if [ -d "$__BinDir" ]; then - rm -r $__BinDir + rm -r "$__BinDir" fi - mkdir -p $__BinDir + mkdir -p "$__BinDir" # Cleanup the CMake folder if [ -d "$__CMakeSlnDir" ]; then - rm -r $__CMakeSlnDir + rm -r "$__CMakeSlnDir" fi - mkdir -p $__CMakeSlnDir + mkdir -p "$__CMakeSlnDir" # Cleanup the logs folder if [ -d "$__LogsDir" ]; then - rm -r $__LogsDir + rm -r "$__LogsDir" fi - mkdir -p $__LogsDir + mkdir -p "$__LogsDir" # Cleanup intermediates folder if [ -d "$__IntermediatesDir" ]; then - rm -f $__IntermediatesDir + rm -f "$__IntermediatesDir" fi - mkdir -p $__IntermediatesDir + mkdir -p "$__IntermediatesDir" } # Check the system to ensure the right pre-reqs are in place check_prereqs() { - echo Checking pre-requisites... + echo "Checking pre-requisites..." # Check presence of CMake on the path hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; } @@ -64,17 +64,17 @@ build_coreclr() { # All set to commence the build - echo Commencing build of native components for $__BuildArch/$__BuildType - cd $__CMakeSlnDir + echo "Commencing build of native components for $__BuildArch/$__BuildType" + cd "$__CMakeSlnDir" # Regenerate the CMake solution - echo Invoking cmake with arguments: $__ProjectRoot $__CMakeArgs - $__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh $__ProjectRoot $__CMakeArgs + echo "Invoking cmake with arguments: \"$__ProjectRoot\" $__CMakeArgs" + "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__CMakeArgs # Check that the makefiles were created. if [ ! -f "$__CMakeSlnDir/Makefile" ]; then - echo Failed to generate native component build project! + echo "Failed to generate native component build project!" exit 1 fi @@ -85,16 +85,16 @@ build_coreclr() # Build CoreCLR - echo Executing make install -j $NumProc $__UnprocessedBuildArgs + echo "Executing make install -j $NumProc $__UnprocessedBuildArgs" make install -j $NumProc $__UnprocessedBuildArgs if [ $? != 0 ]; then - echo Failed to build coreclr components. + echo "Failed to build coreclr components." exit 1 fi } -echo Commencing CoreCLR Repo build +echo "Commencing CoreCLR Repo build" # Argument types supported by this script: # @@ -104,7 +104,7 @@ echo Commencing CoreCLR Repo build # Set the default arguments for build # Obtain the location of the bash script to figure out whether the root of the repo is. -__ProjectRoot=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" __BuildArch=amd64 __MSBuildBuildArch=x64 __BuildType=debug @@ -179,6 +179,6 @@ build_coreclr # Build complete -echo Repo successfully built. -echo Product binaries are available at $__BinDir +echo "Repo successfully built." +echo "Product binaries are available at $__BinDir" exit 0 diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh index ff7c2a9..760d89e 100755 --- a/src/pal/tools/gen-buildsys-clang.sh +++ b/src/pal/tools/gen-buildsys-clang.sh @@ -12,7 +12,7 @@ then exit 1 fi -. $1/src/pal/tools/setup-compiler-clang.sh +. "$1/src/pal/tools/setup-compiler-clang.sh" # Possible build types are DEBUG, RELEASE, RELWITHDEBINFO, MINSIZEREL. # Default to DEBUG @@ -21,7 +21,7 @@ then echo "Defaulting to DEBUG build." buildtype="DEBUG" else - buildtype=$2 + buildtype="$2" fi OS=`uname` @@ -42,35 +42,35 @@ fi desired_llvm_version=3.5 locate_llvm_exec() { - if which $llvm_prefix$1-$desired_llvm_version > /dev/null 2>&1 + if which "$llvm_prefix$1-$desired_llvm_version" > /dev/null 2>&1 then - echo $(which $llvm_prefix$1-$desired_llvm_version) - elif which $1 > /dev/null 2>&1 + echo "$(which $llvm_prefix$1-$desired_llvm_version)" + elif which "$1" > /dev/null 2>&1 then - echo $(which $1) + echo "$(which $1)" else exit 1 fi } -llvm_ar=$(locate_llvm_exec ar) +llvm_ar="$(locate_llvm_exec ar)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; } -llvm_link=$(locate_llvm_exec link) +llvm_link="$(locate_llvm_exec link)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; } -llvm_nm=$(locate_llvm_exec nm) +llvm_nm="$(locate_llvm_exec nm)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; } -llvm_ranlib=$(locate_llvm_exec ranlib) +llvm_ranlib="$(locate_llvm_exec ranlib)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-ranlib"; exit 1; } if [ $OS = "Linux" ]; then - llvm_objdump=$(locate_llvm_exec objdump) + llvm_objdump="$(locate_llvm_exec objdump)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; } fi -cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override.txt \ - -DCMAKE_AR=$llvm_ar \ - -DCMAKE_LINKER=$llvm_link \ - -DCMAKE_NM=$llvm_nm \ - -DCMAKE_OBJDUMP=$llvm_objdump \ - -DCMAKE_RANLIB=$llvm_ranlib \ - -DCMAKE_BUILD_TYPE=$buildtype \ - $1 +cmake "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override.txt" \ + "-DCMAKE_AR=$llvm_ar" \ + "-DCMAKE_LINKER=$llvm_link" \ + "-DCMAKE_NM=$llvm_nm" \ + "-DCMAKE_OBJDUMP=$llvm_objdump" \ + "-DCMAKE_RANLIB=$llvm_ranlib" \ + "-DCMAKE_BUILD_TYPE=$buildtype" \ + "$1" diff --git a/src/pal/tools/setup-compiler-clang.sh b/src/pal/tools/setup-compiler-clang.sh index 949872c..7e33e8c 100755 --- a/src/pal/tools/setup-compiler-clang.sh +++ b/src/pal/tools/setup-compiler-clang.sh @@ -3,5 +3,5 @@ # This file sets the environment to be used for building with clang. # -export CC=$(which clang) -export CXX=$(which clang++) +export CC="$(which clang)" +export CXX="$(which clang++)" -- 2.7.4