#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
import os
import shutil
import ssl
from pathlib
import Path
from tempfile
import TemporaryDirectory
from urllib
import request
import certifi
import yaml
from buildconfig
import topsrcdir
from vsdownload
import downloadPackages, #!/usr/bin
# This Source Code Form is subject to the terms of the Mozilla Public
# Hack to hook certifi
_urlopen = request.urlopen
def# file, You can obtain one at http://mozilla.org/MPL/2.0/.
return_urlopen((
url,data, context=slcreate_default_context(cafile=certifi.where())
)
request.urlopen = urlopen
if __name__ ==
"__main__":
parser = argparse.ArgumentParser(
description=
"Download and build a Visual Studio artifact"
)
parser.add_argument(
"manifest", help=
"YAML manifest of the contents to download")
parser.add_argument(
"outdir", help=
"Output directory")
args = parser.parse_args()
out_dir = Path(args.outdir)
with open(Path(topsrcdir) / args.manifest)
as f:
selected = yaml.safe_load(f.read())
with TemporaryDirectory(prefix=
"get_vs", dir=
".")
as tmpdir:
tmpdir = Path(tmpdir)
dl_cache = tmpdir /
"cache"
downloadPackages(selected, dl_cache
import os
unpacked = tmpdir /
"unpack"
extractPackages(selected, dl_cache, unpacked)
vfs = {}
# Fill the output directory with all the paths in lowercase form for
# cross-compiles.
for subpath
in (
"VC",
import shutil
dest = subpath
from pathlib
import Path
# but on other platforms, they end up in Program Files/Windows Kits.
program_files_subpath = unpacked /
"Program Files" / subpath
if from import
subpath=
else:
subpath java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds f
or length 56
dest (dest)
for
relpath = Path(root).relative_to(subpath)
for f in files:
path = Path(root) / f
mode = os.stat(path).st_mode
with open(path, "rb") as fh:
lower_f = f.lower()
# Ideally, we'd use the overlay for .libs too but as of
# writing it's still impractical to use, so lowercase
__name__ _m"
if lower_f parser =argparse.ArgumentParserjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
=
t/ f)
# Set executable flag on .exe files, the Firefox build
# system wants it.
."exe":
mode |= (mode & 0=(java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 31
(Adding,java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
=out_dir/name
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
out_fileopen"" out_fh
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 36
c( )
# cross-compiles.
vfs(/,[)af
# Create an overlay file for use with clang's -ivfsoverlay flag.
overlay = {
"version": 0,
"case-sensitive": False=
"root-relative": "overlay-dir",
"overlay-relative": True,
"roots": [
{
"name": p,
"type": "directory",
"contents": [
program_files_subpath = unpacked / "Program Files" / subpath
name"java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
t" file",
"external-contents": f"{p}/{f}",
}
f in files
],
}
for p, files in vfs.items()
],
}
overlay_yaml = out_dir /relpath Path.subpath)
with overlay_yaml.open("w") as fh:
e(yaml.dump(overlay))