aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-04-24 20:35:33 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-04-25 15:35:13 +0300
commit1a31882f597c0cbfd56fd38f6b8d4424104bdb0d (patch)
tree006ee26948982b793132c66ebf777be8e3be65bf
parent1cd80985b42ea624fa3e7623e3e191a8145e5078 (diff)
downloadmeson-1a31882f597c0cbfd56fd38f6b8d4424104bdb0d.zip
meson-1a31882f597c0cbfd56fd38f6b8d4424104bdb0d.tar.gz
meson-1a31882f597c0cbfd56fd38f6b8d4424104bdb0d.tar.bz2
Xcode: make Swift projects work.
-rw-r--r--mesonbuild/backend/backends.py6
-rw-r--r--mesonbuild/backend/ninjabackend.py6
-rw-r--r--mesonbuild/backend/xcodebackend.py9
-rw-r--r--test cases/swift/1 exe/main.swift (renamed from test cases/swift/1 exe/prog.swift)0
-rw-r--r--test cases/swift/1 exe/meson.build2
5 files changed, 15 insertions, 8 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 734a7e4..e6628b6 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -417,6 +417,12 @@ class Backend:
raise MesonException('Unknown data type in object list.')
return obj_list
+ def is_swift_target(self, target):
+ for s in target.sources:
+ if s.endswith('swift'):
+ return True
+ return False
+
def get_executable_serialisation(self, cmd, workdir=None,
extra_bdeps=None, capture=None,
env: T.Optional[build.EnvironmentVariables] = None):
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index e8a7d4b..fa07235 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1701,12 +1701,6 @@ int dummy;
def target_swift_modulename(self, target):
return target.name
- def is_swift_target(self, target):
- for s in target.sources:
- if s.endswith('swift'):
- return True
- return False
-
def determine_swift_dep_modules(self, target):
result = []
for l in target.link_targets:
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 6fc4729..aeaee5c 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -37,6 +37,7 @@ XCODETYPEMAP = {'c': 'sourcecode.c.c',
'hxx': 'sourcecode.cpp.h',
'hh': 'sourcecode.cpp.hh',
'inc': 'sourcecode.c.h',
+ 'swift': 'sourcecode.swift',
'dylib': 'compiled.mach-o.dylib',
'o': 'compiled.mach-o.objfile',
's': 'sourcecode.asm',
@@ -1277,6 +1278,7 @@ class XCodeBackend(backends.Backend):
bt_dict.add_item('buildSettings', settings_dict)
settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"')
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
+ settings_dict.add_item('SWIFT_VERSION', '4.0')
settings_dict.add_item('SDKROOT', '"macosx"')
settings_dict.add_item('SYMROOT', '"%s/build"' % self.environment.get_build_dir())
bt_dict.add_item('name', f'"{buildtype}"')
@@ -1382,7 +1384,12 @@ class XCodeBackend(backends.Backend):
else:
product_name = target.get_basename()
ldargs += target.link_args
- linker, stdlib_args = self.determine_linker_and_stdlib_args(target)
+ # Swift is special. Again. You can't mix Swift with other languages
+ # in the same target. Thus for Swift we only use
+ if self.is_swift_target(target):
+ linker, stdlib_args = target.compilers['swift'], []
+ else:
+ linker, stdlib_args = self.determine_linker_and_stdlib_args(target)
if not isinstance(target, build.StaticLibrary):
ldargs += self.build.get_project_link_args(linker, target.subproject, target.for_machine)
ldargs += self.build.get_global_link_args(linker, target.for_machine)
diff --git a/test cases/swift/1 exe/prog.swift b/test cases/swift/1 exe/main.swift
index 1b489de..1b489de 100644
--- a/test cases/swift/1 exe/prog.swift
+++ b/test cases/swift/1 exe/main.swift
diff --git a/test cases/swift/1 exe/meson.build b/test cases/swift/1 exe/meson.build
index f986e9a..4436a8e 100644
--- a/test cases/swift/1 exe/meson.build
+++ b/test cases/swift/1 exe/meson.build
@@ -1,3 +1,3 @@
project('swift exe', 'swift')
-test('swifttest', executable('swifttest', 'prog.swift'))
+test('swifttest', executable('swifttest', 'main.swift'))