Skip to content

Commit 1620f2c

Browse files
authored
Merge pull request #36178 from akyrtzi/build-parser-lib-improvements
[parser lib] A few enhancements for the syntax-parser-only build
2 parents f64b7c4 + 8cbfb54 commit 1620f2c

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,6 +4215,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
42154215
}
42164216

42174217
void visit(Type T) {
4218+
#if SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
4219+
return; // not needed for the parser library.
4220+
#endif
4221+
42184222
Printer.printTypePre(TypeLoc::withoutLoc(T));
42194223
SWIFT_DEFER { Printer.printTypePost(TypeLoc::withoutLoc(T)); };
42204224

tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ add_swift_tool_subdirectory(swift-refactor)
3131
add_swift_tool_subdirectory(libSwiftScan)
3232
if(SWIFT_BUILD_SYNTAXPARSERLIB)
3333
add_swift_tool_subdirectory(libSwiftSyntaxParser)
34-
if(SWIFT_INCLUDE_TESTS)
34+
if(SWIFT_INCLUDE_TESTS OR SWIFT_BUILD_SYNTAXPARSERTEST)
3535
add_swift_tool_subdirectory(swift-syntax-parser-test)
3636
endif()
3737
endif()

utils/build-parser-lib

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ from swift_build_support.swift_build_support import shell
4040
from swift_build_support.swift_build_support.toolchain import host_toolchain
4141

4242
isDarwin = platform.system() == "Darwin"
43+
isSwiftContainedInLLVMProject = os.path.exists(os.path.join(SWIFT_SOURCE_ROOT, "llvm"))
4344

4445

4546
class Builder(object):
@@ -227,7 +228,10 @@ class Builder(object):
227228
"-DLLVM_ENABLE_PROJECTS=clang;swift",
228229
"-DLLVM_EXTERNAL_PROJECTS=swift",
229230
]
230-
cmake_args += ["-DSWIFT_BUILD_ONLY_SYNTAXPARSERLIB=TRUE"]
231+
cmake_args += [
232+
"-DSWIFT_BUILD_ONLY_SYNTAXPARSERLIB=TRUE",
233+
"-DSWIFT_BUILD_SYNTAXPARSERTEST=TRUE",
234+
]
231235
cmake_args += ["-DSWIFT_BUILD_PERF_TESTSUITE=NO", "-DSWIFT_INCLUDE_DOCS=NO"]
232236
cmake_args += [
233237
"-DSWIFT_BUILD_REMOTE_MIRROR=FALSE",
@@ -253,7 +257,10 @@ class Builder(object):
253257
"-DCLANG_INCLUDE_TESTS=FALSE",
254258
"-DSWIFT_INCLUDE_TESTS=FALSE",
255259
]
256-
cmake_args += [os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "llvm")]
260+
llvm_src_path = os.path.join(SWIFT_SOURCE_ROOT, "llvm") \
261+
if isSwiftContainedInLLVMProject \
262+
else os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "llvm")
263+
cmake_args += [llvm_src_path]
257264
self.call(cmake_args, env=environment)
258265

259266
def build_target(self, build_dir, target, env=None):
@@ -473,16 +480,17 @@ Example invocations:
473480
if not args.install_destdir and not args.no_install:
474481
args.install_destdir = os.path.join(args.build_dir, "install")
475482

476-
swift_src_path = os.path.join(SWIFT_SOURCE_ROOT, "swift")
477-
swift_src_in_llvm_project_path = \
478-
os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "swift")
479-
# Need to symlink 'swift' into 'llvm-project' since we will be doing
480-
# a unified configure with 'swift' as an external project.
481-
if not os.path.exists(swift_src_in_llvm_project_path):
482-
print("Symlinking '%s' to '%s'" %
483-
(swift_src_path, swift_src_in_llvm_project_path), file=sys.stderr)
484-
shell.symlink(swift_src_path, swift_src_in_llvm_project_path,
485-
dry_run=args.dry_run, echo=args.verbose)
483+
if not isSwiftContainedInLLVMProject:
484+
swift_src_path = os.path.join(SWIFT_SOURCE_ROOT, "swift")
485+
swift_src_in_llvm_project_path = \
486+
os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "swift")
487+
# Need to symlink 'swift' into 'llvm-project' since we will be doing
488+
# a unified configure with 'swift' as an external project.
489+
if not os.path.exists(swift_src_in_llvm_project_path):
490+
print("Symlinking '%s' to '%s'" %
491+
(swift_src_path, swift_src_in_llvm_project_path), file=sys.stderr)
492+
shell.symlink(swift_src_path, swift_src_in_llvm_project_path,
493+
dry_run=args.dry_run, echo=args.verbose)
486494

487495
architectures = args.architectures.split(" ")
488496
architectures = [arch for arch in architectures if arch != ""]

0 commit comments

Comments
 (0)