summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 17:14:07 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 17:14:07 +0000
commit79a634351d4c69ce9570ab5ec952556347891db7 (patch)
treee43e152e410305fd28c637d990fcf863623c427b /tools
parente7736d75f1a69e8af68ca3d5610bce84c215cf0e (diff)
downloadchromium_src-79a634351d4c69ce9570ab5ec952556347891db7.zip
chromium_src-79a634351d4c69ce9570ab5ec952556347891db7.tar.gz
chromium_src-79a634351d4c69ce9570ab5ec952556347891db7.tar.bz2
Second try of landing chrome_resources project. Changes from last time:
- fix scons dependencies by adding a target for grit/theme_resources.h - fix mac build by adding grit to unittest include path - fix check deps by adding rules for /grit dir. Create a chrome_resources.vcproj that holds grd files that hold non-string resources. Put browser_resources.grd into this vcproj. Port theme_resources.rc/theme_resources.h to theme_resources.grd and put it in the vcproj too. I did a find/replace on the theme_resources include line. Modify grit so header files go in grit_generated_resources/grit/ so the include path can be cleaner. I'll migrate the others in follow up patches. theme_resources.rc had a conditional include of distribution_resources.rc so I had to add support for preprocessor defines to visual studio. Review URL: http://codereview.chromium.org/24011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/grit/build/grit_resource_file.bat15
-rw-r--r--tools/grit/build/grit_resources.rules10
-rw-r--r--tools/grit/grit/scons.py10
-rw-r--r--tools/grit/grit/tool/build.py15
4 files changed, 48 insertions, 2 deletions
diff --git a/tools/grit/build/grit_resource_file.bat b/tools/grit/build/grit_resource_file.bat
index 9769bef..bc5af21 100644
--- a/tools/grit/build/grit_resource_file.bat
+++ b/tools/grit/build/grit_resource_file.bat
@@ -9,11 +9,24 @@ set InFile=%~1
set SolutionDir=%~2
set OutDir=%~3
+:: We treat the next five args as preprocessor defines for grit.
+set PreProc1=%~4
+set PreProc2=%~5
+set PreProc3=%~6
+set PreProc4=%~7
+set PreProc5=%~8
+
IF NOT EXIST %OutDir% (
mkdir %OutDir%
)
+IF NOT (%PreProc1%)==() set PreProc1=-D %PreProc1%
+IF NOT (%PreProc2%)==() set PreProc2=-D %PreProc2%
+IF NOT (%PreProc3%)==() set PreProc3=-D %PreProc3%
+IF NOT (%PreProc4%)==() set PreProc4=-D %PreProc4%
+IF NOT (%PreProc5%)==() set PreProc5=-D %PreProc5%
+
:: Put cygwin in the path
call %SolutionDir%\..\third_party\cygwin\setup_env.bat
-%SolutionDir%\..\third_party\python_24\python.exe %SolutionDir%\..\tools\grit\grit.py -i %InFile% build -o %OutDir%
+%SolutionDir%\..\third_party\python_24\python.exe %SolutionDir%\..\tools\grit\grit.py -i %InFile% build -o %OutDir% %PreProc1% %PreProc2% %PreProc3% %PreProc4% %PreProc5%
diff --git a/tools/grit/build/grit_resources.rules b/tools/grit/build/grit_resources.rules
index 0f1614c..d686fed 100644
--- a/tools/grit/build/grit_resources.rules
+++ b/tools/grit/build/grit_resources.rules
@@ -7,13 +7,21 @@
<CustomBuildRule
Name="GRIT Generated Resources"
DisplayName="GRIT Generated Resources"
- CommandLine="$(SolutionDir)..\tools\grit\build\grit_resource_file.bat [inputs] &quot;$(SolutionDir)&quot; &quot;$(OutDir)\grit_derived_sources&quot;"
+ CommandLine="$(SolutionDir)..\tools\grit\build\grit_resource_file.bat [inputs] &quot;$(SolutionDir)&quot; &quot;$(OutDir)\grit_derived_sources&quot; [AllOptions]"
Outputs="$(OutDir)\grit_derived_sources\$(InputName).h"
AdditionalDependencies="$(SolutionDir)..\tools\grit\build\grit_resource_file.bat;$(SolutionDir)..\tools\grit\grit.py"
FileExtensions="*.grd"
ExecutionDescription="Generating resources..."
>
<Properties>
+ <StringProperty
+ Name="PreprocessorDefinitions"
+ DisplayName="Preprocessor Definitions"
+ Description="Defines a text macro with the given name."
+ Switch="&quot;[value]&quot;"
+ Delimited="true"
+ Inheritable="true"
+ />
</Properties>
</CustomBuildRule>
</Rules>
diff --git a/tools/grit/grit/scons.py b/tools/grit/grit/scons.py
index 89b8837..ba1c6c12f 100644
--- a/tools/grit/grit/scons.py
+++ b/tools/grit/grit/scons.py
@@ -84,10 +84,17 @@ def _Emitter(target, source, env):
target = []
lang_folders = {}
+ # TODO(tc): new_header_output is a hack while we migrate to
+ # grit_derived_sources/grit/ as the new output dir for headers.
+ new_header_output = None
# Add all explicitly-specified output files
for output in grd.GetOutputFiles():
path = os.path.join(base_dir, output.GetFilename())
target.append(path)
+
+ if path.endswith('.h'):
+ path, filename = os.path.split(path)
+ new_header_output = os.path.join(path, 'grit', filename)
if _IsDebugEnabled():
print "GRIT: Added target %s" % path
if output.attrs['lang'] != '':
@@ -108,6 +115,9 @@ def _Emitter(target, source, env):
if _IsDebugEnabled():
print "GRIT: Added target %s" % path
+ if new_header_output:
+ target.append(new_header_output)
+
# GRIT is not thread safe so we should only build one grit target at a time.
# We tell scons about this by making a fake side effect target.
env.SideEffect('grit_lock', target)
diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py
index ab89809..9e45859 100644
--- a/tools/grit/grit/tool/build.py
+++ b/tools/grit/grit/tool/build.py
@@ -10,6 +10,7 @@ SCons build system.
import os
import getopt
import types
+import shutil
import sys
from grit import grd_reader
@@ -189,6 +190,20 @@ are exported to translation interchange files (e.g. XMB files), etc.
self.ProcessNode(self.res, output, outfile)
outfile.close()
+
+ # Generate the header and also put a copy in a grit subdir. We do this
+ # so our include paths can have 'grit' in them.
+ # TODO(tc): Once we transition all the #include lines to have 'grit' in
+ # the path, we can only generate one header.
+ if output.GetType() == 'rc_header':
+ dir_name, header_name = os.path.split(output.GetOutputFilename())
+ dir_name = os.path.join(dir_name, 'grit')
+ try:
+ os.makedirs(dir_name)
+ except OSError, e:
+ pass
+ shutil.copy2(output.GetOutputFilename(),
+ os.path.join(dir_name, header_name))
self.VerboseOut(' done.\n')
# Print warnings if there are any duplicate shortcuts.