Visual C++ Builds: Use Custom Build Rules
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 30 Aug 2013 06:47:39 +0000 (14:47 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 30 Aug 2013 06:47:39 +0000 (14:47 +0800)
Use custom build rules in the Visual C++ projects because this enables
that the generated files get automatically regenerated when the associated
source files change and that the generated files can be automatically
removed when "clean" is requested.

Also drop some unneeded items from the property sheets.

build/win32/vs10/atk.props
build/win32/vs10/atk.vcxproj.filtersin
build/win32/vs10/atk.vcxprojin
build/win32/vs9/atk.vcprojin
build/win32/vs9/atk.vsprops

index b4a4c3a..09f42bb 100644 (file)
@@ -4,9 +4,9 @@
     <ApiVersion>1.0</ApiVersion>
     <AtkDummyPrefix>\"/dummy\"</AtkDummyPrefix>
     <VSVer>10</VSVer>
-    <GlibEtcInstallRoot>..\..\..\..\vs$(VSVer)\$(Platform)</GlibEtcInstallRoot>
-    <GlibEtcInstallRootFromBuildWin32>..\..\..\vs$(VSVer)\$(Platform)</GlibEtcInstallRootFromBuildWin32>
+    <GlibEtcInstallRoot>$(SolutionDir)\..\..\..\..\vs$(VSVer)\$(Platform)</GlibEtcInstallRoot>
     <CopyDir>$(GLibEtcInstallRoot)</CopyDir>
+    <DefDir>$(SolutionDir)$(Configuration)\$(PlatformName)\obj\$(ProjectName)\</DefDir>
     <AtkDoInstall>
 mkdir $(CopyDir)\bin
 
@@ -89,13 +89,30 @@ copy $(SolutionDir)$(Configuration)\$(Platform)\bin\*-$(ApiVersion).lib $(CopyDi
 set VSVER=$(VSVer)
 set CONF=$(Configuration)
 set PLAT=$(Platform)
-set BASEDIR=$(GlibEtcInstallRootFromBuildWin32)
+set BASEDIR=$(GlibEtcInstallRoot)
 cd ..
 call gengir.bat
 
 cd vs$(VSVer)
 </DoGenGir>
-    <GenerateAtkDef>echo EXPORTS &gt;"..\..\..\atk\atk.def" &amp;&amp; cl /EP ..\..\..\atk\atk.symbols &gt;&gt;"..\..\..\atk\atk.def"</GenerateAtkDef>
+    <GenMarshalSrc>
+if exist ..\..\..\atk\atkmarshal.h goto DONE_GEN_MARS_H
+cd ..\..\..\atk
+$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal atkmarshal.list --header &gt; atkmarshal.h
+cd $(SolutionDir)
+
+:DONE_GEN_MARS_H
+if exist ..\..\..\atk\atkmarshal.c goto DONE_GEN_MARS_C
+cd ..\..\..\atk
+$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal atkmarshal.list --body &gt; atkmarshal.c
+cd $(SolutionDir)
+
+:DONE_GEN_MARS_C
+    </GenMarshalSrc>
+    <GenerateAtkDef>
+echo EXPORTS &gt; $(DefDir)\atk.def
+cl /EP ..\..\..\atk\atk.symbols &gt;&gt; $(DefDir)\atk.def
+    </GenerateAtkDef>
     <AtkDefines>ATK_COMPILATION;DLL_EXPORT;ATK_LOCALEDIR="$(AtkDummyPrefix)/share/locale"</AtkDefines>
     <AtkLibtoolCompatibleDllPrefix>lib</AtkLibtoolCompatibleDllPrefix>
     <AtkLibtoolCompatibleDllSuffix>-1.0-0</AtkLibtoolCompatibleDllSuffix>
@@ -126,20 +143,7 @@ if exist ..\..\..\config.h goto DONE_CONFIG_H
 copy ..\..\..\config.h.win32 ..\..\..\config.h
 
 :DONE_CONFIG_H
-
-if exist ..\..\..\atk\atkmarshal.h goto GEN_MARS_C
-
-$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkmarshal.list --header &gt;..\..\..\atk\atkmarshal.h
-
-:GEN_MARS_C
-
-if exist ..\..\..\atk\atkmarshal.c goto END
-
-$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkmarshal.list --body &gt;..\..\..\atk\atkmarshal.c
-
-:END
-
-</Command>
+      </Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
@@ -155,9 +159,15 @@ $(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkm
     <BuildMacro Include="CopyDir">
       <Value>$(CopyDir)</Value>
     </BuildMacro>
+    <BuildMacro Include="DefDir">
+      <Value>$(DefDir)</Value>
+    </BuildMacro>
     <BuildMacro Include="AtkDoInstall">
       <Value>$(AtkDoInstall)</Value>
     </BuildMacro>
+    <BuildMacro Include="GenMarshalSrc">
+      <Value>$(GenMarshalSrc)</Value>
+    </BuildMacro>
     <BuildMacro Include="GenerateAtkDef">
       <Value>$(GenerateAtkDef)</Value>
     </BuildMacro>
index cef25b9..07395b7 100644 (file)
 #include "libatk.vs10.sourcefiles.filters"
   </ItemGroup>
   <ItemGroup>
+    <CustomBuild Include="..\..\..\atk\atkmarshal.list"><Filter>Resource Files</Filter></CustomBuild>
+    <CustomBuild Include="..\..\..\atk\atk.symbols"><Filter>Resource Files</Filter></CustomBuild>
+  </ItemGroup>
+  <ItemGroup>
     <ResourceCompile Include="..\..\..\atk\atk.rc">
       <Filter>Resource Files</Filter>
     </ResourceCompile>
index c156087..a52baf7 100644 (file)
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
     </ClCompile>
-    <PreLinkEvent>
-      <Command>$(GenerateAtkDef)</Command>
-    </PreLinkEvent>
     <Link>
       <OutputFile>$(OutDir)$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll</OutputFile>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <ModuleDefinitionFile>..\..\..\atk\atk.def</ModuleDefinitionFile>
+      <ModuleDefinitionFile>$(IntDir)\atk.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(OutDir)$(ProjectName)-$(ApiVersion).lib</ImportLibrary>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
-    <PreLinkEvent>
-      <Command>$(GenerateAtkDef)</Command>
-    </PreLinkEvent>
     <Link>
       <OutputFile>$(OutDir)$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll</OutputFile>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
-      <ModuleDefinitionFile>..\..\..\atk\atk.def</ModuleDefinitionFile>
+      <ModuleDefinitionFile>$(IntDir)\atk.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
       <OptimizeReferences>true</OptimizeReferences>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
-    <PreLinkEvent>
-      <Command>$(GenerateAtkDef)</Command>
-    </PreLinkEvent>
     <Link>
       <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll</OutputFile>
-      <ModuleDefinitionFile>..\..\..\atk\atk.def</ModuleDefinitionFile>
+      <ModuleDefinitionFile>$(IntDir)\atk.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
       <ImportLibrary>$(TargetDir)$(ProjectName)-$(ApiVersion).lib</ImportLibrary>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
     </ClCompile>
-    <PreLinkEvent>
-      <Command>$(GenerateAtkDef)</Command>
-    </PreLinkEvent>
     <Link>
       <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(OutDir)$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll</OutputFile>
-      <ModuleDefinitionFile>..\..\..\atk\atk.def</ModuleDefinitionFile>
+      <ModuleDefinitionFile>$(IntDir)\atk.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
       <OptimizeReferences>true</OptimizeReferences>
 #include "libatk.vs10.sourcefiles"
   </ItemGroup>
   <ItemGroup>
+    <CustomBuild Include="..\..\..\atk\atkmarshal.list">
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating Marshalling Sources...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(GenMarshalSrc)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generating Marshalling Sources...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(GenMarshalSrc)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Generating Marshalling Sources...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(GenMarshalSrc)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generating Marshalling Sources...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GenMarshalSrc)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c;%(Outputs)</Outputs>
+    </CustomBuild>
+    <CustomBuild Include="..\..\..\atk\atk.symbols">
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating atk.def...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(GenerateAtkDef)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)atk.def;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generating atk.def...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(GenerateAtkDef)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)atk.def;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Generating atk.def...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(GenerateAtkDef)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)atk.def;%(Outputs)</Outputs>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generating atk.def...</Message>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GenerateAtkDef)</Command>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)atk.def;%(Outputs)</Outputs>
+    </CustomBuild>
+  </ItemGroup>
+  <ItemGroup>
     <ResourceCompile Include="..\..\..\atk\atk.rc" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
