Skip to content

Commit

Permalink
iss #23: Build.bat supports internal commands
Browse files Browse the repository at this point in the history
  • Loading branch information
renestein committed Feb 22, 2021
1 parent 9a32677 commit 9cccae4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
36 changes: 36 additions & 0 deletions RStein.AsyncCpp/RStein.AsyncCpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(VcpkgRoot)debug\lib\manual-link\gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_ClangWin|Win32'">
<ClCompile>
Expand All @@ -284,6 +287,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(VcpkgRoot)debug\lib\manual-link\gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_VSAWAIT|Win32'">
<ClCompile>
Expand All @@ -303,6 +309,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(VcpkgRoot)debug\lib\manual-link\gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand All @@ -322,6 +331,9 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_ClangWin|x64'">
<ClCompile>
Expand All @@ -338,6 +350,9 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_VSAWAIT|x64'">
<ClCompile>
Expand All @@ -356,6 +371,9 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand All @@ -376,6 +394,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(VcpkgRoot)lib\manual-link\gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_CLangWin|Win32'">
<ClCompile>
Expand All @@ -400,6 +421,9 @@
<Lib>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_VSAWAIT|Win32'">
<ClCompile>
Expand All @@ -421,6 +445,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(VcpkgRoot)lib\manual-link\gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -442,6 +469,9 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_CLangWin|x64'">
<ClCompile>
Expand All @@ -465,6 +495,9 @@
<Lib>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_VSAWAIT|x64'">
<ClCompile>
Expand All @@ -485,6 +518,9 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>if True==$(BuildingInsideVisualStudio) $(SolutionDir)build.bat INTERNAL_GENERATE_HEADERS</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Actors\IActor.cpp" />
Expand Down
31 changes: 29 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ set CPP_HEADERS_FOLDER=bin\libs\includes\asynccpp
set RSTEIN_ASYNC_LIB_FOLDER=RStein.AsyncCpp

set TARGET=%1
rem internal commands
if "%TARGET%"=="INTERNAL_GENERATE_HEADERS" goto internal_command_regenerate_headers

goto public_commands
rem end internal commands

rem internal commands handlers
:internal_command_regenerate_headers
cd %~dp0
if exist "%CPP_HEADERS_FOLDER%" rmdir /q /s "%CPP_HEADERS_FOLDER%"
mkdir "%CPP_HEADERS_FOLDER%"
xcopy "%RSTEIN_ASYNC_LIB_FOLDER%\*.h" "%CPP_HEADERS_FOLDER%" /s /y
exit /b 0
rem end internal commands handlers

:public_commands
if "%TARGET%"=="" set TARGET=%LIB_WIN_CL_STD20_AWAIT%
if not "%TARGET%"=="%LIB_WIN_CL_STD20_AWAIT%" (
if not "%TARGET%"=="%LIB_WIN_CL_LEGACY_AWAIT%" (
Expand All @@ -21,6 +37,8 @@ if not exist "%VS_LOCATION%vcvars32.bat" (
exit /b ERROR_NO_VS
)



echo Preparing build environment. Calling vcvars32.bat.
call "%VS_LOCATION%vcvars32.bat"
if %ERRORLEVEL% NEQ 0 goto build_failed
Expand Down Expand Up @@ -54,11 +72,18 @@ echo Deleting old header files.

if exist "%CPP_HEADERS_FOLDER%" rmdir /q /s "%CPP_HEADERS_FOLDER%"

:build_projects
:clean_projects
echo Cleaning previous builds.
Msbuild "RStein.AsyncCppLib.sln" /t:clean
Msbuild "RStein.AsyncCppLib.sln" /p:configuration=%RELEASE_CONFIGURATION% /p:platform=x64 /t:clean
if %ERRORLEVEL% NEQ 0 goto build_failed
Msbuild "RStein.AsyncCppLib.sln" /p:configuration=%DEBUG_CONFIGURATION% /p:platform=x64 /t:clean
if %ERRORLEVEL% NEQ 0 goto build_failed
Msbuild "RStein.AsyncCppLib.sln" /p:configuration=%RELEASE_CONFIGURATION% /p:platform=x86 /t:clean
if %ERRORLEVEL% NEQ 0 goto build_failed
Msbuild "RStein.AsyncCppLib.sln" /p:configuration=%DEBUG_CONFIGURATION% /p:platform=x86 /t:clean
if %ERRORLEVEL% NEQ 0 goto build_failed

:build_projects
echo Building: Platform=x64 Configuration=%RELEASE_CONFIGURATION%.
msbuild "RStein.AsyncCppLib.sln" /p:configuration=%RELEASE_CONFIGURATION% /p:platform=x64 /t:build
if %ERRORLEVEL% NEQ 0 goto build_failed
Expand All @@ -77,6 +102,8 @@ if %ERRORLEVEL% NEQ 0 goto build_failed
:create_headers
cd %~dp0
echo Generating header files.
echo.
echo.
if not exist "%CPP_HEADERS_FOLDER%" mkdir "%CPP_HEADERS_FOLDER%"
xcopy "%RSTEIN_ASYNC_LIB_FOLDER%\*.h" "%CPP_HEADERS_FOLDER%" /s /y
echo.
Expand Down

0 comments on commit 9cccae4

Please sign in to comment.