servo: We don't want Python
Edit: Actually, instead of moving mach into a submodule, we should just not have to use any python scripts, as suggested by @SimonSapin.
For 3rd party projects embedding Servo, on Linux and Mac, cargo build is enough to build servo, but mach is necessary on Windows. First to download the necessary dependencies, and then to set the proper env variables.
At the moment, we copy mach, mach.bat and /python/ in the embedder code.
From the embedder perspective, it’s not great to have to copy and tweak the python scripts.
Would there be a way to “detach” mach from Servo and make it available as a 3rd party tool?
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 13
- Comments: 16 (12 by maintainers)
I needed to build servo-embed-example on windows and the mach dependency was annoying me, so I dug down into what is actually needed in order to build, and https://github.com/shana/servo/commit/afbd29ec314391cc307c376ae329630b0857561d is the result.
It turns out there’s only around 5 environment variables needed plus a few path adjustments, all very doable. I have a separate powershell script to download the dependencies, and the main bootstrap.bat script just sets up the command line with the required environment, ready for a
cargo buildinvocation.I didn’t do a PR because I know you’d rather have cargo scripts to do this, but I don’t know exactly how to set this stuff up in cargo in order for dependencies to pick up the proper environment variables (I wouldn’t mind fixing that if someone could point me to docs that show how that would work… but cargo doesn’t have postbuild steps, so I’m not sure if everything is possible just with cargo).
I hope having a clean list of the requirements is useful, at least 😛
Personally, I only see a benefit to removing mach and giving us a cargo-compatible build. I don’t see a benefit to replacing it with some other driver.
Yep, we should keep
mach, but the main thing is that a normal developer should be able to primarily work withcargo buildandcargo run, and they only need to use mach if:As mentioned in some other issue, cargo is a package manager, not a build system (I would argue that if it has a build command then it kinda is a build system but ¯_(ツ)_/¯), so cargo is probably not the best way to go to drive the whole thing. It would be nice if the build bits in cargo got moved into a separate project that would actually consider itself a build system, but until (or if) that happens, some pre and post build scripts probably need to happen.
I can run the build right now just with path and environment variables set (and doing that postbuild step once), so I think
mach buildis not doing anything special (unless I missed something, anyone know different?). I haven’t looked at all the code for all platforms that the python scripts do for bootstrapping and running the build, but windows is not the only platform that requires environment variables and things in the path, and it’s likely the most complicated.This means that the whole
mach buildthing can probably be replaced with 2 shell scripts, an environment boostrap script and a postbuild script, in 2 variants - bat for windows and sh for the rest. A third script for loading the environment, driving cargo commands, and running any post-command scripts needed can be optionally added as well, for ease of use and isolation testing. Having a script that sets up the shell environment properly would also be very useful for doing things like building apps that depend on servo itself. Does this make sense?Yes, we could do that.
The python scripts do a lot more than just setting the variables. But I don’t see why we couldn’t migrate all the features, step by step, into build scripts.
How feasible is to make mach unnecessary in the first place? What are these dependencies and environment variables? Could they be handled by Cargo build scripts?