Skip to content

Commit 406f007

Browse files
authored
Merge pull request #873 from weissi/jw-build-static-foundation
2 parents 61a7760 + 909dc98 commit 406f007

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
script = Script()
1111

12-
foundation = DynamicLibrary("Foundation")
12+
foundation = StaticAndDynamicLibrary("Foundation")
1313

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

@@ -513,6 +513,8 @@
513513
rule InstallFoundation
514514
command = mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
515515
cp "${BUILD_DIR}/Foundation/${DYLIB_PREFIX}Foundation${DYLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
516+
mkdir -p "${DSTROOT}/${PREFIX}/lib/swift_static/${OS}"; $
517+
cp "${BUILD_DIR}/Foundation/${STATICLIB_PREFIX}Foundation${STATICLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib/swift_static/${OS}"; $
516518
mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}"; $
517519
cp "${BUILD_DIR}/Foundation/Foundation.swiftmodule" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $
518520
cp "${BUILD_DIR}/Foundation/Foundation.swiftdoc" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ from lib.phases import SwiftExecutable
2828
from lib.product import DynamicLibrary
2929
from lib.product import Framework
3030
from lib.product import StaticLibrary
31+
from lib.product import StaticAndDynamicLibrary
3132
from lib.product import Application
3233
from lib.product import Executable
3334

lib/product.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ def generate(self, flags):
112112
class DynamicLibrary(Library):
113113
def __init__(self, name):
114114
Library.__init__(self, name)
115-
self.rule = "Link"
116-
self.product_name = Configuration.current.target.dynamic_library_prefix + name + Configuration.current.target.dynamic_library_suffix
115+
self.name = name
117116

118117
def generate(self):
118+
self.rule = "Link"
119+
self.product_name = Configuration.current.target.dynamic_library_prefix + self.name + Configuration.current.target.dynamic_library_suffix
119120
if Configuration.current.target.sdk == OSType.Linux or Configuration.current.target.sdk == OSType.FreeBSD:
120121
self.conformance_begin = '${SDKROOT}/lib/swift/${OS}/${ARCH}/swift_begin.o'
121122
self.conformance_end = '${SDKROOT}/lib/swift/${OS}/${ARCH}/swift_end.o'
@@ -172,16 +173,23 @@ def generate(self):
172173

173174
return generated
174175

175-
176176
class StaticLibrary(Library):
177177
def __init__(self, name):
178178
Library.__init__(self, name)
179-
self.rule = "Archive"
180-
self.product_name = Configuration.current.target.static_library_prefix + name + Configuration.current.target.static_library_suffix
181-
179+
self.name = name
180+
182181
def generate(self):
182+
self.rule = "Archive"
183+
self.product_name = Configuration.current.target.static_library_prefix + self.name + Configuration.current.target.static_library_suffix
183184
return Library.generate(self, [])
184-
185+
186+
class StaticAndDynamicLibrary(StaticLibrary, DynamicLibrary):
187+
def __init__(self, name):
188+
StaticLibrary.__init__(self, name)
189+
DynamicLibrary.__init__(self, name)
190+
191+
def generate(self):
192+
return StaticLibrary.generate(self) + DynamicLibrary.generate(self)
185193

186194
class Executable(Product):
187195
def __init__(self, name):
@@ -190,9 +198,8 @@ def __init__(self, name):
190198

191199
def generate(self):
192200
generated = Product.generate(self)
193-
194-
return generated
195201

202+
return generated
196203

197204
class Application(Product):
198205
executable = None

lib/script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def generate_products(self):
6363
ARCH = """ + Configuration.current.target.swift_arch + """
6464
DYLIB_PREFIX = """ + Configuration.current.target.dynamic_library_prefix + """
6565
DYLIB_SUFFIX = """ + Configuration.current.target.dynamic_library_suffix + """
66+
STATICLIB_PREFIX = """ + Configuration.current.target.static_library_prefix + """
67+
STATICLIB_SUFFIX = """ + Configuration.current.target.static_library_suffix + """
6668
PREFIX = """ + Configuration.current.prefix + """
6769
"""
6870
if Configuration.current.requires_pkg_config:
@@ -206,7 +208,7 @@ def generate_products(self):
206208
description = Link: $out
207209
208210
rule Archive
209-
command = mkdir -p `dirname $out`; ${AR} ${AR_FLAGS} $flags $out $in
211+
command = mkdir -p `dirname $out`; ${AR} ${AR_FLAGS} $out $in
210212
description = Archive: $out
211213
"""
212214

0 commit comments

Comments
 (0)