Skip to content

Commit 3871c6c

Browse files
committed
add a phony artifact for installation via a ninja target
remove the old install script since the ninja script now can properly install the products
1 parent 3e32cef commit 3871c6c

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

build.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,19 @@
359359

360360
script.add_product(foundation)
361361

362+
script.add_text("""
363+
rule InstallFoundation
364+
command = mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
365+
cp "${BUILD_DIR}/Foundation/${DYLIB_PREFIX}Foundation${DYLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib/swift/${OS}"; $
366+
mkdir -p "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}"; $
367+
cp "${BUILD_DIR}/Foundation/Foundation.swiftmodule" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $
368+
cp "${BUILD_DIR}/Foundation/Foundation.swiftdoc" "${DSTROOT}/${PREFIX}/lib/swift/${OS}/${ARCH}/"; $
369+
mkdir -p "${DSTROOT}/${PREFIX}/local/include"; $
370+
rsync -r "${BUILD_DIR}/Foundation/${PREFIX}/lib/swift/CoreFoundation" "${DSTROOT}/${PREFIX}/lib/swift/"
371+
372+
build ${BUILD_DIR}/.install: InstallFoundation ${BUILD_DIR}/Foundation/${DYLIB_PREFIX}Foundation${DYLIB_SUFFIX}
373+
374+
build install: phony | ${BUILD_DIR}/.install
375+
""")
376+
362377
script.generate()

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def main():
5151
config.module_cache_directory = Path.path(os.getenv("BUILD_DIR", config.build_directory.path_by_appending("ModuleCache")))
5252
config.intermediate_directory = Path.path(os.getenv("INTERMEDIATE_DIR", config.build_directory.path_by_appending("Intermediates")))
5353
config.install_directory = Path.path(os.getenv("DSTROOT", "/"))
54+
config.prefix = os.getenv("PREFIX", "/usr")
5455
config.clang = os.getenv("CLANG", "clang")
5556
config.clangxx = os.getenv("CLANGXX", "clang")
5657
config.swift = os.getenv("SWIFT", "swift")

install

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Configuration:
2424
intermediate_directory = None
2525
module_cache_directory = None
2626
install_directory = None
27+
prefix = None
2728
swift_install = None
2829
clang = None
2930
clangxx = None

lib/script.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
class Script:
1414
products = []
1515
workspaces = []
16+
extra = ""
17+
1618
def __init__(self):
1719
pass
1820

@@ -24,6 +26,8 @@ def add_workspace(self, workspace):
2426
self.products = None
2527
self.workspaces.append(workspace)
2628

29+
def add_text(self, text):
30+
self.extra += text + "\n\n"
2731

2832
def generate_products(self):
2933
verbose_flags = """
@@ -51,6 +55,11 @@ def generate_products(self):
5155
SWIFTC = """ + Configuration.current.swiftc + """
5256
SDKROOT = """ + Configuration.current.swift_sdk + """
5357
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 + """
5463
"""
5564
if Configuration.current.system_root is not None:
5665
base_flags += """
@@ -109,16 +118,18 @@ def generate_products(self):
109118
elif Configuration.current.build_mode == Configuration.Release:
110119
swift_flags += " "
111120

121+
122+
112123
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 + """ """
114128
if Configuration.current.system_root is not None:
115129
ld_flags += "--sysroot=${SYSROOT}"
116130

117131
if Configuration.current.bootstrap_directory is not None:
118132
ld_flags += """ -L${TARGET_BOOTSTRAP_DIR}/usr/lib"""
119-
120-
121-
ld_flags += Configuration.current.extra_ld_flags
122133

123134
if Configuration.current.toolchain is not None:
124135
c_flags += " -B" + Configuration.current.toolchain.path_by_appending("bin").relative()
@@ -186,7 +197,7 @@ def generate_products(self):
186197

187198
swift_build_command = """
188199
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
190201
description = SwiftExecutable: $out
191202
"""
192203

@@ -198,6 +209,8 @@ def generate_products(self):
198209
script += product.generate()
199210

200211
script += "\n\n"
212+
script += self.extra
213+
script += "\n\n"
201214

202215
return script
203216

0 commit comments

Comments
 (0)