Skip to content

Commit 0459214

Browse files
author
Mike Ferris
committed
Add --debug and --release command line options to Linux build script. --release causes -O to be added to the compile line and --debug causes -g to be added. --debug is the default.
1 parent 0dc69bb commit 0459214

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

build_script.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ def main():
5757
action="store",
5858
dest="lib_path",
5959
default=None)
60+
parser.add_argument("--release",
61+
help="builds for release",
62+
action="store_const",
63+
dest="build_style",
64+
const="release",
65+
default="debug")
66+
parser.add_argument("--debug",
67+
help="builds for debug (the default)",
68+
action="store_const",
69+
dest="build_style",
70+
const="debug",
71+
default="debug")
6072
args = parser.parse_args()
6173

6274
swiftc = os.path.abspath(args.swiftc)
@@ -71,11 +83,17 @@ def main():
7183
for file in sourceFiles:
7284
sourcePaths.append("{0}/XCTest/{1}".format(os.path.dirname(os.path.abspath(__file__)), file))
7385

74-
# Not incremental..
75-
run("{0} -c -O -emit-object {1} -module-name XCTest -parse-as-library -emit-module "
76-
"-emit-module-path {2}/XCTest.swiftmodule -o {2}/XCTest.o -force-single-frontend-invocation "
77-
"-module-link-name XCTest".format(swiftc, " ".join(sourcePaths), build_dir))
7886

87+
if args.build_style == "debug":
88+
style_options = "-g"
89+
else:
90+
style_options = "-O"
91+
92+
# Not incremental..
93+
# Build library
94+
run("{0} -c {1} -emit-object {2} -module-name XCTest -parse-as-library -emit-module "
95+
"-emit-module-path {3}/XCTest.swiftmodule -o {3}/XCTest.o -force-single-frontend-invocation "
96+
"-module-link-name XCTest".format(swiftc, style_options, " ".join(sourcePaths), build_dir))
7997
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))
8098

8199
# If we were given an install directive, perform installation

0 commit comments

Comments
 (0)