Add pre-build step in VS2015 projects to generate config.h from VERSION

This commit is contained in:
Vlad Vissoultchev
2017-02-09 13:31:12 +02:00
parent 5efa75d9b8
commit 910a6bc859
3 changed files with 61 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
set /p VERSION= < %~dp0..\..\VERSION
:config.h
echo> .\config.h #define TCC_VERSION "%VERSION%"
echo>> .\config.h #ifdef TCC_TARGET_X86_64
echo>> .\config.h #define CONFIG_TCC_LIBPATHS "{B}/lib/64;{B}/lib"
echo>> .\config.h #else
echo>> .\config.h #define CONFIG_TCC_LIBPATHS "{B}/lib/32;{B}/lib"
echo>> .\config.h #endif
+30
View File
@@ -71,15 +71,19 @@
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@@ -88,6 +92,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -96,6 +101,12 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@@ -104,6 +115,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -112,6 +124,12 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@@ -132,6 +150,12 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
@@ -152,6 +176,12 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\libtcc.c" /> <ClCompile Include="..\..\libtcc.c" />
+22
View File
@@ -71,15 +71,19 @@
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@@ -88,6 +92,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@@ -98,6 +103,10 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@@ -106,6 +115,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@@ -116,6 +126,10 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
@@ -138,6 +152,10 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
@@ -160,6 +178,10 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..</Command> <Command>copy $(TargetPath) $(SolutionDir)..</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent>
<Command>$(ProjectDir)PreBuild.bat</Command>
<Message>Generate config.h</Message>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\tcc.c" /> <ClCompile Include="..\..\tcc.c" />