| Index: grit/tool/build.py
|
| diff --git a/grit/tool/build.py b/grit/tool/build.py
|
| index 68245a343476faa07441fca7fa163a15d33a48e5..f5254bf14ad68964460c89d7b730635cc9d7af00 100644
|
| --- a/grit/tool/build.py
|
| +++ b/grit/tool/build.py
|
| @@ -116,7 +116,11 @@ Options:
|
| systems to realize that dependent build steps might be
|
| unnecessary, at the cost of comparing the output data at
|
| grit time.
|
| -
|
| +
|
| + --depend-on-stamp
|
| + If specified along with --depfile and --depdir, the depfile
|
| + generated will depend on a stampfile instead of the first
|
| + output in the input .grd file.
|
|
|
| Conditional inclusion of resources only affects the output of files which
|
| control which resources get linked into a binary, e.g. it affects .rc files
|
| @@ -139,10 +143,12 @@ are exported to translation interchange files (e.g. XMB files), etc.
|
| rc_header_format = None
|
| output_all_resource_defines = None
|
| write_only_new = False
|
| + depend_on_stamp = False
|
| (own_opts, args) = getopt.getopt(args, 'a:o:D:E:f:w:t:h:',
|
| ('depdir=','depfile=','assert-file-list=',
|
| 'output-all-resource-defines',
|
| 'no-output-all-resource-defines',
|
| + 'depend-on-stamp',
|
| 'write-only-new='))
|
| for (key, val) in own_opts:
|
| if key == '-a':
|
| @@ -179,6 +185,8 @@ are exported to translation interchange files (e.g. XMB files), etc.
|
| depfile = val
|
| elif key == '--write-only-new':
|
| write_only_new = val != '0'
|
| + elif key == '--depend-on-stamp':
|
| + depend_on_stamp = True
|
|
|
| if len(args):
|
| print 'This tool takes no tool-specific arguments.'
|
| @@ -225,7 +233,7 @@ are exported to translation interchange files (e.g. XMB files), etc.
|
| return 2
|
|
|
| if depfile and depdir:
|
| - self.GenerateDepfile(depfile, depdir, first_ids_file)
|
| + self.GenerateDepfile(depfile, depdir, first_ids_file, depend_on_stamp)
|
|
|
| return 0
|
|
|
| @@ -424,7 +432,7 @@ Extra output files:
|
| return True
|
|
|
|
|
| - def GenerateDepfile(self, depfile, depdir, first_ids_file):
|
| + def GenerateDepfile(self, depfile, depdir, first_ids_file, depend_on_stamp):
|
| '''Generate a depfile that contains the imlicit dependencies of the input
|
| grd. The depfile will be in the same format as a makefile, and will contain
|
| references to files relative to |depdir|. It will be put in |depfile|.
|
| @@ -446,7 +454,9 @@ Extra output files:
|
| gen/blah.h: ../src/input1.xtb ../src/input2.xtb
|
|
|
| Where "gen/blah.h" is the first output (Ninja expects the .d file to list
|
| - the first output in cases where there is more than one).
|
| + the first output in cases where there is more than one). If the flag
|
| + --depend-on-stamp is specified, "gen/blah.rd.d.stamp" will be used that is
|
| + 'touched' whenever a new depfile is generated.
|
|
|
| Note that all paths in the depfile are relative to ../out, the depdir.
|
| '''
|
| @@ -458,11 +468,18 @@ Extra output files:
|
| if first_ids_file is not None:
|
| infiles.append(first_ids_file)
|
|
|
| - # Get the first output file relative to the depdir.
|
| - outputs = self.res.GetOutputFiles()
|
| - output_file = os.path.relpath(os.path.join(
|
| - self.output_directory, outputs[0].GetFilename()), depdir)
|
| + if (depend_on_stamp):
|
| + output_file = depfile + ".stamp"
|
| + # Touch the stamp file before generating the depfile.
|
| + with open(output_file, 'a'):
|
| + os.utime(output_file, None)
|
| + else:
|
| + # Get the first output file relative to the depdir.
|
| + outputs = self.res.GetOutputFiles()
|
| + output_file = os.path.join(self.output_directory,
|
| + outputs[0].GetFilename())
|
|
|
| + output_file = os.path.relpath(output_file, depdir)
|
| # The path prefix to prepend to dependencies in the depfile.
|
| prefix = os.path.relpath(os.getcwd(), depdir)
|
| deps_text = ' '.join([os.path.join(prefix, i) for i in infiles])
|
|
|