diff options
author | Guillermo Ignacio Enriquez Gutierrez <ignacio@jp.ibm.com> | 2018-09-25 01:11:46 +0900 |
---|---|---|
committer | Guillermo Ignacio Enriquez Gutierrez <ignacio@jp.ibm.com> | 2018-09-25 01:11:46 +0900 |
commit | 6f4ba8b2f44d9cca0c2955cd0df74ef33efc339a (patch) | |
tree | bfdf93078bc36bdfa0ea6dbf1d720aaf164bbb8a /mesonbuild/backend/xcodebackend.py | |
parent | 9b7bb4aa92bc292230294929d35f3617cc48b0bf (diff) | |
download | meson-6f4ba8b2f44d9cca0c2955cd0df74ef33efc339a.zip meson-6f4ba8b2f44d9cca0c2955cd0df74ef33efc339a.tar.gz meson-6f4ba8b2f44d9cca0c2955cd0df74ef33efc339a.tar.bz2 |
Fix Xcode backend: support for precompiled headers. Only one header per target is supported
Diffstat (limited to 'mesonbuild/backend/xcodebackend.py')
-rw-r--r-- | mesonbuild/backend/xcodebackend.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 42f44cf..b0fcfa4 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -16,6 +16,7 @@ from . import backends from .. import build from .. import dependencies from .. import mesonlib +from .. import mlog import uuid, os, operator from ..mesonlib import MesonException @@ -756,12 +757,16 @@ class XCodeBackend(backends.Backend): self.write_line('GCC_INLINES_ARE_PRIVATE_EXTERN = NO;') self.write_line('GCC_OPTIMIZATION_LEVEL = 0;') if target.has_pch: - # FIXME: GCC_PREFIX_HEADER accepts only one file so temporary we get the pch for the first language available and apply it to the entire target - # If more than pch are found we should add a compiler flag per each file - pch_headers = target.get_pch('c') + target.get_pch('cpp') + target.get_pch('objc') + target.get_pch('objcpp') - # Find path relative to target so we can use "$(PROJECT_DIR)" - relative_pch_path = os.path.join(self.get_target_dir(target), pch_headers[0]) - if relative_pch_path: + # Xcode uses GCC_PREFIX_HEADER which only allows one file per target/executable. Precompiling various header files and + # applying a particular pch to each source file will require custom scripts (as a build phase) and build flags per each + # file. Since Xcode itself already discourages precompiled headers in favor of modules we don't try much harder here. + pchs = target.get_pch('c') + target.get_pch('cpp') + target.get_pch('objc') + target.get_pch('objcpp') + # Make sure to use headers (other backends require implementation files like *.c *.cpp, etc; these should not be used here) + pchs = [pch for pch in pchs if pch.endswith('.h') or pch.endswith('.hh') or pch.endswith('hpp')] + if pchs: + if len(pchs) > 1: + mlog.warning('Unsupported Xcode configuration: More than 1 precompiled header found "%s". Target "%s" might not compile correctly.' % (str(pchs), target.name)) + relative_pch_path = os.path.join(target.get_subdir(), pchs[0]) # Path relative to target so it can be used with "$(PROJECT_DIR)" self.write_line('GCC_PRECOMPILE_PREFIX_HEADER = YES;') self.write_line('GCC_PREFIX_HEADER = "$(PROJECT_DIR)/%s";' % relative_pch_path) self.write_line('GCC_PREPROCESSOR_DEFINITIONS = "";') |