index 1cd6313..8a9fbc5 100644 (file)
                                DebugInformationFormat="4"
                        />
                        <Tool
-                               Name="VCPreLinkEventTool"
-                               CommandLine="$(GenerateAtkDef)"
-                       />
-                       <Tool
                                Name="VCLinkerTool"
                                OutputFile="$(OutDir)\$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll"
                                LinkIncremental="2"
                                IgnoreDefaultLibraryNames=""
-                               ModuleDefinitionFile="..\..\..\atk\atk.def"
+                               ModuleDefinitionFile="$(IntDir)\atk.def"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                ImportLibrary="$(OutDir)\$(ProjectName)-$(ApiVersion).lib"
                                DebugInformationFormat="3"
                        />
                        <Tool
-                               Name="VCPreLinkEventTool"
-                               CommandLine="$(GenerateAtkDef)"
-                       />
-                       <Tool
                                Name="VCLinkerTool"
                                OutputFile="$(OutDir)\$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll"
                                LinkIncremental="1"
                                IgnoreDefaultLibraryNames=""
-                               ModuleDefinitionFile="..\..\..\atk\atk.def"
+                               ModuleDefinitionFile="$(IntDir)\atk.def"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                OptimizeReferences="2"
                                DebugInformationFormat="3"
                        />
                        <Tool
-                               Name="VCPreLinkEventTool"
-                               CommandLine="$(GenerateAtkDef)"
-                       />
-                       <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies=""
                                OutputFile="$(OutDir)\$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll"
                                LinkIncremental="2"
-                               ModuleDefinitionFile="..\..\..\atk\atk.def"
+                               ModuleDefinitionFile="$(IntDir)\atk.def"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                ImportLibrary="$(TargetDir)$(ProjectName)-$(ApiVersion).lib"
                                DebugInformationFormat="3"
                        />
                        <Tool
-                               Name="VCPreLinkEventTool"
-                               CommandLine="$(GenerateAtkDef)"
-                       />
-                       <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies=""
                                OutputFile="$(OutDir)\$(AtkDllPrefix)$(ProjectName)$(AtkDllSuffix).dll"
                                LinkIncremental="2"
-                               ModuleDefinitionFile="..\..\..\atk\atk.def"
+                               ModuleDefinitionFile="$(IntDir)\atk.def"
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                OptimizeReferences="2"
                        Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
                        UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
                        >
+                       <File RelativePath="..\..\..\atk\atkmarshal.list">
+                               <FileConfiguration Name="Debug|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating Marshalling Sources..."
+                                               CommandLine="$(GenMarshalSrc)"
+                                               Outputs="..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Release|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating Marshalling Sources..."
+                                               CommandLine="$(GenMarshalSrc)"
+                                               Outputs="..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Debug|x64">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating Marshalling Sources..."
+                                               CommandLine="$(GenMarshalSrc)"
+                                               Outputs="..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Release|x64">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating Marshalling Sources..."
+                                               CommandLine="$(GenMarshalSrc)"
+                                               Outputs="..\..\..\atk\atkmarshal.h;..\..\..\atk\atkmarshal.c"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File RelativePath="..\..\..\atk\atk.symbols">
+                               <FileConfiguration Name="Debug|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating atk.def..."
+                                               CommandLine="$(GenerateAtkDef)"
+                                               Outputs="$(IntDir)\atk.def"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Release|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating atk.def..."
+                                               CommandLine="$(GenerateAtkDef)"
+                                               Outputs="$(IntDir)\atk.def"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Debug|x64">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating atk.def..."
+                                               CommandLine="$(GenerateAtkDef)"
+                                               Outputs="$(IntDir)\atk.def"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration Name="Release|x64">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating atk.def..."
+                                               CommandLine="$(GenerateAtkDef)"
+                                               Outputs="$(IntDir)\atk.def"
+                                       />
+                               </FileConfiguration>
+                       </File>
                        <File RelativePath="..\..\..\atk\atk.rc" />
                </Filter>
        </Files>
