Created
December 16, 2019 16:55
-
-
Save danielfullmer/a5adf47e6532062751c9f0ccfd81cc9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#!nix-shell -i python -p python2 | |
import gclient_eval | |
# Normally set in gclient.py | |
target_os = [ "android" ] | |
target_cpu = [ "arm64" ] | |
builtin_vars={ | |
'checkout_android': 'android' in target_os, | |
'checkout_chromeos': 'chromeos' in target_os, | |
'checkout_fuchsia': 'fuchsia' in target_os, | |
'checkout_ios': 'ios' in target_os, | |
'checkout_linux': 'unix' in target_os, | |
'checkout_mac': 'mac' in target_os, | |
'checkout_win': 'win' in target_os, | |
'checkout_arm': 'arm' in target_cpu, | |
'checkout_arm64': 'arm64' in target_cpu, | |
'checkout_x86': 'x86' in target_cpu, | |
'checkout_mips': 'mips' in target_cpu, | |
'checkout_mips64': 'mips64' in target_cpu, | |
'checkout_ppc': 'ppc' in target_cpu, | |
'checkout_s390': 's390' in target_cpu, | |
'checkout_x64': 'x64' in target_cpu, | |
'host_os': 'linux', # See _PLATFORM_MARPPING in tools/gclient.py | |
'host_cpu': 'x64', # See tools/detect_host_arch.py. Luckily this variable is not really currently used much | |
} | |
f = open('flat').read() | |
v = gclient_eval.Parse(f, validate_syntax=True, filename='DEPS', | |
vars_override={}, builtin_vars=builtin_vars) | |
merged_vars = dict(v['vars']) | |
merged_vars.update(builtin_vars) | |
for dep, fields in v['deps'].iteritems(): | |
# Skip dependency if its condition evaluates to False | |
if 'condition' in fields: | |
if not gclient_eval.EvaluateCondition(fields['condition'], merged_vars): | |
continue | |
if fields['dep_type'] == "git": | |
url, rev = fields['url'].split('@') | |
print url, rev | |
elif fields['dep_type'] == "cipd": | |
for p in fields['packages']: | |
package, version = p['package'], p['version'] | |
print package, version | |
else: | |
raise ValueError("Unrecognized dep_type", fields['dep_type']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment