Do any platform-specific customization of a compiler instance. This method calls `distutils.sysconfig.customize_compiler` for platform-specific customization, as well as optionally remove a flag to suppress spurious warnings in case C++ code is being compiled. Parameters -
(self, dist, need_cxx=0)
| 477 | replace_method(CCompiler, 'show_customization', CCompiler_show_customization) |
| 478 | |
| 479 | def CCompiler_customize(self, dist, need_cxx=0): |
| 480 | """ |
| 481 | Do any platform-specific customization of a compiler instance. |
| 482 | |
| 483 | This method calls `distutils.sysconfig.customize_compiler` for |
| 484 | platform-specific customization, as well as optionally remove a flag |
| 485 | to suppress spurious warnings in case C++ code is being compiled. |
| 486 | |
| 487 | Parameters |
| 488 | ---------- |
| 489 | dist : object |
| 490 | This parameter is not used for anything. |
| 491 | need_cxx : bool, optional |
| 492 | Whether or not C++ has to be compiled. If so (True), the |
| 493 | ``"-Wstrict-prototypes"`` option is removed to prevent spurious |
| 494 | warnings. Default is False. |
| 495 | |
| 496 | Returns |
| 497 | ------- |
| 498 | None |
| 499 | |
| 500 | Notes |
| 501 | ----- |
| 502 | All the default options used by distutils can be extracted with:: |
| 503 | |
| 504 | from distutils import sysconfig |
| 505 | sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS', |
| 506 | 'CCSHARED', 'LDSHARED', 'SO') |
| 507 | |
| 508 | """ |
| 509 | # See FCompiler.customize for suggested usage. |
| 510 | log.info('customize %s' % (self.__class__.__name__)) |
| 511 | customize_compiler(self) |
| 512 | if need_cxx: |
| 513 | # In general, distutils uses -Wstrict-prototypes, but this option is |
| 514 | # not valid for C++ code, only for C. Remove it if it's there to |
| 515 | # avoid a spurious warning on every compilation. |
| 516 | try: |
| 517 | self.compiler_so.remove('-Wstrict-prototypes') |
| 518 | except (AttributeError, ValueError): |
| 519 | pass |
| 520 | |
| 521 | if hasattr(self, 'compiler') and 'cc' in self.compiler[0]: |
| 522 | if not self.compiler_cxx: |
| 523 | if self.compiler[0].startswith('gcc'): |
| 524 | a, b = 'gcc', 'g++' |
| 525 | else: |
| 526 | a, b = 'cc', 'c++' |
| 527 | self.compiler_cxx = [self.compiler[0].replace(a, b)]\ |
| 528 | + self.compiler[1:] |
| 529 | else: |
| 530 | if hasattr(self, 'compiler'): |
| 531 | log.warn("#### %s #######" % (self.compiler,)) |
| 532 | if not hasattr(self, 'compiler_cxx'): |
| 533 | log.warn('Missing compiler_cxx fix for ' + self.__class__.__name__) |
| 534 | |
| 535 | |
| 536 | # check if compiler supports gcc style automatic dependencies |