Write out the flags and include paths used to compile source files for the current target. Args: spec, configs: input from gyp.
(self, spec, configs)
| 498 | self.WriteLn() |
| 499 | |
| 500 | def WriteSourceFlags(self, spec, configs): |
| 501 | """Write out the flags and include paths used to compile source files for |
| 502 | the current target. |
| 503 | |
| 504 | Args: |
| 505 | spec, configs: input from gyp. |
| 506 | """ |
| 507 | for configname, config in sorted(configs.items()): |
| 508 | extracted_includes = [] |
| 509 | |
| 510 | self.WriteLn("\n# Flags passed to both C and C++ files.") |
| 511 | cflags, includes_from_cflags = self.ExtractIncludesFromCFlags( |
| 512 | config.get("cflags", []) + config.get("cflags_c", []) |
| 513 | ) |
| 514 | extracted_includes.extend(includes_from_cflags) |
| 515 | self.WriteList(cflags, "MY_CFLAGS_%s" % configname) |
| 516 | |
| 517 | self.WriteList( |
| 518 | config.get("defines"), |
| 519 | "MY_DEFS_%s" % configname, |
| 520 | prefix="-D", |
| 521 | quoter=make.EscapeCppDefine, |
| 522 | ) |
| 523 | |
| 524 | self.WriteLn("\n# Include paths placed before CFLAGS/CPPFLAGS") |
| 525 | includes = list(config.get("include_dirs", [])) |
| 526 | includes.extend(extracted_includes) |
| 527 | includes = map(Sourceify, map(self.LocalPathify, includes)) |
| 528 | includes = self.NormalizeIncludePaths(includes) |
| 529 | self.WriteList(includes, "LOCAL_C_INCLUDES_%s" % configname) |
| 530 | |
| 531 | self.WriteLn("\n# Flags passed to only C++ (and not C) files.") |
| 532 | self.WriteList(config.get("cflags_cc"), "LOCAL_CPPFLAGS_%s" % configname) |
| 533 | |
| 534 | self.WriteLn( |
| 535 | "\nLOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) " |
| 536 | "$(MY_DEFS_$(GYP_CONFIGURATION))" |
| 537 | ) |
| 538 | # Undefine ANDROID for host modules |
| 539 | # TODO: the source code should not use macro ANDROID to tell if it's host |
| 540 | # or target module. |
| 541 | if self.toolset == "host": |
| 542 | self.WriteLn("# Undefine ANDROID for host modules") |
| 543 | self.WriteLn("LOCAL_CFLAGS += -UANDROID") |
| 544 | self.WriteLn( |
| 545 | "LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) " |
| 546 | "$(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION))" |
| 547 | ) |
| 548 | self.WriteLn("LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION))") |
| 549 | # Android uses separate flags for assembly file invocations, but gyp expects |
| 550 | # the same CFLAGS to be applied: |
| 551 | self.WriteLn("LOCAL_ASFLAGS := $(LOCAL_CFLAGS)") |
| 552 | |
| 553 | def WriteSources(self, spec, configs, extra_sources): |
| 554 | """Write Makefile code for any 'sources' from the gyp input. |
no test coverage detected