Skip to content

build static foundation #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

script = Script()

foundation = DynamicLibrary("Foundation")
foundation = StaticAndDynamicLibrary("Foundation")

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

Expand Down Expand Up @@ -504,6 +504,8 @@
rule InstallFoundation
command = mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
cp "${BUILD_DIR}/Foundation/${DYLIB_PREFIX}Foundation${DYLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
mkdir -p "${DSTROOT}/${PREFIX}/lib/swift_static/${OS}"; $
cp "${BUILD_DIR}/Foundation/${STATICLIB_PREFIX}Foundation${STATICLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib/swift_static/${OS}"; $
mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}"; $
cp "${BUILD_DIR}/Foundation/Foundation.swiftmodule" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $
cp "${BUILD_DIR}/Foundation/Foundation.swiftdoc" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ from lib.phases import SwiftExecutable
from lib.product import DynamicLibrary
from lib.product import Framework
from lib.product import StaticLibrary
from lib.product import StaticAndDynamicLibrary
from lib.product import Application
from lib.product import Executable

Expand Down
25 changes: 16 additions & 9 deletions lib/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ def generate(self, flags):
class DynamicLibrary(Library):
def __init__(self, name):
Library.__init__(self, name)
self.rule = "Link"
self.product_name = Configuration.current.target.dynamic_library_prefix + name + Configuration.current.target.dynamic_library_suffix
self.name = name

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

return generated


class StaticLibrary(Library):
def __init__(self, name):
Library.__init__(self, name)
self.rule = "Archive"
self.product_name = Configuration.current.target.static_library_prefix + name + Configuration.current.target.static_library_suffix

self.name = name

def generate(self):
self.rule = "Archive"
self.product_name = Configuration.current.target.static_library_prefix + self.name + Configuration.current.target.static_library_suffix
return Library.generate(self, [])


class StaticAndDynamicLibrary(StaticLibrary, DynamicLibrary):
def __init__(self, name):
StaticLibrary.__init__(self, name)
DynamicLibrary.__init__(self, name)

def generate(self):
return StaticLibrary.generate(self) + DynamicLibrary.generate(self)

class Executable(Product):
def __init__(self, name):
Expand All @@ -190,9 +198,8 @@ def __init__(self, name):

def generate(self):
generated = Product.generate(self)

return generated

return generated

class Application(Product):
executable = None
Expand Down
4 changes: 3 additions & 1 deletion lib/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def generate_products(self):
ARCH = """ + Configuration.current.target.swift_arch + """
DYLIB_PREFIX = """ + Configuration.current.target.dynamic_library_prefix + """
DYLIB_SUFFIX = """ + Configuration.current.target.dynamic_library_suffix + """
STATICLIB_PREFIX = """ + Configuration.current.target.static_library_prefix + """
STATICLIB_SUFFIX = """ + Configuration.current.target.static_library_suffix + """
PREFIX = """ + Configuration.current.prefix + """
"""
if Configuration.current.requires_pkg_config:
Expand Down Expand Up @@ -206,7 +208,7 @@ def generate_products(self):
description = Link: $out

rule Archive
command = mkdir -p `dirname $out`; ${AR} ${AR_FLAGS} $flags $out $in
command = mkdir -p `dirname $out`; ${AR} ${AR_FLAGS} $out $in
description = Archive: $out
"""

Expand Down