diff options
author | Matt Mitchell <mmitche@microsoft.com> | 2015-02-12 16:56:00 +0000 |
---|---|---|
committer | Matt Mitchell <mmitche@microsoft.com> | 2015-02-12 16:56:00 +0000 |
commit | 5baf48df8e2a6d9b1fce906ae2248db81ec61a01 (patch) | |
tree | c2a5af194e57120168e734350ea4818b37f26ca7 | |
parent | 69ee8265d7a1313965d4c7433fd1753937b05f51 (diff) | |
parent | 832291f0afdc059f3fd1d4398e265507371f49d8 (diff) | |
download | coreclr-5baf48df8e2a6d9b1fce906ae2248db81ec61a01.tar.gz coreclr-5baf48df8e2a6d9b1fce906ae2248db81ec61a01.tar.bz2 coreclr-5baf48df8e2a6d9b1fce906ae2248db81ec61a01.zip |
Merge pull request #183 from poizan42/build-space-fix
Correct handling of paths with spaces and ampersands when building on windows
-rw-r--r-- | build.cmd | 70 | ||||
-rw-r--r-- | build.proj | 2 | ||||
-rw-r--r-- | src/mscorlib/GenerateSplitStringResources.targets | 2 | ||||
-rw-r--r-- | src/mscorlib/Tools/BclRewriter/BclRewriter.targets | 2 | ||||
-rw-r--r-- | src/pal/tools/gen-buildsys-win.bat | 12 | ||||
-rw-r--r-- | src/vm/wks/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/buildtest.cmd | 20 |
7 files changed, 60 insertions, 52 deletions
@@ -1,18 +1,20 @@ @echo off -setlocal +setlocal EnableDelayedExpansion :: Set the default arguments for build set __BuildArch=x64 set __BuildType=debug :: Set the various build properties here so that CMake and MSBuild can pick them up -set __ProjectDir=%~dp0 -set __ProjectFilesDir=%~dp0 -set __SourceDir=%__ProjectDir%\src -set __PackagesDir=%__SourceDir%\.nuget -set __RootBinDir=%__ProjectDir%\binaries -set __LogsDir=%__RootBinDir%\Logs -set __CMakeSlnDir=%__RootBinDir%\CMake +set "__ProjectDir=%~dp0" +:: remove trailing slash +if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" +set "__ProjectFilesDir=%__ProjectDir%" +set "__SourceDir=%__ProjectDir%\src" +set "__PackagesDir=%__SourceDir%\.nuget" +set "__RootBinDir=%__ProjectDir%\binaries" +set "__LogsDir=%__RootBinDir%\Logs" +set "__CMakeSlnDir=%__RootBinDir%\CMake" set __MSBCleanBuildArgs= :Arg_Loop @@ -36,18 +38,18 @@ echo Commencing CoreCLR Repo build echo. :: Set the remaining variables based upon the determined build configuration -set __BinDir=%__RootBinDir%\Product\%__BuildArch%\%__BuildType% -set __PackagesBinDir=%__BinDir%\.nuget -set __ToolsDir=%__RootBinDir%\tools -set __TestWorkingDir=%__RootBinDir%\tests\%__BuildArch%\%__BuildType% -set __IntermediatesDir=%__RootBinDir%\intermediates\%__BuildArch%\%__BuildType% +set "__BinDir=%__RootBinDir%\Product\%__BuildArch%\%__BuildType%" +set "__PackagesBinDir=%__BinDir%\.nuget" +set "__ToolsDir=%__RootBinDir%\tools" +set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildArch%\%__BuildType%" +set "__IntermediatesDir=%__RootBinDir%\intermediates\%__BuildArch%\%__BuildType%" :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash -set __CMakeBinDir=%__BinDir% +set "__CMakeBinDir=%__BinDir%" set "__CMakeBinDir=%__CMakeBinDir:\=/%" :: Switch to clean build mode if the binaries output folder does not exist -if not exist %__RootBinDir% set __CleanBuild=1 +if not exist "%__RootBinDir%" set __CleanBuild=1 :: Configure environment if we are doing a clean build. if not defined __CleanBuild goto CheckPrereqs @@ -58,19 +60,19 @@ echo. set __MSBCleanBuildArgs=/t:rebuild :: Cleanup the binaries drop folder -if exist %__BinDir% rd /s /q %__BinDir% -md %__BinDir% +if exist "%__BinDir%" rd /s /q "%__BinDir%" +md "%__BinDir%" :: Cleanup the CMake folder -if exist %__CMakeSlnDir% rd /s /q %__CMakeSlnDir% -md %__CMakeSlnDir% +if exist "%__CMakeSlnDir%" rd /s /q "%__CMakeSlnDir%" +md "%__CMakeSlnDir%" :: Cleanup the logs folder -if exist %__LogsDir% rd /s /q %__LogsDir% -md %__LogsDir% +if exist "%__LogsDir%" rd /s /q "%__LogsDir%" +md "%__LogsDir%" ::Cleanup intermediates folder -if exist %__IntermediatesDir% rd /s /q %__IntermediatesDir% +if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%" :: Check prerequisites :CheckPrereqs @@ -126,21 +128,21 @@ goto :eof :GenVSSolution :: Regenerate the VS solution -pushd %__CMakeSlnDir% -call %__SourceDir%\pal\tools\gen-buildsys-win.bat %__ProjectDir% +pushd "%__CMakeSlnDir%" +call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" popd :BuildComponents -if exist %__CMakeSlnDir%\install.vcxproj goto BuildCoreCLR +if exist "%__CMakeSlnDir%\install.vcxproj" goto BuildCoreCLR echo Failed to generate native component build project! goto :eof REM Build CoreCLR :BuildCoreCLR -set __CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildArch%__%__BuildType%.log -%_msbuildexe% %__CMakeSlnDir%\install.vcxproj %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%" +set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildArch%__%__BuildType%.log" +%_msbuildexe% "%__CMakeSlnDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%" IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild -echo Native component build failed. Refer %__CoreCLRBuildLog% for details. +echo Native component build failed. Refer !__CoreCLRBuildLog! for details. goto :eof :PerformMScorlibBuild @@ -157,14 +159,14 @@ if defined __UnixMscorlibOnly set __AdditionalMSBuildArgs=/p:OS=Unix /p:BuildNug call "%VS120COMNTOOLS%\VsDevCmd.bat" echo Commencing build of mscorlib for %__BuildArch%/%__BuildType% echo. -set __MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildArch%__%__BuildType%.log -%_msbuildexe% "%__ProjectFilesDir%build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" %__AdditionalMSBuildArgs% +set "__MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildArch%__%__BuildType%.log" +%_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" %__AdditionalMSBuildArgs% IF NOT ERRORLEVEL 1 ( if defined __UnixMscorlibOnly goto :eof goto PerformTestBuild ) -echo MScorlib build failed. Refer %__MScorlibBuildLog% for details. +echo MScorlib build failed. Refer !__MScorlibBuildLog! for details. goto :eof :PerformTestBuild @@ -173,15 +175,15 @@ echo Commencing build of tests for %__BuildArch%/%__BuildType% echo. call tests\buildtest.cmd IF NOT ERRORLEVEL 1 goto SuccessfulBuild -echo Test binaries build failed. Refer %__MScorlibBuildLog% for details. +echo Test binaries build failed. Refer !__MScorlibBuildLog! for details. goto :eof :SuccessfulBuild ::Build complete echo Repo successfully built. echo. -echo Product binaries are available at %__BinDir% -echo Test binaries are available at %__TestWorkingDir% +echo Product binaries are available at !__BinDir! +echo Test binaries are available at !__TestWorkingDir! goto :eof :Usage diff --git a/build.proj b/build.proj index e582c07e85..d3bb61470f 100644 --- a/build.proj +++ b/build.proj @@ -58,7 +58,7 @@ <Target Name="BuildNuGetPackages" AfterTargets="Build" Condition="'$(BuildNugetPackage)' != 'false'"> <MakeDir Directories="$(PackagesBinDir)" Condition="!Exists('$(PackagesBinDir)')" /> <Copy SourceFiles="@(NuSpecSrcs)" DestinationFolder="$(PackagesBinDir)" /> - <Exec Command="$(NuGetToolPath) pack "%(NuSpecs.Identity)" -NoPackageAnalysis -NoDefaultExcludes -OutputDirectory "$(PackagesBinDir)"" /> + <Exec Command=""$(NuGetToolPath)" pack "%(NuSpecs.Identity)" -NoPackageAnalysis -NoDefaultExcludes -OutputDirectory "$(PackagesBinDir)"" /> </Target> <ItemGroup> diff --git a/src/mscorlib/GenerateSplitStringResources.targets b/src/mscorlib/GenerateSplitStringResources.targets index 0b3f76c25d..567f8928c7 100644 --- a/src/mscorlib/GenerateSplitStringResources.targets +++ b/src/mscorlib/GenerateSplitStringResources.targets @@ -13,7 +13,7 @@ <Internal_ResGenDefines Include="%(SplitTextStringResource.ResGenDefines)" /> </ItemGroup> - <Exec Command=""$(ResGenCommand)" %(SplitTextStringResource.Identity) $(IntermediateOutputPath)%(SplitTextStringResource.Filename).resources /D:INCLUDE_DEBUG /D:INCLUDE_RUNTIME @(Internal_ResGenDefines->'/D:%(Identity)', ' ')" /> + <Exec Command=""$(ResGenCommand)" "%(SplitTextStringResource.Identity)" "$(IntermediateOutputPath)%(SplitTextStringResource.Filename).resources" /D:INCLUDE_DEBUG /D:INCLUDE_RUNTIME @(Internal_ResGenDefines->'/D:%(Identity)', ' ')" /> <ItemGroup> <EmbeddedResource Include="@(SplitTextStringResource->'$(IntermediateOutputPath)%(Filename).resources')"> diff --git a/src/mscorlib/Tools/BclRewriter/BclRewriter.targets b/src/mscorlib/Tools/BclRewriter/BclRewriter.targets index 2c2031585a..62c16f5e3c 100644 --- a/src/mscorlib/Tools/BclRewriter/BclRewriter.targets +++ b/src/mscorlib/Tools/BclRewriter/BclRewriter.targets @@ -19,7 +19,7 @@ <Target Name="RewriteWithBclRewriter" Inputs="@(AnnotatedAssembly)" Outputs="@(RewrittenAssembly)"> - <Exec Command="$(BclRewriterCommand) @(AnnotatedAssembly) /out:$(BclRewriterOutput) /include:$(BclRewriterModelFile) /platform:win /architecture:$(Platform) /flavor:$(_BuildType) /define:$(DefineConstants) /keepTempFiles+" StandardOutputImportance="Normal" /> + <Exec Command=""$(BclRewriterCommand)" "@(AnnotatedAssembly)" "/out:$(BclRewriterOutput)" "/include:$(BclRewriterModelFile)" /platform:win /architecture:$(Platform) /flavor:$(_BuildType) /define:$(DefineConstants) /keepTempFiles+" StandardOutputImportance="Normal" /> <!-- Update the location of the symbol file--> <PropertyGroup> diff --git a/src/pal/tools/gen-buildsys-win.bat b/src/pal/tools/gen-buildsys-win.bat index 9e50f40c31..348d006be8 100644 --- a/src/pal/tools/gen-buildsys-win.bat +++ b/src/pal/tools/gen-buildsys-win.bat @@ -1,15 +1,21 @@ +@echo off rem rem This file invokes cmake and generates the build system for windows. -echo off - set argC=0 for %%x in (%*) do Set /A argC+=1 if NOT %argC%==1 GOTO :USAGE if %1=="/?" GOTO :USAGE -cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE=%1\src\pal\tools\windows-compiler-override.txt -G "Visual Studio 12 2013 Win64" %1 +setlocal +set basePath=%1 +:: remove quotes +set "basePath=%basePath:"=%" +:: remove trailing slash +if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%" +cmake "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\src\pal\tools\windows-compiler-override.txt" -G "Visual Studio 12 2013 Win64" %1 +endlocal GOTO :DONE :USAGE diff --git a/src/vm/wks/CMakeLists.txt b/src/vm/wks/CMakeLists.txt index 573ec6f0fb..bf810d60b7 100644 --- a/src/vm/wks/CMakeLists.txt +++ b/src/vm/wks/CMakeLists.txt @@ -44,8 +44,8 @@ endif() add_custom_command( # The AsmConstants.inc will be built in the pre-build phase of the cee_wks build TARGET cee_wks PRE_BUILD - COMMAND ${POWERSHELL} -NoProfile -ExecutionPolicy Bypass ${VM_DIR}/h2inc.ps1 ${VM_DIR}/amd64/asmconstants.h >${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.tmp - COMMAND ${CMAKE_CXX_COMPILER} ${DEFINITIONS} /EP ${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.tmp >${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc + COMMAND ${POWERSHELL} -NoProfile -ExecutionPolicy Bypass \"& \"\"${VM_DIR}/h2inc.ps1\"\"\" \"\"\"${VM_DIR}/amd64/asmconstants.h\"\"\" >"${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.tmp" + COMMAND ${CMAKE_CXX_COMPILER} ${DEFINITIONS} /EP "${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.tmp" >"${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc" ) endif (WIN32) diff --git a/tests/buildtest.cmd b/tests/buildtest.cmd index 21e1fc366e..e4440ddfb9 100644 --- a/tests/buildtest.cmd +++ b/tests/buildtest.cmd @@ -1,7 +1,7 @@ @echo off -setlocal +setlocal EnableDelayedExpansion -set __ProjectFilesDir=%~dp0 +set "__ProjectFilesDir=%~dp0" :Arg_Loop if "%1" == "" goto ArgsDone if /i "%1" == "x64" (set __BuildArch=x64&shift&goto Arg_Loop) @@ -19,16 +19,16 @@ goto Usage if not defined __BuildArch set __BuildArch=x64 if not defined __BuildType set __BuildType=debug -if not defined __TestWorkingDir set __TestWorkingDir=%__ProjectFilesDir%\..\binaries\tests\%__BuildArch%\%__BuildType% +if not defined __TestWorkingDir set "__TestWorkingDir=%__ProjectFilesDir%\..\binaries\tests\%__BuildArch%\%__BuildType%" -if not defined __LogsDir set __LogsDir=%__ProjectFilesDir%..\binaries\Logs +if not defined __LogsDir set "__LogsDir=%__ProjectFilesDir%..\binaries\Logs" -set __TestBuildLog=%__LogsDir%\Tests_%__BuildArch%__%__BuildType%.log -set __XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildArch%__%__BuildType%.log +set "__TestBuildLog=%__LogsDir%\Tests_%__BuildArch%__%__BuildType%.log" +set "__XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildArch%__%__BuildType%.log" :: Switch to clean build mode if the binaries output folder does not exist -if not exist %__TestWorkingDir% set __CleanBuild=1 -if not exist %__LogsDir% md %__LogsDir% +if not exist "%__TestWorkingDir%" set __CleanBuild=1 +if not exist "%__LogsDir%" md "%__LogsDir%" :: Configure environment if we are doing a clean build. if not defined __CleanBuild goto CheckPrereqs @@ -39,7 +39,7 @@ echo. set __MSBCleanBuildArgs=/t:rebuild :: Cleanup the binaries drop folder -if exist %__TestWorkingDir% rd /s /q %__TestWorkingDir% +if exist "%__TestWorkingDir%" rd /s /q "%__TestWorkingDir%" :: Note: We've disabled node reuse because it causes file locking issues. @@ -87,7 +87,7 @@ goto :eof :build %_buildprefix% %_msbuildexe% "%__ProjectFilesDir%build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestBuildLog%";Append %* %_buildpostfix% -IF ERRORLEVEL 1 echo Test build failed. Refer %__TestBuildLog% for details && exit /b 1 +IF ERRORLEVEL 1 echo Test build failed. Refer !__TestBuildLog! for details && exit /b 1 |