diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 21:20:14 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 21:20:14 +0000 |
commit | e6ff63ce883c6631405f22b6630e3ab6455cc3a1 (patch) | |
tree | dccf4e6196ca9e42fe23eef742aa35f457cdf02e | |
parent | 9e932ff8917a84af838160f1c5e88597d9159e92 (diff) | |
download | chromium_src-e6ff63ce883c6631405f22b6630e3ab6455cc3a1.zip chromium_src-e6ff63ce883c6631405f22b6630e3ab6455cc3a1.tar.gz chromium_src-e6ff63ce883c6631405f22b6630e3ab6455cc3a1.tar.bz2 |
Have net_resources.grd generate a .pak file too. Since the tld
data is generated and included in the .pak file, we need to add
a dependency in the SCons build. Making the corresponding
changes to mac/win is harder, so punting for now.
Review URL: http://codereview.chromium.org/18127
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8220 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/net_resources.grd | 1 | ||||
-rw-r--r-- | net/net_resources.scons | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/grit/grit/format/data_pack.py | 3 | ||||
-rw-r--r-- | tools/grit/grit/node/include.py | 12 | ||||
-rw-r--r-- | tools/grit/grit/tool/build.py | 8 |
5 files changed, 28 insertions, 9 deletions
diff --git a/net/base/net_resources.grd b/net/base/net_resources.grd index 655b785ca..ee8ce4d 100644 --- a/net/base/net_resources.grd +++ b/net/base/net_resources.grd @@ -5,6 +5,7 @@ <emit emit_type='prepend'></emit> </output> <output filename="net_resources.rc" type="rc_all" /> + <output filename="net_resources.pak" type="data_package" /> </outputs> <translations /> <release seq="1"> diff --git a/net/net_resources.scons b/net/net_resources.scons index a9d8143..a48a654 100644 --- a/net/net_resources.scons +++ b/net/net_resources.scons @@ -18,18 +18,19 @@ input_files = [ 'tools/tld_cleanup/tld_cleanup$PROGSUFFIX', ] -sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath) -env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')]) -# This dummy target is used to tell the emitter where to put the target files. -generated = env.GRIT('$TARGET_ROOT/grit_derived_sources/dummy_net_res', - 'base/net_resources.grd') - # This dat file needed by net_resources is generated. tld_names_clean = env.Command( '$TARGET_ROOT/grit_derived_sources/effective_tld_names_clean.dat', input_files, '${SOURCES[1]} ${SOURCES[0]} $TARGET') +sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath) +env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')]) +# This dummy target is used to tell the emitter where to put the target files. +generated = env.GRIT('$TARGET_ROOT/grit_derived_sources/dummy_net_res', + ['base/net_resources.grd'] + tld_names_clean) + + if env.Bit('windows'): env.Prepend( RCFLAGS = [ diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py index 1f11a9b..797c23e 100644..100755 --- a/tools/grit/grit/format/data_pack.py +++ b/tools/grit/grit/format/data_pack.py @@ -22,12 +22,13 @@ class DataPack(interface.ItemFormatter): def Format(self, item, lang='en', begin_item=True, output_dir='.'): if not begin_item: return '' + assert isinstance(item, misc.ReleaseNode) nodes = DataPack.GetDataNodes(item) data = {} for node in nodes: - id, value = node.GetDataPackPair() + id, value = node.GetDataPackPair(output_dir) data[id] = value return DataPack.WriteDataPack(data) diff --git a/tools/grit/grit/node/include.py b/tools/grit/grit/node/include.py index d50e7a6..6ff560a 100644 --- a/tools/grit/grit/node/include.py +++ b/tools/grit/grit/node/include.py @@ -6,6 +6,7 @@ '''Handling of the <include> element. ''' +import os import grit.format.rc_header import grit.format.rc @@ -46,16 +47,23 @@ class IncludeNode(base.Node): ''' return self.FilenameToOpen() - def GetDataPackPair(self): + def GetDataPackPair(self, output_dir): '''Returns a (id, string) pair that represents the resource id and raw bytes of the data. This is used to generate the data pack data file. ''' from grit.format import rc_header id_map = rc_header.Item.tids_ id = id_map[self.GetTextualIds()[0]] - file = open(self.FilenameToOpen(), 'rb') + filename = self.FilenameToOpen() + if not os.path.exists(filename): + # Try to open the file relative to the output dir if it's not relative to + # the grd file. + filename = os.path.join(output_dir, self.attrs['file']) + + file = open(filename, 'rb') data = file.read() file.close() + return id, data # static method diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py index 30d2fb3..e2115ee 100644 --- a/tools/grit/grit/tool/build.py +++ b/tools/grit/grit/tool/build.py @@ -156,6 +156,14 @@ are exported to translation interchange files (e.g. XMB files), etc. for output in self.res.GetOutputFiles(): self.VerboseOut('Creating %s...' % output.GetFilename()) + + # Don't build data package files on mac/windows because it's not used and + # there are project dependency issues. We still need to create the file + # to satisfy build dependencies. + if output.GetType() == 'data_package' and sys.platform != 'linux2': + f = open(output.GetOutputFilename(), 'wb') + f.close() + # Microsoft's RC compiler can only deal with single-byte or double-byte # files (no UTF-8), so we make all RC files UTF-16 to support all # character sets. |