-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Python-only build script #23038
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
Python-only build script #23038
Conversation
Are TODOs in FIFO order? Make is pretty important. Nice writeup. |
The only "interesting" part of building these is that you will need support for installing the earlier parts of the toolchain. |
@openloop: the order was as they were coming to my mind. No other intentional order. @benlangmuir: All right. I wasn't sure why they were done after the rest of the projects had finished the build-test-install steps. That's something I will have to had into account. Thanks for pointing it out. Do you remember why they have to be installed? Dispatch and Foundation use Swift in the build directory without first installing it. Can those other do the same? |
As a quick note, I think non- |
@Rostepher: Totally agree. There's a mix here between compatibility with Python 3, compatibility with Windows and the new build script. Most of the changes for Python 3 should be sent independently. I'm working in all at the same time because it makes sense to have everything in the same branch (for me). But I will have to split them in smaller PRs. And I will do it when I'm sure they are mostly stable and unchanging. |
Passing through all of the paths doesn't scale, particularly for tools that are downstream of swiftpm or Foundation. There's more information at https://forums.swift.org/t/rfc-building-swift-packages-in-build-script/18920 |
That write up is great. Thanks for sharing. I wonder why both |
I don't know if there is a principled reason for the current state of affairs. I suggest not trying to change the order of operations at the same time as rewriting the infrastructure. |
869b16b
to
3baed25
Compare
@@ -86,7 +86,7 @@ def main(): | |||
console.setLevel(level=args.log.upper()) | |||
logging.debug(args) | |||
environment = os.environ.copy() | |||
environment['GIT_EXTERNAL_DIFF'] = script_path | |||
environment['GIT_EXTERNAL_DIFF'] = script_path.replace('\\', '/') |
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 could've sworn that that there was a path utility to convert the slashes in python.
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.
It looks like os.path.normpath
does what you're looking for.
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.
It does the opposite if I read the documentation right: “On Windows, it converts forward slashes to backward slashes.”. In this case, for some reason, GIT_EXTERNAL_DIFF
was removing the backward slashes from the path, but worked when I provided the forward slashes. I can add a comment explaining why it is needed.
The changes in gyb_syntax_support are simple rewrites of the import statements to work both in Python 3 and 2. The changes in the gyb files themselves are some of the problems found by compiling, like expecting integer division and printing floats, and usage of xrange/range.
In many cases, the changes are related to the handling of files, using io.open instead of open to improve compatibility.
For some reason, GIT_EXTERNAL_DIFF in Windows remove the Windows slashes of the value. Fortunately, replacing the Windows path separator for the Linux one seems to work and solves that problem.
Switch the ambigous relative imports to Python 3 relative imports (supported in Python 2.7). Only perform the renaming of the main script in Python 2, or Python 3 will fall into a recursive loop (if the workaround is removed, Python 2 falls into a similar recursive loop). Finally add a couple of decode() calls for the output/error of the shell utilities to be printed as text in Python 3.
11d4787
to
0c6a2c3
Compare
Abandoning this 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 partial reimplementation of
build-script-impl
into Python. This was necessary if we wanted to build on Windows with thebuild-script
. At the same time it includes fixes for compatibility with Python 3 (keeping code backwards compatible with Python 2).Currently it can build and test CMark, LLVM, Swift and LLDB (the test fail in Windows, but that's not the point).
I tried to follow the design that I can intuited in the current Python code, but I have to diverge in some points (because I wanted to keep the usage of
build-script-impl
untouched during the migration). A new parameter--native-impl
allows to use the new code while still allowing the usage of the old code.I hope the ideas I introduce makes sense and we can move forward with this. It would be great to have the Windows builds using the same process than the rest of the builds, and I think it would be a requirement for being integrated with the community CI. This rewrites will also help to future modifications of the build script, since information and process will not have to be duplicated in two places.
Any feedback is appreciated.
Changes
HostSpecificConfiguration
into its own file to be shared between the main script and the products that need to make use of it to recover CMake targets (mostly Swift, at the moment). There's also changes to avoid depending on the invocation object directly and be less tied to it.BuildScriptInvocation
has been moved intoBuildScriptBase
, and it is shared with its subtypesBuildScriptInvocation
andBuildScriptNative
.Base
will invoke different (abstract) methods, that the subtypes implement to either invokebuild-script-impl
with the right arguments, or start executing some Python code for each product.CMakeProductBuilder
(currently inproducts/product.py
, but should be moved out). It implements the common logic for building with CMake, and provides many templated methods/properties for the products to customize. CMark, LLVM, Swift and LLDB use this builder as a base.CMake
type learns a couple new tricks and help invoking CMake for generating the build files, and for both building targets and installing targets.build-script-impl
tobuild-script
in order to get access to their values during the build process. All of them should be forwarded tobuild-script-impl
. When the arguments where used in one of the build presets, I tried to keep compatibility with how thebuild-script-impl
argument seemed to work..cmd
wrapper is provided (build-script.cmd
,coverage-touch-tests.cmd
), but in other cases, Python is invoked internally (likellvm-lit.py
).TODO
install
actions do not work.merge
,extractsymbols
andpackage
do not work either.build-script-impl
. Is it worth it to bring them over, or can the code be removed?build-script-impl
to check the arguments if using the native implementation. It will not work on Windows (for example). I have a workaround locally, but it should be encoded into the script (no need to check the arguments againstimpl
if we are not going to use it)./cc @Rostepher @shahmishal
/cc @benlangmuir: I saw that you modified the code recently to build indexstore-db and sourcekit-lsp. I think the new design I propose will work with those changes. If you have any feedback, please don't hesitate to comment.