Returns flags that need to be added to .c, .cc, .m, and .mm compilations.
(self, configname, arch=None)
| 566 | ) |
| 567 | |
| 568 | def GetCflags(self, configname, arch=None): |
| 569 | """Returns flags that need to be added to .c, .cc, .m, and .mm |
| 570 | compilations.""" |
| 571 | # This functions (and the similar ones below) do not offer complete |
| 572 | # emulation of all xcode_settings keys. They're implemented on demand. |
| 573 | |
| 574 | self.configname = configname |
| 575 | cflags = [] |
| 576 | |
| 577 | sdk_root = self._SdkPath() |
| 578 | if "SDKROOT" in self._Settings() and sdk_root: |
| 579 | cflags.append("-isysroot") |
| 580 | cflags.append(sdk_root) |
| 581 | |
| 582 | if self.header_map_path: |
| 583 | cflags.append("-I%s" % self.header_map_path) |
| 584 | |
| 585 | if self._Test("CLANG_WARN_CONSTANT_CONVERSION", "YES", default="NO"): |
| 586 | cflags.append("-Wconstant-conversion") |
| 587 | |
| 588 | if self._Test("GCC_CHAR_IS_UNSIGNED_CHAR", "YES", default="NO"): |
| 589 | cflags.append("-funsigned-char") |
| 590 | |
| 591 | if self._Test("GCC_CW_ASM_SYNTAX", "YES", default="YES"): |
| 592 | cflags.append("-fasm-blocks") |
| 593 | |
| 594 | if "GCC_DYNAMIC_NO_PIC" in self._Settings(): |
| 595 | if self._Settings()["GCC_DYNAMIC_NO_PIC"] == "YES": |
| 596 | cflags.append("-mdynamic-no-pic") |
| 597 | else: |
| 598 | pass |
| 599 | # TODO: In this case, it depends on the target. xcode passes |
| 600 | # mdynamic-no-pic by default for executable and possibly static lib |
| 601 | # according to mento |
| 602 | |
| 603 | if self._Test("GCC_ENABLE_PASCAL_STRINGS", "YES", default="YES"): |
| 604 | cflags.append("-mpascal-strings") |
| 605 | |
| 606 | self._Appendf(cflags, "GCC_OPTIMIZATION_LEVEL", "-O%s", default="s") |
| 607 | |
| 608 | if self._Test("GCC_GENERATE_DEBUGGING_SYMBOLS", "YES", default="YES"): |
| 609 | dbg_format = self._Settings().get("DEBUG_INFORMATION_FORMAT", "dwarf") |
| 610 | if dbg_format == "dwarf": |
| 611 | cflags.append("-gdwarf-2") |
| 612 | elif dbg_format == "stabs": |
| 613 | raise NotImplementedError("stabs debug format is not supported yet.") |
| 614 | elif dbg_format == "dwarf-with-dsym": |
| 615 | cflags.append("-gdwarf-2") |
| 616 | else: |
| 617 | raise NotImplementedError("Unknown debug format %s" % dbg_format) |
| 618 | |
| 619 | if self._Settings().get("GCC_STRICT_ALIASING") == "YES": |
| 620 | cflags.append("-fstrict-aliasing") |
| 621 | elif self._Settings().get("GCC_STRICT_ALIASING") == "NO": |
| 622 | cflags.append("-fno-strict-aliasing") |
| 623 | |
| 624 | if self._Test("GCC_SYMBOLS_PRIVATE_EXTERN", "YES", default="NO"): |
| 625 | cflags.append("-fvisibility=hidden") |