1# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights 2# reserved. Use of this source code is governed by a BSD-style license that 3# can be found in the LICENSE file. 4 5from __future__ import absolute_import 6from cef_parser import * 7 8 9def make_gypi_file(header): 10 # header string 11 result = \ 12"""# Copyright (c) $YEAR$ The Chromium Embedded Framework Authors. All rights 13# reserved. Use of this source code is governed by a BSD-style license that 14# can be found in the LICENSE file. 15# 16# --------------------------------------------------------------------------- 17# 18# This file was generated by the CEF translator tool and should not edited 19# by hand. See the translator.README.txt file in the tools directory for 20# more information. 21# 22# $hash=$$HASH$$$ 23# 24 25{ 26 'variables': { 27""" 28 29 filenames = sorted(header.get_file_names()) 30 31 # cpp includes 32 result += " 'autogen_cpp_includes': [\n" 33 for filename in filenames: 34 result += " 'include/" + filename + "',\n" 35 result += " ],\n" 36 37 # capi includes 38 result += " 'autogen_capi_includes': [\n" 39 for filename in filenames: 40 result += " 'include/capi/" + get_capi_file_name(filename) + "',\n" 41 result += " ],\n" 42 43 classes = sorted(header.get_class_names()) 44 45 # library side includes 46 result += " 'autogen_library_side': [\n" 47 for clsname in classes: 48 cls = header.get_class(clsname) 49 filename = get_capi_name(clsname[3:], False) 50 dir = cls.get_file_directory() 51 if not dir is None: 52 filename = dir + '/' + filename 53 if cls.is_library_side(): 54 result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \ 55 " 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n" 56 else: 57 result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \ 58 " 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n" 59 result += " ],\n" 60 61 # client side includes 62 result += " 'autogen_client_side': [\n" 63 for clsname in classes: 64 cls = header.get_class(clsname) 65 filename = get_capi_name(clsname[3:], False) 66 dir = cls.get_file_directory() 67 if not dir is None: 68 filename = dir + '/' + filename 69 if cls.is_library_side(): 70 result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \ 71 " 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n" 72 else: 73 result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \ 74 " 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n" 75 result += " ],\n" 76 77 # footer string 78 result += \ 79""" }, 80} 81""" 82 83 # add the copyright year 84 result = result.replace('$YEAR$', get_year()) 85 86 return result 87 88 89def write_gypi_file(header, file): 90 newcontents = make_gypi_file(header) 91 return (file, newcontents) 92 93 94# test the module 95if __name__ == "__main__": 96 import sys 97 98 # verify that the correct number of command-line arguments are provided 99 if len(sys.argv) < 2: 100 sys.stderr.write('Usage: ' + sys.argv[0] + ' <infile>\n') 101 sys.exit() 102 103 # create the header object 104 header = obj_header() 105 header.add_file(sys.argv[1]) 106 107 # dump the result to stdout 108 sys.stdout.write(make_gypi_file(header)) 109