diff options
author | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-26 22:48:11 +0000 |
---|---|---|
committer | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-26 22:48:11 +0000 |
commit | a24417742faf535b1a616984b03dcf8258b9f818 (patch) | |
tree | e85877b99462ef492f9be32312a3bcde4c434184 /native_client_sdk | |
parent | 1c76dc3ca13fee61d2e3e1a6e4eab104a4a43c3e (diff) | |
download | chromium_src-a24417742faf535b1a616984b03dcf8258b9f818.zip chromium_src-a24417742faf535b1a616984b03dcf8258b9f818.tar.gz chromium_src-a24417742faf535b1a616984b03dcf8258b9f818.tar.bz2 |
add dependancy generatation to generated Makefiles
This is implemented by passing -MMD to gcc and then including the
generated .d files in the Makefile.
BUG=139161
TEST=
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/10821050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/generate_make.py | 33 | ||||
-rwxr-xr-x | native_client_sdk/src/build_tools/make_rules.py | 10 |
2 files changed, 24 insertions, 19 deletions
diff --git a/native_client_sdk/src/build_tools/generate_make.py b/native_client_sdk/src/build_tools/generate_make.py index ac7d01c..66cf47f 100755 --- a/native_client_sdk/src/build_tools/generate_make.py +++ b/native_client_sdk/src/build_tools/generate_make.py @@ -27,7 +27,7 @@ import getos SUPPORTED_HOSTS = ['win'] def ErrorExit(text): - sys.stderr.write(text + '\n') + ErrorMsgFunc(text) sys.exit(1) @@ -87,7 +87,7 @@ def GetSourcesDict(sources): else: source_map[key] = [] return source_map - + def GetPlatforms(plat_list, plat_filter): platforms = [] @@ -101,7 +101,7 @@ def GenerateToolDefaults(desc, tools): defaults = '' for tool in tools: defaults += BUILD_RULES[tool]['DEFS'] - return defaults + return defaults def GenerateSettings(desc, tools): @@ -137,7 +137,7 @@ def GenerateCompile(target, tool, arch, srcs): For the given target, toolset and architecture, returns a rule to generate the object files for the set of sources. - + Returns: Returns a tuple containin the objects and the rule. """ @@ -159,6 +159,7 @@ def GenerateCompile(target, tool, arch, srcs): compile_rule = GetBuildRule(tool, 'CXX') rules += Replace(compile_rule, replace) object_sets.append('$(%s)' % replace['<OBJS>']) + return (' '.join(object_sets), rules) @@ -168,13 +169,13 @@ def GenerateLink(target, tool, arch, objs): Returns: Returns a tuple containing the rule and target. """ - targ_type = target['TYPE'] + targ_type = target['TYPE'] link_rule = GetBuildRule(tool, targ_type.upper()) libs = target.get('LIBS', []) libs = BuildLibList(tool, libs) replace = BuildToolDict(tool, target['NAME'], arch, 'nexe', OBJS=objs, LIBLIST=libs) - rule = Replace(link_rule, replace) + rule = Replace(link_rule, replace) target_out = GetTarget(tool, targ_type, replace) return target_out, rule @@ -213,11 +214,11 @@ def GenerateRules(desc, tools): targs, nmf_rule = GenerateNMF(main, tc) rules += nmf_rule all_targets.append(targs) - rules += '\n.PHONY : clean\nclean:\n\t$(RM) ' + ' '.join(clean) + rules += '\n.PHONY : clean\nclean:\n\t$(RM) $(DEPFILES) ' + ' '.join(clean) + rules += '\n\n-include $(DEPFILES)' return ' '.join(all_targets), rules - def GenerateTargets(desc, tools): targets = [] rules = '' @@ -257,7 +258,6 @@ def GenerateReplacements(desc, tools): } - # 'KEY' : ( <TYPE>, [Accepted Values], <Required?>) DSC_FORMAT = { 'TOOLS' : (list, ['newlib', 'glibc', 'pnacl', 'win'], True), @@ -310,7 +310,7 @@ def ValidateFormat(src, format, ErrorMsg=ErrorMsgFunc): continue exp_type, exp_value, required = format[key] - value = src[key] + value = src[key] # Verify the key is of the expected type if exp_type != type(value): @@ -409,7 +409,7 @@ def IsNexe(desc): def ProcessHTML(srcroot, dstroot, desc, toolchains): name = desc['NAME'] outdir = os.path.join(dstroot, desc['DEST'], name) - + srcfile = os.path.join(srcroot, 'index.html') tools = GetPlatforms(toolchains, desc['TOOLS']) for tool in tools: @@ -426,17 +426,17 @@ def ProcessHTML(srcroot, dstroot, desc, toolchains): srcfile = os.path.join(SDK_SRC_DIR, 'build_tools', 'redirect.html') dstfile = os.path.join(outdir, 'index.html') WriteReplaced(srcfile, dstfile, replace) - + def LoadProject(filename, toolchains): - """Generate a Master Makefile that builds all examples. + """Generate a Master Makefile that builds all examples. Load a project desciption file, verifying it conforms and checking if it matches the set of requested toolchains. Return None if the project is filtered out.""" print '\n\nProcessing %s...' % filename - # Default src directory is the directory the description was found in + # Default src directory is the directory the description was found in desc = open(filename, 'r').read() desc = eval(desc, {}, {}) @@ -511,7 +511,7 @@ def GenerateMasterMakefile(in_path, out_path, projects): outdir = os.path.dirname(os.path.abspath(out_path)) pepperdir = os.path.dirname(outdir) AddMakeBat(pepperdir, outdir) - + def main(argv): parser = optparse.OptionParser() @@ -541,6 +541,9 @@ def main(argv): if options.host: toolchains.append(platform) + if not args: + ErrorExit('Please specify one or more projects to generate Makefiles for.') + # By default support newlib and glibc if not toolchains: toolchains = ['newlib', 'glibc'] diff --git a/native_client_sdk/src/build_tools/make_rules.py b/native_client_sdk/src/build_tools/make_rules.py index 8c6f00e..a7d4158 100755 --- a/native_client_sdk/src/build_tools/make_rules.py +++ b/native_client_sdk/src/build_tools/make_rules.py @@ -12,7 +12,7 @@ NEWLIB_CC?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-gcc -c NEWLIB_CXX?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -c -std=gnu++98 NEWLIB_LINK?=$(TC_PATH)/$(OSNAME)_x86_newlib/bin/i686-nacl-g++ -Wl,-as-needed NEWLIB_DUMP?=$(TC_PATH)/$(OSNAME)_x86_newlib/x86_64-nacl/bin/objdump -NEWLIB_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) +NEWLIB_CCFLAGS?=-O0 -MMD -g -pthread $(NACL_WARNINGS) NEWLIB_LDFLAGS?=-g -pthread """ @@ -23,7 +23,7 @@ GLIBC_LINK?=$(TC_PATH)/$(OSNAME)_x86_glibc/bin/i686-nacl-g++ -Wl,-as-needed GLIBC_DUMP?=$(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/bin/objdump GLIBC_PATHS:=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib32 GLIBC_PATHS+=-L $(TC_PATH)/$(OSNAME)_x86_glibc/x86_64-nacl/lib -GLIBC_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) +GLIBC_CCFLAGS?=-O0 -MMD -g -pthread $(NACL_WARNINGS) GLIBC_LDFLAGS?=-g -pthread """ @@ -33,7 +33,7 @@ PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c -std=gnu++ PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ PNACL_DUMP?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/objdump PNACL_CCFLAGS?=-O0 -g -pthread $(NACL_WARNINGS) -PNACL_LDFLAGS?=-g -pthread +PNACL_CCFLAGS?=-O0 -MMD -g -pthread $(NACL_WARNINGS) TRANSLATE:=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-translate """ @@ -51,12 +51,14 @@ WIN_LDFLAGS=/LIBPATH:$(NACL_SDK_ROOT)/lib/win_x86_32_host # NACL_CC_RULE = """ <OBJS>:=$(patsubst %.<ext>, <tc>/%_<ARCH>.o,$(<PROJ>_<EXT>)) +DEPFILES+=$(<OBJS>:.o=.d) $(<OBJS>) : <tc>/%_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc> <TAB>$(<CC>) -o $@ $< <MACH> $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> """ SO_CC_RULE = """ <OBJS>:=$(patsubst %.<ext>, <tc>/%_<ARCH>.o,$(<PROJ>_<EXT>)) +DEPFILES+=$(<OBJS>:.o=.d) $(<OBJS>) : <tc>/%_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc> <TAB>$(<CC>) -o $@ $< <MACH> -fPIC $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> """ @@ -271,7 +273,7 @@ def BuildToolDict(toolchain, project, arch = {}, ext='nexe', **kwargs): # Add other passed in replacements for key in kwargs: replace['<%s>' % key] = kwargs[key] - + if '<OBJS>' not in replace: if replace.get('<ARCH>', ''): replace['<OBJS>'] = '%s_%s_%s_%s_O' % (TC, PROJ, replace['<ARCH>'], EXT) |