Skip to content

Fixes to enable swift section objects #50

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 1 commit into from
Feb 18, 2016
Merged
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
8 changes: 7 additions & 1 deletion build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ def main():
action="store_true",
dest="test",
default=False)
parser.add_argument("--arch",
help="target architecture",
action="store",
dest="arch",
default=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to explicitly mark default=None here. argparse already uses None in the absence of the option being specified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the build invocation below uses arch. Shouldn't --arch be marked as required=True here?

args = parser.parse_args()

swiftc = os.path.abspath(args.swiftc)
build_dir = os.path.abspath(args.build_dir)
swift_build_dir = os.path.abspath(args.swift_build_dir)
arch = args.arch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: You could simply reference args.arch below, and eliminate this line. Other parameters, such as args.build_style, follow that pattern.


if not os.path.exists(build_dir):
run("mkdir -p {}".format(build_dir))
Expand All @@ -112,7 +118,7 @@ def main():
run("{0} -c {1} -emit-object {2} -module-name XCTest -parse-as-library -emit-module "
"-emit-module-path {3}/XCTest.swiftmodule -o {3}/XCTest.o -force-single-frontend-invocation "
"-module-link-name XCTest".format(swiftc, style_options, " ".join(sourcePaths), build_dir))
run("clang {0}/XCTest.o -shared -o {0}/libXCTest.so -Wl,--no-undefined -Wl,-soname,libXCTest.so -L{1}/lib/swift/linux/ -lswiftGlibc -lswiftCore -lm".format(build_dir, swift_build_dir))
run("clang {1}/lib/swift/linux/{2}/swift_begin.o {0}/XCTest.o {1}/lib/swift/linux/{2}/swift_end.o -shared -o {0}/libXCTest.so -Wl,--no-undefined -Wl,-soname,libXCTest.so -L{1}/lib/swift/linux/ -lswiftGlibc -lswiftCore -lm".format(build_dir, swift_build_dir, arch))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. Thanks, @hpux735! 💯

Personally I've been meaning to reformat this convoluted string interpolation to use identifiers--something like the following:

run('clang {swift_build_dir}/lib/swift/linux/{arch}/swift_begin.o '
    '{build_dir}/XCTest.o '
    '{swift_build_dir}/lib/swift/linux/{arch}/swift_end.o '
    '-shared -o {build_dir}/libXCTest.so '
    '-Wl,--no-undefined -Wl,-soname,libXCTest.so '
    '-L{swift_build_dir}/lib/swift/linux/ '
    '-lswiftGlibc -lswiftCore -lm'.format(
        build_dir=build_dir,
        swift_build_dir=swift_build_dir,
        arch=arch))

Doing so makes it a little easier for me to follow what's going on. I can take care of that at a later time--I think this is fine for now!


# If we were given an install directive, perform installation
if args.module_path is not None and args.lib_path is not None:
Expand Down