Skip to content

Commit e57d3c6

Browse files
authored
Merge pull request swiftlang#541 from tinysun212/pr-foundation-build-cygwin-1
2 parents d015466 + d7a69f7 commit e57d3c6

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

build.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
foundation.GCC_PREFIX_HEADER = 'CoreFoundation/Base.subproj/CoreFoundation_Prefix.h'
1515

16+
swift_cflags = []
1617
if Configuration.current.target.sdk == OSType.Linux:
1718
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -DCF_CHARACTERSET_DATA_DIR="CoreFoundation/CharacterSets"'
1819
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -Wl,@./CoreFoundation/linux.ld -lswiftGlibc `${PKG_CONFIG} icu-uc icu-i18n --libs` -Wl,-defsym,__CFConstantStringClassReference=_TMC10Foundation19_NSCFConstantString -Wl,-Bsymbolic '
@@ -23,6 +24,10 @@
2324
elif Configuration.current.target.sdk == OSType.MacOSX:
2425
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_MACOSX '
2526
foundation.LDFLAGS = '-licucore -twolevel_namespace -Wl,-alias_list,CoreFoundation/Base.subproj/DarwinSymbolAliases -sectcreate __UNICODE __csbitmaps CoreFoundation/CharacterSets/CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CoreFoundation/CharacterSets/CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data CoreFoundation/CharacterSets/CFUnicodeData-L.mapping -segprot __UNICODE r r '
27+
elif Configuration.current.target.sdk == OSType.Win32 and Configuration.current.target.environ == EnvironmentType.Cygnus:
28+
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -mcmodel=large '
29+
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,-defsym,__CFConstantStringClassReference=_TMC10Foundation19_NSCFConstantString,--allow-multiple-definition '
30+
swift_cflags += ['-DCYGWIN']
2631

2732
if Configuration.current.build_mode == Configuration.Debug:
2833
foundation.LDFLAGS += ' -lswiftSwiftOnoneSupport '
@@ -61,7 +66,7 @@
6166
'-I./',
6267
])
6368

64-
swift_cflags = [
69+
swift_cflags += [
6570
'-I${BUILD_DIR}/Foundation/usr/lib/swift',
6671
'-I${SYSROOT}/usr/include/libxml2',
6772
'-I${SYSROOT}/usr/include/curl'

lib/script.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def generate_products(self):
199199

200200
link_command = """
201201
rule Link
202-
command = mkdir -p `dirname $out`; ${CLANG} ${TARGET_LDFLAGS} $flags ${VERBOSE_FLAGS} $start $in $end -o $out"""
202+
command = mkdir -p `dirname $out`; ${CLANG} ${TARGET_LDFLAGS} ${VERBOSE_FLAGS} $start $in $end $flags -o $out"""
203203
if Configuration.current.verbose:
204204
link_command += "-Xlinker --verbose"
205205
link_command += """

lib/target.py

+11
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ class Target:
325325
triple = None
326326
sdk = None
327327
arch = None
328+
environ = None
328329
executable_suffix = ""
329330
dynamic_library_prefix = "lib"
330331
dynamic_library_suffix = ".dylib"
@@ -342,6 +343,10 @@ def __init__(self, triple):
342343
self.sdk = OSType.Win32
343344
self.dynamic_library_suffix = ".dll"
344345
self.executable_suffix = ".exe"
346+
if "cygnus" in triple:
347+
self.environ = EnvironmentType.Cygnus
348+
else:
349+
self.environ = EnvironmentType.UnknownEnvironment
345350
elif "darwin" in triple:
346351
self.sdk = OSType.MacOSX
347352
else:
@@ -366,6 +371,8 @@ def default():
366371
elif platform.system() == "FreeBSD":
367372
# Make this work on 10 as well.
368373
triple += "-freebsd11.0"
374+
elif platform.system() == "CYGWIN_NT-10.0":
375+
triple += "-windows-cygnus"
369376
else:
370377
# TODO: This should be a bit more exhaustive
371378
print("unknown host os")
@@ -388,6 +395,8 @@ def swift_triple(self):
388395
triple += "-unknown-linux"
389396
elif self.sdk == OSType.FreeBSD:
390397
triple += "-unknown-freebsd"
398+
elif self.sdk == OSType.Win32 and self.environ == EnvironmentType.Cygnus:
399+
triple += "-unknown-windows-cygnus"
391400
else:
392401
print("unknown sdk for swift")
393402
return None
@@ -402,6 +411,8 @@ def swift_sdk_name(self):
402411
return "linux"
403412
elif self.sdk == OSType.FreeBSD:
404413
return "freebsd"
414+
elif self.sdk == OSType.Win32:
415+
return "cygwin"
405416
else:
406417
print("unknown sdk for swift")
407418
return None

0 commit comments

Comments
 (0)