Skip to content

[parser lib] A few enhancements for the syntax-parser-only build #36178

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 26, 2021
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: 4 additions & 0 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4216,6 +4216,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
}

void visit(Type T) {
#if SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
return; // not needed for the parser library.
#endif

Printer.printTypePre(TypeLoc::withoutLoc(T));
SWIFT_DEFER { Printer.printTypePost(TypeLoc::withoutLoc(T)); };

Expand Down
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add_swift_tool_subdirectory(swift-refactor)
add_swift_tool_subdirectory(libSwiftScan)
if(SWIFT_BUILD_SYNTAXPARSERLIB)
add_swift_tool_subdirectory(libSwiftSyntaxParser)
if(SWIFT_INCLUDE_TESTS)
if(SWIFT_INCLUDE_TESTS OR SWIFT_BUILD_SYNTAXPARSERTEST)
add_swift_tool_subdirectory(swift-syntax-parser-test)
endif()
endif()
Expand Down
32 changes: 20 additions & 12 deletions utils/build-parser-lib
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ from swift_build_support.swift_build_support import shell
from swift_build_support.swift_build_support.toolchain import host_toolchain

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


class Builder(object):
Expand Down Expand Up @@ -227,7 +228,10 @@ class Builder(object):
"-DLLVM_ENABLE_PROJECTS=clang;swift",
"-DLLVM_EXTERNAL_PROJECTS=swift",
]
cmake_args += ["-DSWIFT_BUILD_ONLY_SYNTAXPARSERLIB=TRUE"]
cmake_args += [
"-DSWIFT_BUILD_ONLY_SYNTAXPARSERLIB=TRUE",
"-DSWIFT_BUILD_SYNTAXPARSERTEST=TRUE",
]
cmake_args += ["-DSWIFT_BUILD_PERF_TESTSUITE=NO", "-DSWIFT_INCLUDE_DOCS=NO"]
cmake_args += [
"-DSWIFT_BUILD_REMOTE_MIRROR=FALSE",
Expand All @@ -253,7 +257,10 @@ class Builder(object):
"-DCLANG_INCLUDE_TESTS=FALSE",
"-DSWIFT_INCLUDE_TESTS=FALSE",
]
cmake_args += [os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "llvm")]
llvm_src_path = os.path.join(SWIFT_SOURCE_ROOT, "llvm") \
if isSwiftContainedInLLVMProject \
else os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "llvm")
cmake_args += [llvm_src_path]
self.call(cmake_args, env=environment)

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

swift_src_path = os.path.join(SWIFT_SOURCE_ROOT, "swift")
swift_src_in_llvm_project_path = \
os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "swift")
# Need to symlink 'swift' into 'llvm-project' since we will be doing
# a unified configure with 'swift' as an external project.
if not os.path.exists(swift_src_in_llvm_project_path):
print("Symlinking '%s' to '%s'" %
(swift_src_path, swift_src_in_llvm_project_path), file=sys.stderr)
shell.symlink(swift_src_path, swift_src_in_llvm_project_path,
dry_run=args.dry_run, echo=args.verbose)
if not isSwiftContainedInLLVMProject:
swift_src_path = os.path.join(SWIFT_SOURCE_ROOT, "swift")
swift_src_in_llvm_project_path = \
os.path.join(SWIFT_SOURCE_ROOT, "llvm-project", "swift")
# Need to symlink 'swift' into 'llvm-project' since we will be doing
# a unified configure with 'swift' as an external project.
if not os.path.exists(swift_src_in_llvm_project_path):
print("Symlinking '%s' to '%s'" %
(swift_src_path, swift_src_in_llvm_project_path), file=sys.stderr)
shell.symlink(swift_src_path, swift_src_in_llvm_project_path,
dry_run=args.dry_run, echo=args.verbose)

architectures = args.architectures.split(" ")
architectures = [arch for arch in architectures if arch != ""]
Expand Down