-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Build script builders #23257
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
Build script builders #23257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really happy about moving the responsibility for invoking build-script-impl
into the Product. I think this is a natural evolution toward killing build-script-impl ❤️
I skimmed over the patch, and it seems reasonable to me, but I haven't dug into the details.
One thing that I'm curious about: is it possible to verify that this doesn't change the invocations to build-script-impl, for example using --dry-run
and comparing with the previous behaviour? If we could do that for all of our presets, that would be great.
utils/swift_build_support/swift_build_support/products/product_builder.py
Show resolved
Hide resolved
# | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know why I remember changing that. It must have been in a parallel dimension. I will fix it everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will see if there's a way to run with dry-run and compare before and after these changes. I'm afraid that I will have modified the order of some arguments and maybe some values, which might make comparing a little harder.
utils/swift_build_support/swift_build_support/products/product_builder.py
Show resolved
Hide resolved
# | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know why I remember changing that. It must have been in a parallel dimension. I will fix it everywhere.
ea717ae
to
11a8a9b
Compare
Good idea running the dry-run. I found two problems: the tests for the products built without Additionally, in the new version To test I wrote a couple of small scripts (https://gist.github.com/drodriguez/8bc2a0c228b7afad5cec97448dd04bec): one that listed every preset in the preset file and run it with dry-run (skipping mixins and |
Nice! Thanks for testing it out. It gives me a lot of confidence in the change to know it gives the same commands.
I think right now "libcxx" is using llvm_cmake_options; could you take a look? Otherwise I think you're right and only passing the relevant options is a nice simplification. |
It is quite complicated to trace
|
Ah, thanks for clearing up my confusion. |
11a8a9b
to
c6908ee
Compare
@Rostepher: I’m sorry to bother you again. It would be great to have this PR moving again, since it is interesting for the Windows work, and it will allow me to also try to compile more pieces for the Android targets when all the pieces are there. If you think someone else should review this, that's also fine. For the time being, it would be nice to have the test passing (I have commit access, but I still don’t have swift-ci access for some reason). If anyone want to see how this is used later, I started uploading more pieces into my repo. The LLVM builder needs to be the first one, since other builders depend on it. It is also one of the most complicated ones. The code is at https://github.com/drodriguez/swift/tree/llvm-builder. Another example is the CMark builder, which builds on top of the LLVM one. The code is at https://github.com/drodriguez/swift/tree/cmark-builder. Thanks. |
@swift-ci please test |
Build failed |
Build failed |
This will allow using HostSpecificConfiguration from other parts that are not the main script in the future. Additionally, a lot of code that was part of BuildScriptInvocation has been moved into HostSpeficiaConfiguration because nobody else needed it, and HostSpecificConfiguration was highly coupled with the Invocation object (through one of its arguments). This should make the Configuration object a better citizen in other scenarios.
ProductBuilder allows us to tackle the different way than the different products need to be build. The builders follow a very simple interface, but inside them the details are hidden. Previously the Ninja product was both a Product and ProductBuilder. The methods that did the build have moved into ProductBuilder to match the future ProductBuilders.
BuildScriptImplBuilder is a ProductBuilder that invokes build-script-impl to work. The implementation is moved code from the main script BuildScriptInvocation type into the new builder. This will allow us to replace each of the product builders one by one and check them before commiting to the new system. There's a little reorganization in the execute method of BuildScriptInvocation to make it less tied to the whims of build-script-impl.
…Builders. Create a new helper for IndexStoreDB and SourcekitLSP called BuildScriptHelperBuilder. Move most of the code that existed in a function in indexstoredb.py into that helper object. Create small builders for IndexStoreDB and SourcekitLSP which use this helper object as their base. Modify the main build-script to invoke the new builder instead of the specific do_build/do_test. This way, all products are using the same system to be build, but some use build-script-impl, and others use build-script-helper.py.
c6908ee
to
8afd7f4
Compare
Thanks @compnerd for starting the tests. I hope I have fixed the problem with the last push. I will also start creating smaller PR with each of the commits to try to make these reviews less difficult. I hope with smaller commits the code movements will be clearer. |
Abandoning these efforts. It might still be useful for better Windows builds for most of the community, but I will not have time to keep improving this and it doesn't seem to be a lot of interest in improving the build system in this direction. |
Applies to SR-237
This is a transition version of #23038. I tried to reduce the code to only the essential to show the idea behind the “product builders”. This version hides the invocations to
build-script-impl
in a builder, and that way, one can replace each product builder one by one, which should make reviews easier.This is probably easier to look at commit by commit, because the code movements are clearer. There are three commits that mostly move code from one file to another:
shell
.HostSpecificConfiguration
from the main script into its own file, and also bring parts ofBuildScriptInvocation
with it.BuildScriptInvocation
that dealt with transforming the Python arguments intobuild-script-impl
arguments intoBuildScriptImplBuilder
.The final intention of this changes is replacing
build-script-impl
to allow the build script to not depend on Bash, and be compatible with Windows./cc @Rostepher, @benlangmuir, @compnerd