| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Notes: | 3 # Notes: |
| 4 # | 4 # |
| 5 # This is all roughly based on the Makefile system used by the Linux | 5 # This is all roughly based on the Makefile system used by the Linux |
| 6 # kernel. | 6 # kernel. |
| 7 # | 7 # |
| 8 # The code below generates a separate .mk file for each target, but | 8 # The code below generates a separate .mk file for each target, but |
| 9 # all are sourced by the top-level Makefile. This means that all | 9 # all are sourced by the top-level Makefile. This means that all |
| 10 # variables in .mk-files clobber one another. Be careful to use := | 10 # variables in .mk-files clobber one another. Be careful to use := |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 deps = [] | 206 deps = [] |
| 207 if 'dependencies' in spec: | 207 if 'dependencies' in spec: |
| 208 deps = [libpaths[dep] for dep in spec['dependencies']] | 208 deps = [libpaths[dep] for dep in spec['dependencies']] |
| 209 libs = filter(lambda dep: dep.endswith('.a'), deps) | 209 libs = filter(lambda dep: dep.endswith('.a'), deps) |
| 210 diff = set(libs) - set(deps) | 210 diff = set(libs) - set(deps) |
| 211 if diff: | 211 if diff: |
| 212 print "Warning: filtered out", diff, "from deps list." | 212 print "Warning: filtered out", diff, "from deps list." |
| 213 deps = libs | 213 deps = libs |
| 214 | 214 |
| 215 # Now write the actual build rule. | 215 # Now write the actual build rule. |
| 216 if typ in ('executable', 'application'): | 216 if typ == 'executable': |
| 217 fp.write('%s: $(OBJS) %s\n' % (output, ' '.join(deps))) | 217 fp.write('%s: $(OBJS) %s\n' % (output, ' '.join(deps))) |
| 218 fp.write('\t$(call do_cmd,link)\n') | 218 fp.write('\t$(call do_cmd,link)\n') |
| 219 binpath = '$(obj)/bin/' + target | 219 binpath = '$(obj)/bin/' + target |
| 220 fp.write('%s: %s\n' % (binpath, output)) | 220 fp.write('%s: %s\n' % (binpath, output)) |
| 221 fp.write('\tmkdir -p $(obj)/bin\n') | 221 fp.write('\tmkdir -p $(obj)/bin\n') |
| 222 fp.write('\tln %s %s\n' % (output, binpath)) | 222 fp.write('\tln %s %s\n' % (output, binpath)) |
| 223 fp.write('# Also provide a short alias for building this executable:\n') | 223 fp.write('# Also provide a short alias for building this executable:\n') |
| 224 fp.write('%s: %s\n' % (target, binpath)) | 224 fp.write('%s: %s\n' % (target, binpath)) |
| 225 elif typ == 'static_library': | 225 elif typ == 'static_library': |
| 226 fp.write('%s: $(OBJS) %s\n' % (output, ' '.join(deps))) | 226 fp.write('%s: $(OBJS) %s\n' % (output, ' '.join(deps))) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 252 # Hack around SCons-specific gyp file. | 252 # Hack around SCons-specific gyp file. |
| 253 out = out.replace('../grit_derived_sources', '$(out)/gen') | 253 out = out.replace('../grit_derived_sources', '$(out)/gen') |
| 254 fp.write('%s: %s\n' % (out, name)) | 254 fp.write('%s: %s\n' % (out, name)) |
| 255 dirs.add(os.path.split(out)[0]) | 255 dirs.add(os.path.split(out)[0]) |
| 256 # Make the phony target depend on the inputs and generate the outputs. | 256 # Make the phony target depend on the inputs and generate the outputs. |
| 257 fp.write('%s: %s\n' % (name, ' '.join(inputs))) | 257 fp.write('%s: %s\n' % (name, ' '.join(inputs))) |
| 258 if len(dirs) > 0: | 258 if len(dirs) > 0: |
| 259 fp.write('\tmkdir -p %s\n' % ' '.join(dirs)) | 259 fp.write('\tmkdir -p %s\n' % ' '.join(dirs)) |
| 260 fp.write('\t%s\n' % ' '.join(action['action'])) | 260 fp.write('\t%s\n' % ' '.join(action['action'])) |
| 261 | 261 |
| 262 if typ not in ('executable', 'application', 'resource', 'none', 'static_librar
y'): | 262 if typ not in ('executable', 'resource', 'none', 'static_library'): |
| 263 raise "unhandled typ", typ | 263 raise "unhandled typ", typ |
| 264 | 264 |
| 265 fp.write('\n') | 265 fp.write('\n') |
| 266 fp.write(footer) | 266 fp.write(footer) |
| 267 fp.write('\n') | 267 fp.write('\n') |
| 268 | 268 |
| 269 fp.close() | 269 fp.close() |
| 270 return output | 270 return output |
| 271 | 271 |
| 272 def GenerateOutput(target_list, target_dicts, data, params): | 272 def GenerateOutput(target_list, target_dicts, data, params): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 285 target + params['options'].suffix + '.mk') | 285 target + params['options'].suffix + '.mk') |
| 286 | 286 |
| 287 spec = target_dicts[qualified_target] | 287 spec = target_dicts[qualified_target] |
| 288 config = spec['configurations']['Debug'] | 288 config = spec['configurations']['Debug'] |
| 289 output = GenerateMakefile(output_file, build_file, spec, config) | 289 output = GenerateMakefile(output_file, build_file, spec, config) |
| 290 if output: | 290 if output: |
| 291 libpaths[qualified_target] = output | 291 libpaths[qualified_target] = output |
| 292 root_makefile.write('include ' + output_file + "\n") | 292 root_makefile.write('include ' + output_file + "\n") |
| 293 | 293 |
| 294 root_makefile.close() | 294 root_makefile.close() |
| OLD | NEW |