13
13
class Script :
14
14
products = []
15
15
workspaces = []
16
+ extra = ""
17
+
16
18
def __init__ (self ):
17
19
pass
18
20
@@ -24,6 +26,8 @@ def add_workspace(self, workspace):
24
26
self .products = None
25
27
self .workspaces .append (workspace )
26
28
29
+ def add_text (self , text ):
30
+ self .extra += text + "\n \n "
27
31
28
32
def generate_products (self ):
29
33
verbose_flags = """
@@ -51,6 +55,11 @@ def generate_products(self):
51
55
SWIFTC = """ + Configuration .current .swiftc + """
52
56
SDKROOT = """ + Configuration .current .swift_sdk + """
53
57
AR = """ + Configuration .current .ar + """
58
+ OS = """ + Configuration .current .target .swift_sdk_name + """
59
+ ARCH = """ + Configuration .current .target .swift_arch + """
60
+ DYLIB_PREFIX = """ + Configuration .current .target .dynamic_library_prefix + """
61
+ DYLIB_SUFFIX = """ + Configuration .current .target .dynamic_library_suffix + """
62
+ PREFIX = """ + Configuration .current .prefix + """
54
63
"""
55
64
if Configuration .current .system_root is not None :
56
65
base_flags += """
@@ -109,16 +118,18 @@ def generate_products(self):
109
118
elif Configuration .current .build_mode == Configuration .Release :
110
119
swift_flags += " "
111
120
121
+
122
+
112
123
ld_flags = """
113
- TARGET_LDFLAGS = --target=${TARGET} -L${SDKROOT}/lib/swift/""" + Configuration .current .target .swift_sdk_name + """ """
124
+ EXTRA_LD_FLAGS = """ + Configuration .current .extra_ld_flags
125
+
126
+ ld_flags += """
127
+ TARGET_LDFLAGS = --target=${TARGET} ${EXTRA_LD_FLAGS} -L${SDKROOT}/lib/swift/""" + Configuration .current .target .swift_sdk_name + """ """
114
128
if Configuration .current .system_root is not None :
115
129
ld_flags += "--sysroot=${SYSROOT}"
116
130
117
131
if Configuration .current .bootstrap_directory is not None :
118
132
ld_flags += """ -L${TARGET_BOOTSTRAP_DIR}/usr/lib"""
119
-
120
-
121
- ld_flags += Configuration .current .extra_ld_flags
122
133
123
134
if Configuration .current .toolchain is not None :
124
135
c_flags += " -B" + Configuration .current .toolchain .path_by_appending ("bin" ).relative ()
@@ -186,7 +197,7 @@ def generate_products(self):
186
197
187
198
swift_build_command = """
188
199
rule SwiftExecutable
189
- command = mkdir -p `dirname $out`; ${SWIFTC} ${TARGET_SWIFTEXE_FLAGS} $flags $in -o $out
200
+ command = mkdir -p `dirname $out`; ${SWIFTC} ${TARGET_SWIFTEXE_FLAGS} ${EXTRA_LD_FLAGS} $ flags $in -o $out
190
201
description = SwiftExecutable: $out
191
202
"""
192
203
@@ -198,6 +209,8 @@ def generate_products(self):
198
209
script += product .generate ()
199
210
200
211
script += "\n \n "
212
+ script += self .extra
213
+ script += "\n \n "
201
214
202
215
return script
203
216
0 commit comments