blob: b8a7b39de82fcbbac77d1b6e28b80b26965a7a73 [file] [log] [blame]
Mike Klein552cd132016-10-26 13:32:07 -04001#!/usr/bin/env python
2#
3# Copyright 2016 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8import os
9import sys
10
11# We'll read a single named list of paths from a .gni file.
12gni, name = sys.argv[1:]
13
14# The .gni files we want to read are close enough to Python syntax
15# that we can use execfile() if we supply definitions for GN builtins.
16
17def get_path_info(path, kind):
18 assert kind == "abspath"
19 # While we want absolute paths in GN, GYP prefers relative paths.
20 return path
21
22builtins = {
23 'get_path_info': get_path_info,
24}
25definitions = {}
26execfile(gni, builtins, definitions)
27
28# definitions now holds all the values defined in the .gni.
29paths = definitions[name]
30
31# Perform any string substitutions.
32for var in definitions:
33 if type(definitions[var]) is str:
34 paths = [ p.replace('$'+var, definitions[var]) for p in paths ]
35
36# Print the path list, to be received by <!@ syntax in GYP.
37for p in paths:
38 print p