index 9cf21f4..61273f9 100644 (file)
 if exist ..\..\..\config.h goto DONE_CONFIG_H&#x0D;&#x0A;
 copy ..\..\..\config.h.win32 ..\..\..\config.h&#x0D;&#x0A;
 :DONE_CONFIG_H&#x0D;&#x0A;
-if exist ..\..\..\atk\atkmarshal.h goto GEN_MARS_C&#x0D;&#x0A;
-$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkmarshal.list --header >..\..\..\atk\atkmarshal.h&#x0D;&#x0A;
-:GEN_MARS_C&#x0D;&#x0A;
-if exist ..\..\..\atk\atkmarshal.c goto END&#x0D;&#x0A;
-$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkmarshal.list --body >..\..\..\atk\atkmarshal.c&#x0D;&#x0A;
-:END&#x0D;&#x0A;
 "
        />
        <UserMacro
@@ -37,11 +31,11 @@ $(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal ..\..\..\atk\atkm
        />
        <UserMacro
                Name="GLibEtcInstallRoot"
-               Value="..\..\..\..\vs$(VSVER)\$(PlatformName)"
+               Value="$(SolutionDir)\..\..\..\..\vs$(VSVER)\$(PlatformName)"
        />
        <UserMacro
-               Name="GlibEtcInstallRootFromBuildWin32"
-               Value="..\..\..\vs$(VSVer)\$(PlatformName)"
+               Name="DefDir"
+               Value="$(SolutionDir)$(ConfigurationName)\$(PlatformName)\obj\$(ProjectName)"
        />
        <UserMacro
                Name="ApiVersion"
@@ -97,12 +91,29 @@ copy $(SolutionDir)$(ConfigurationName)\$(PlatformName)\bin\*-$(ApiVersion).lib
 "
        />
        <UserMacro
+               Name="GenMarshalSrc"
+               Value="
+if exist ..\..\..\atk\atkmarshal.h goto DONE_GEN_MARS_H&#x0D;&#x0A;
+cd ..\..\..\atk&#x0D;&#x0A;
+$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal atkmarshal.list --header &gt; atkmarshal.h&#x0D;&#x0A;
+cd $(SolutionDir)&#x0D;&#x0A;
+
+:DONE_GEN_MARS_H&#x0D;&#x0A;
+if exist ..\..\..\atk\atkmarshal.c goto DONE_GEN_MARS_C&#x0D;&#x0A;
+cd ..\..\..\atk&#x0D;&#x0A;
+$(GLibEtcInstallRoot)\bin\glib-genmarshal --prefix=atk_marshal atkmarshal.list --body &gt; atkmarshal.c&#x0D;&#x0A;
+cd $(SolutionDir)&#x0D;&#x0A;
+
+:DONE_GEN_MARS_C&#x0D;&#x0A;
+                     "
+       />
+       <UserMacro
                Name="DoGenGir"
                Value="
 set VSVER=$(VSVer)&#x0D;&#x0A;
 set CONF=$(ConfigurationName)&#x0D;&#x0A;
 set PLAT=$(PlatformName)&#x0D;&#x0A;
-set BASEDIR=$(GlibEtcInstallRootFromBuildWin32)&#x0D;&#x0A;
+set BASEDIR=$(GLibEtcInstallRoot)&#x0D;&#x0A;
 
 cd ..&#x0D;&#x0A;
 call gengir.bat&#x0D;&#x0A;
@@ -111,7 +122,10 @@ cd vs$(VSVer)&#x0D;&#x0A;
        />
        <UserMacro
                Name="GenerateAtkDef"
-               Value="echo EXPORTS &gt;&quot;..\..\..\atk\atk.def&quot; &amp;&amp; cl /EP ..\..\..\atk\atk.symbols &gt;&gt;&quot;..\..\..\atk\atk.def&quot;"
+               Value="
+echo EXPORTS &gt; $(DefDir)\atk.def&#x0D;&#x0A;
+cl /EP ..\..\..\atk\atk.symbols &gt;&gt; $(DefDir)\atk.def
+                     "
        />
        <UserMacro
                Name="AtkDefines"