mirror of
https://github.com/servo/servo.git
synced 2025-07-02 04:53:39 +01:00
Use the bootstraped Android toolchains by default
This commit is contained in:
parent
65122b10d3
commit
fc77db4b09
3 changed files with 18 additions and 18 deletions
|
@ -77,10 +77,10 @@ class MachCommands(CommandBase):
|
||||||
if not path.isdir(toolchains):
|
if not path.isdir(toolchains):
|
||||||
os.makedirs(toolchains)
|
os.makedirs(toolchains)
|
||||||
|
|
||||||
def download(name, target_dir, flatten=False):
|
def download(target_dir, name, flatten=False):
|
||||||
final = path.join(toolchains, target_dir)
|
final = path.join(toolchains, target_dir)
|
||||||
if path.isdir(final):
|
if path.isdir(final):
|
||||||
return final
|
return
|
||||||
|
|
||||||
base_url = "https://dl.google.com/android/repository/"
|
base_url = "https://dl.google.com/android/repository/"
|
||||||
filename = name + ".zip"
|
filename = name + ".zip"
|
||||||
|
@ -100,16 +100,15 @@ class MachCommands(CommandBase):
|
||||||
os.rmdir(extracted)
|
os.rmdir(extracted)
|
||||||
else:
|
else:
|
||||||
extract(archive, final, remove=remove)
|
extract(archive, final, remove=remove)
|
||||||
return final
|
|
||||||
|
|
||||||
system = platform.system().lower()
|
system = platform.system().lower()
|
||||||
machine = platform.machine().lower()
|
machine = platform.machine().lower()
|
||||||
arch = {"i386": "x86"}.get(machine, machine)
|
arch = {"i386": "x86"}.get(machine, machine)
|
||||||
ndk_path = download(ndk.format(system=system, arch=arch), "ndk", flatten=True)
|
download("ndk", ndk.format(system=system, arch=arch), flatten=True)
|
||||||
tools_path = download(tools.format(system=system), "sdk")
|
download("sdk", tools.format(system=system))
|
||||||
|
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
path.join(tools_path, "tools", "bin", "sdkmanager"),
|
path.join(toolchains, "sdk", "tools", "bin", "sdkmanager"),
|
||||||
"platform-tools",
|
"platform-tools",
|
||||||
"build-tools;" + sdk_build_tools,
|
"build-tools;" + sdk_build_tools,
|
||||||
"emulator",
|
"emulator",
|
||||||
|
@ -123,7 +122,7 @@ class MachCommands(CommandBase):
|
||||||
])
|
])
|
||||||
for avd_name, api_level, system_image in emulator_images:
|
for avd_name, api_level, system_image in emulator_images:
|
||||||
process = subprocess.Popen(stdin=subprocess.PIPE, stdout=subprocess.PIPE, args=[
|
process = subprocess.Popen(stdin=subprocess.PIPE, stdout=subprocess.PIPE, args=[
|
||||||
path.join(tools_path, "tools", "bin", "avdmanager"),
|
path.join(toolchains, "sdk", "tools", "bin", "avdmanager"),
|
||||||
"create", "avd",
|
"create", "avd",
|
||||||
"--path", path.join(toolchains, "avd", avd_name),
|
"--path", path.join(toolchains, "avd", avd_name),
|
||||||
"--name", avd_name,
|
"--name", avd_name,
|
||||||
|
@ -148,15 +147,6 @@ class MachCommands(CommandBase):
|
||||||
with open(path.join(toolchains, "avd", avd_name, "config.ini"), "a") as f:
|
with open(path.join(toolchains, "avd", avd_name, "config.ini"), "a") as f:
|
||||||
f.write("disk.dataPartition.size=1G\n")
|
f.write("disk.dataPartition.size=1G\n")
|
||||||
|
|
||||||
print("")
|
|
||||||
print("export ANDROID_SDK=\"%s\"" % tools_path)
|
|
||||||
print("export ANDROID_NDK=\"%s\"" % ndk_path)
|
|
||||||
print("export PATH=\"%s:$PATH\"" % path.join(tools_path, "platform-tools"))
|
|
||||||
print("")
|
|
||||||
# https://developer.android.com/studio/run/emulator-acceleration#command-gpu
|
|
||||||
print(path.join(tools_path, "tools", "emulator") +
|
|
||||||
" @servo-armv7 -gpu swiftshader_indirect [ -no-window ]")
|
|
||||||
|
|
||||||
@Command('update-hsts-preload',
|
@Command('update-hsts-preload',
|
||||||
description='Download the HSTS preload list',
|
description='Download the HSTS preload list',
|
||||||
category='bootstrap')
|
category='bootstrap')
|
||||||
|
|
|
@ -260,10 +260,10 @@ class MachCommands(CommandBase):
|
||||||
env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions"
|
env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions"
|
||||||
|
|
||||||
if android:
|
if android:
|
||||||
if "ANDROID_NDK" not in os.environ:
|
if "ANDROID_NDK" not in env:
|
||||||
print("Please set the ANDROID_NDK environment variable.")
|
print("Please set the ANDROID_NDK environment variable.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if "ANDROID_SDK" not in os.environ:
|
if "ANDROID_SDK" not in env:
|
||||||
print("Please set the ANDROID_SDK environment variable.")
|
print("Please set the ANDROID_SDK environment variable.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -525,6 +525,16 @@ class CommandBase(object):
|
||||||
if self.config["android"]["platform"]:
|
if self.config["android"]["platform"]:
|
||||||
env["ANDROID_PLATFORM"] = self.config["android"]["platform"]
|
env["ANDROID_PLATFORM"] = self.config["android"]["platform"]
|
||||||
|
|
||||||
|
toolchains = path.join(self.context.topdir, "android-toolchains")
|
||||||
|
for kind in ["sdk", "ndk"]:
|
||||||
|
default = os.path.join(toolchains, kind)
|
||||||
|
if os.path.isdir(default):
|
||||||
|
env.setdefault("ANDROID_" + kind.upper(), default)
|
||||||
|
|
||||||
|
tools = os.path.join(toolchains, "sdk", "platform-tools")
|
||||||
|
if os.path.isdir(tools):
|
||||||
|
env["PATH"] = "%s%s%s" % (tools, os.pathsep, env["PATH"])
|
||||||
|
|
||||||
# These are set because they are the variable names that build-apk
|
# These are set because they are the variable names that build-apk
|
||||||
# expects. However, other submodules have makefiles that reference
|
# expects. However, other submodules have makefiles that reference
|
||||||
# the env var names above. Once glutin is enabled and set as the
|
# the env var names above. Once glutin is enabled and set as the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue