You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_tools/win_toolchain
Nico Weber 499a2fd61b Reland "win toolchain: Prepare downloader for windows sdk dir switch"
This is a reland of e72789f5b4

Original change's description:
> win toolchain: Prepare downloader for windows sdk dir switch
>
> crrev.com/c/2655836 tries to move the Windows SDK from
> "win_sdk" to "Windows Kits/10".
>
> get_toolchain_if_necessary.py (in depot_tools) saves the path to the SDK to
> third_party/depot_tools/win_toolchain/data.json which then gets copied
> by a script in the chromium repo to build/win_toolchain.json.
> For the SDK move to work, chromium's pinned depot_tools
> must write the new SDK path when rolling in the new toolchain package.
> This change makes depot_tools handle win packages that have the
> windows sdk either win "win_sdk" or in "Windows Kits\10".
>
> The plan is:
>
> 1. Land this change, which can handle both path styles
> 2. Wait for depot_tools in chromium to update
> 3. Then roll to a win toolchain package with the new layout
>
> In a few years, when we no longer need the old layout,
> we can remove this detection code again and assume the new layout.
>
> Bug: 1173176
> Change-Id: Iaefc5c16685d3dbfff87a3e50a7b20b457366e44
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2666429
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Auto-Submit: Nico Weber <thakis@chromium.org>
> Reviewed-by: Bruce Dawson <brucedawson@chromium.org>

Bug: 1173176,1173393
Change-Id: Ic706f694f8f0260208fa637864e62d7cc4f7ce93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2668127
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
4 years ago
..
OWNERS Add brucedawson@ to win_toolchain/OWNERS 9 years ago
README.md Add README.md for win_toolchain 10 years ago
get_toolchain_if_necessary.py Reland "win toolchain: Prepare downloader for windows sdk dir switch" 4 years ago
package_from_installed.py Print packaging file size/count stats always 5 years ago

README.md

Automatic updates of the Windows toolchain

On the consumer side, e.g. in Chromium src.git:

  • vs_toolchain.py update is called early during DEPS. Update() asks depot_tools to put in place a particular version of the toolchain (whatever src will currently build with). src provides an output .json file, where Update() saves relevant information about the toolchain, the paths, version numbers, etc.
  • Later in DEPS, build/gyp_chromium uses vs_toolchain:SetEnvironmentAndGetRuntimeDllDirs(), which loads the .json file, and uses it to set a few GYP_ variables and update the PATH to include CRT runtime directories (see below).
  • Then, gyp_chromium runs gyp generation.
  • Finally, it uses vs_toolchain again to copy runtime dlls to the output directories.

The reason the logic was split between depot_tools and src was because at some point, the bots had insufficient hard drive space and if there were > 1 build directories (say, if a build machine handled the Release and Debug builds for a given configuration) then the duplication of the toolchain in both trees would cause the bot to run out of disk space.

On the depot_tools side:

get_toolchain_if_necessary.py takes an output .json file (per above) and an input SHA1. It tries to confirm that the user is probably a Google employee (or a bot) to encourage them to use the automatic toolchain rather than using a system installed one. It then uses gsutil to download the zip corresponding to the hash. This requires authentication with @google.com credentials, so it walks the user through that process if necessary.

(Previously in the VS2010 and early VS2013 timeframe, we also supported building with Express editions of VS. Along with toolchain2013.py this script dealt with all the complexity of acquiring the Express ISO, SDK bits, patches, etc. and applying them all in the correct sequence. However, Express no longer works, and Community is not too hard to install properly, so we just let the user do that. The primary benefit of having an automatically updated toolchain is that it works for bots, allows changes to the toolchain to be tryjob'd, reduces Infra/Labs work, and ensures that devs match bots.)

For the above convoluted reason get_toolchain_if_necessary uses toolchain2013.py to extract the zip file, but the majority of the code in there is no longer used and what remains should be inlined into get_toolchain_if_necessary in the future.

When the zip file is extracted, the mtimes of all the files, and the sha1 of the entire tree are saved to a local file. This allows future updates to compare whether the bits of the toolchain currently on disk are different than expected (the passed in SHA1), and if so, replace it with a toolchain with the correct SHA1. This is probably a bit more complicated than necessary, and again dates back to when the toolchain was assembled from many pieces. It could probably just write a stamp file with the SHA1, or just a version number, and trust that on future runs.

Finally, it copies the json file to the location that the caller requested (the json file is generated during the unzip/acquire process in toolchain2013.py).

Building a .zip

Ignoring the toolchain2013.py steps to acquire a toolchain automatically from bits for Express, the procedure is roughly:

  • Get a clean Windows VM,
  • Install Visual Studio 2013 with updates as you want it,
  • Install Windows 8.1 SDK,
  • Run package_from_installed.py,
  • Upload the resulting zip file to the chrome-wintoolchain GS bucket.

That script first builds a zip file of the required pieces, including generating a batch file corresponding to SetEnv.cmd or vcvarsall.bat. It then extracts that zip to a temporary location and calculates the SHA1 in the same way that the depot_tools update procedure would do, so that it knows what to rename the zip file to.