| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2016, the Dart project authors. Please see the AUTHORS file | |
| 3 # for details. All rights reserved. Use of this source code is governed by a | |
| 4 # BSD-style license that can be found in the LICENSE file. | |
| 5 | |
| 6 import gn_helpers | |
| 7 import os.path | |
| 8 import sys | |
| 9 | |
| 10 # Given a list of dart package names read in the set of runtime and sdk library | |
| 11 # sources into variables in a gn scope. | |
| 12 | |
| 13 | |
| 14 def LoadPythonDictionary(path): | |
| 15 file_string = open(path).read() | |
| 16 try: | |
| 17 file_data = eval(file_string, {'__builtins__': None}, None) | |
| 18 except SyntaxError, e: | |
| 19 e.filename = path | |
| 20 raise | |
| 21 except Exception, e: | |
| 22 raise Exception('Unexpected error while reading %s: %s' % | |
| 23 (path, str(e))) | |
| 24 | |
| 25 assert isinstance( | |
| 26 file_data, dict), '%s does not eval to a dictionary' % path | |
| 27 return file_data | |
| 28 | |
| 29 | |
| 30 def main(): | |
| 31 dart_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| 32 runtime_dir = os.path.join(dart_root_dir, 'runtime') | |
| 33 runtime_lib_dir = os.path.join(runtime_dir, 'lib') | |
| 34 sdk_lib_dir = os.path.join(dart_root_dir, 'sdk', 'lib') | |
| 35 libs = sys.argv[1:] | |
| 36 data = {} | |
| 37 data['allsources'] = [] | |
| 38 | |
| 39 for lib in libs: | |
| 40 runtime_path = os.path.join(runtime_lib_dir, lib + '_sources.gypi') | |
| 41 sdk_path = os.path.join(sdk_lib_dir, lib, lib + '_sources.gypi') | |
| 42 runtime_dict = LoadPythonDictionary(runtime_path) | |
| 43 for source in runtime_dict['sources']: | |
| 44 data['allsources'].append(source) | |
| 45 data[lib + '_runtime_sources'] = runtime_dict['sources'] | |
| 46 sdk_dict = LoadPythonDictionary(sdk_path) | |
| 47 data[lib + '_sdk_sources'] = sdk_dict['sources'] | |
| 48 | |
| 49 vm_sources_path = os.path.join(runtime_dir, 'vm', 'vm_sources.gypi') | |
| 50 vm_sources_dict = LoadPythonDictionary(vm_sources_path) | |
| 51 data['vm_sources'] = vm_sources_dict['sources'] | |
| 52 | |
| 53 platform_sources_base = os.path.join(runtime_dir, 'platform', 'platform_') | |
| 54 platform_headers_dict = LoadPythonDictionary( | |
| 55 platform_sources_base + 'headers.gypi') | |
| 56 platform_sources_dict = LoadPythonDictionary( | |
| 57 platform_sources_base + 'sources.gypi') | |
| 58 data['platform_sources'] = platform_headers_dict[ | |
| 59 'sources'] + platform_sources_dict['sources'] | |
| 60 | |
| 61 bin_io_sources_path = os.path.join(runtime_dir, 'bin', 'io_sources.gypi') | |
| 62 bin_io_sources_dict = LoadPythonDictionary(bin_io_sources_path) | |
| 63 data['bin_io_sources'] = bin_io_sources_dict['sources'] | |
| 64 | |
| 65 print gn_helpers.ToGNString(data) | |
| 66 return 0 | |
| 67 | |
| 68 if __name__ == '__main__': | |
| 69 sys.exit(main()) | |
| OLD | NEW |