Building specific target with the build script and Ninja

Does the build script support a way to build a specific target and the bare minimum of its dependencies?

For example, say I wanted to build the swift-lldb driver, I can use

./swift/utils/build-script --release --lldb

which will give me the lldb driver but will also build a whole lot of things that I don't necessarily need to run the lldb driver. Things such as StaticAnalyzer and clang-tidy/android are getting compiled which I don't necessarily need. I can slim down the build by cutting out some parts of the build and ending up with a command like:

./swift/utils/build-script --lldb \
--release \
--no-assertions \
--llvm-targets-to-build=X86 \
--build-swift-examples=0 \
-- \
--swift-stdlib-build-type=Release \
--swift-stdlib-enable-assertions=true \
--stdlib-deployment-targets=macosx-x86_64 \
--swift-primary-variant-sdk=OSX \
--swift-primary-variant-arch=x86_64 \
--lldb-no-debugserver \
--lldb-use-system-debugserver \
--lldb-build-type=Release \
--skip-build-ios \
--skip-build-tvos \
--skip-build-watchos \
--skip-build-linux \
--skip-build-freebsd \
--skip-build-cygwin \
--skip-build-clang-tools-extra \
--skip-build-benchmarks \
--skip-test-osx \
--skip-test-ios \
--skip-test-ios-32bit-simulator \
--skip-test-tvos \
--skip-test-watchos \
--skip-test-cmark \
--skip-test-lldb \
--skip-test-swift

That does build a lot less but is there a way to instead specify what I do want to build and not what I don't want to build? I tried running the build script to generate only the build files, skipping the build step, and then have ninja build only the lldb driver target.

e.g.

  • ./swift/utils/build-script --release --skip-build --llvm-targets-to-build X86
  • ninja -C build/Ninja-ReleaseAssert/lldb-macosx-x86_64/ lldb

But that won't work since Ninja doesn't build the swift or llvm dependencies so we'll get errors like

ninja: error: '~/swift-lldb/build/Ninja-ReleaseAssert/swift-macosx-x86_64/lib/libswiftASTSectionImporter.a', needed by 'bin/LLDB.framework/Versions/A/LLDB', missing and no known rule to make it

Is there a better way to accomplish this or is a custom build preset with all the exclusions the recommended way to go about this?

Terms of Service

Privacy Policy

Cookie Policy