| 951 | |
| 952 | |
| 953 | def GNArgs(self, vals, expand_imports=False): |
| 954 | if vals['cros_passthrough']: |
| 955 | if not 'GN_ARGS' in os.environ: |
| 956 | raise MBErr('MB is expecting GN_ARGS to be in the environment') |
| 957 | gn_args = os.environ['GN_ARGS'] |
| 958 | if not re.search('target_os.*=.*"chromeos"', gn_args): |
| 959 | raise MBErr('GN_ARGS is missing target_os = "chromeos": (GN_ARGS=%s)' % |
| 960 | gn_args) |
| 961 | else: |
| 962 | gn_args = vals['gn_args'] |
| 963 | |
| 964 | android_version_code = self.args.android_version_code |
| 965 | if android_version_code: |
| 966 | gn_args += ' android_default_version_code="%s"' % android_version_code |
| 967 | |
| 968 | android_version_name = self.args.android_version_name |
| 969 | if android_version_name: |
| 970 | gn_args += ' android_default_version_name="%s"' % android_version_name |
| 971 | |
| 972 | args_gn_lines = [] |
| 973 | parsed_gn_args = {} |
| 974 | |
| 975 | args_file = vals.get('args_file', None) |
| 976 | if args_file: |
| 977 | if expand_imports: |
| 978 | content = self.ReadFile(self.ToAbsPath(args_file)) |
| 979 | parsed_gn_args = gn_helpers.FromGNArgs(content) |
| 980 | else: |
| 981 | args_gn_lines.append('import("%s")' % args_file) |
| 982 | |
| 983 | # Canonicalize the arg string into a sorted, newline-separated list |
| 984 | # of key-value pairs, and de-dup the keys if need be so that only |
| 985 | # the last instance of each arg is listed. |
| 986 | parsed_gn_args.update(gn_helpers.FromGNArgs(gn_args)) |
| 987 | args_gn_lines.append(gn_helpers.ToGNString(parsed_gn_args)) |
| 988 | |
| 989 | return '\n'.join(args_gn_lines) |
| 990 | |
| 991 | def ToAbsPath(self, build_path, *comps): |
| 992 | return self.PathJoin(self.chromium_src_dir, |