| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Creates windows and posix stub files for a given set of signatures. | 6 """Creates windows and posix stub files for a given set of signatures. |
| 7 | 7 |
| 8 For libraries that need to be loaded outside of the standard executable startup | 8 For libraries that need to be loaded outside of the standard executable startup |
| 9 path mechanism, stub files need to be generated for the wanted functions. In | 9 path mechanism, stub files need to be generated for the wanted functions. In |
| 10 windows, this is done via "def" files and the delay load mechanism. On a posix | 10 windows, this is done via "def" files and the delay load mechanism. On a posix |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 # Constants defning the supported file types options. | 78 # Constants defning the supported file types options. |
| 79 FILE_TYPE_WIN_X86 = 'windows_lib' | 79 FILE_TYPE_WIN_X86 = 'windows_lib' |
| 80 FILE_TYPE_WIN_X64 = 'windows_lib_x64' | 80 FILE_TYPE_WIN_X64 = 'windows_lib_x64' |
| 81 FILE_TYPE_POSIX_STUB = 'posix_stubs' | 81 FILE_TYPE_POSIX_STUB = 'posix_stubs' |
| 82 FILE_TYPE_WIN_DEF = 'windows_def' | 82 FILE_TYPE_WIN_DEF = 'windows_def' |
| 83 | 83 |
| 84 # Template for generating a stub function definition. Includes a forward | 84 # Template for generating a stub function definition. Includes a forward |
| 85 # declaration marking the symbol as weak. This template takes the following | 85 # declaration marking the symbol as weak. This template takes the following |
| 86 # named parameters. | 86 # named parameters. |
| 87 # return_type: The return type. | 87 # return_type: The return type. |
| 88 # export: The macro used to alter the stub's visibility. |
| 88 # name: The name of the function. | 89 # name: The name of the function. |
| 89 # params: The parameters to the function. | 90 # params: The parameters to the function. |
| 90 # return_prefix: 'return ' if this function is not void. '' otherwise. | 91 # return_prefix: 'return ' if this function is not void. '' otherwise. |
| 91 # arg_list: The arguments used to call the stub function. | 92 # arg_list: The arguments used to call the stub function. |
| 92 STUB_FUNCTION_DEFINITION = ( | 93 STUB_FUNCTION_DEFINITION = ( |
| 93 """extern %(return_type)s %(name)s(%(params)s) __attribute__((weak)); | 94 """extern %(return_type)s %(name)s(%(params)s) __attribute__((weak)); |
| 94 %(return_type)s %(name)s(%(params)s) { | 95 %(return_type)s %(export)s %(name)s(%(params)s) { |
| 95 %(return_prefix)s%(name)s_ptr(%(arg_list)s); | 96 %(return_prefix)s%(name)s_ptr(%(arg_list)s); |
| 96 }""") | 97 }""") |
| 97 | 98 |
| 98 # Template for generating a variadic stub function definition with return | 99 # Template for generating a variadic stub function definition with return |
| 99 # value. | 100 # value. |
| 100 # Includes a forward declaration marking the symbol as weak. | 101 # Includes a forward declaration marking the symbol as weak. |
| 101 # This template takes the following named parameters. | 102 # This template takes the following named parameters. |
| 102 # return_type: The return type. | 103 # return_type: The return type. |
| 104 # export: The macro used to alter the stub's visibility. |
| 103 # name: The name of the function. | 105 # name: The name of the function. |
| 104 # params: The parameters to the function. | 106 # params: The parameters to the function. |
| 105 # arg_list: The arguments used to call the stub function without the | 107 # arg_list: The arguments used to call the stub function without the |
| 106 # variadic argument. | 108 # variadic argument. |
| 107 # last_named_arg: Name of the last named argument before the variadic | 109 # last_named_arg: Name of the last named argument before the variadic |
| 108 # argument. | 110 # argument. |
| 109 VARIADIC_STUB_FUNCTION_DEFINITION = ( | 111 VARIADIC_STUB_FUNCTION_DEFINITION = ( |
| 110 """extern %(return_type)s %(name)s(%(params)s) __attribute__((weak)); | 112 """extern %(return_type)s %(name)s(%(params)s) __attribute__((weak)); |
| 111 %(return_type)s %(name)s(%(params)s) { | 113 %(return_type)s %(export)s %(name)s(%(params)s) { |
| 112 va_list args___; | 114 va_list args___; |
| 113 va_start(args___, %(last_named_arg)s); | 115 va_start(args___, %(last_named_arg)s); |
| 114 %(return_type)s ret___ = %(name)s_ptr(%(arg_list)s, va_arg(args___, void*)); | 116 %(return_type)s ret___ = %(name)s_ptr(%(arg_list)s, va_arg(args___, void*)); |
| 115 va_end(args___); | 117 va_end(args___); |
| 116 return ret___; | 118 return ret___; |
| 117 }""") | 119 }""") |
| 118 | 120 |
| 119 # Template for generating a variadic stub function definition without | 121 # Template for generating a variadic stub function definition without |
| 120 # return value. | 122 # return value. |
| 121 # Includes a forward declaration marking the symbol as weak. | 123 # Includes a forward declaration marking the symbol as weak. |
| 122 # This template takes the following named parameters. | 124 # This template takes the following named parameters. |
| 123 # name: The name of the function. | 125 # name: The name of the function. |
| 124 # params: The parameters to the function. | 126 # params: The parameters to the function. |
| 127 # export: The macro used to alter the stub's visibility. |
| 125 # arg_list: The arguments used to call the stub function without the | 128 # arg_list: The arguments used to call the stub function without the |
| 126 # variadic argument. | 129 # variadic argument. |
| 127 # last_named_arg: Name of the last named argument before the variadic | 130 # last_named_arg: Name of the last named argument before the variadic |
| 128 # argument. | 131 # argument. |
| 129 VOID_VARIADIC_STUB_FUNCTION_DEFINITION = ( | 132 VOID_VARIADIC_STUB_FUNCTION_DEFINITION = ( |
| 130 """extern void %(name)s(%(params)s) __attribute__((weak)); | 133 """extern void %(name)s(%(params)s) __attribute__((weak)); |
| 131 void %(name)s(%(params)s) { | 134 void %(export)s %(name)s(%(params)s) { |
| 132 va_list args___; | 135 va_list args___; |
| 133 va_start(args___, %(last_named_arg)s); | 136 va_start(args___, %(last_named_arg)s); |
| 134 %(name)s_ptr(%(arg_list)s, va_arg(args___, void*)); | 137 %(name)s_ptr(%(arg_list)s, va_arg(args___, void*)); |
| 135 va_end(args___); | 138 va_end(args___); |
| 136 }""") | 139 }""") |
| 137 | 140 |
| 138 # Template for the preamble for the stub header file with the header guards, | 141 # Template for the preamble for the stub header file with the header guards, |
| 139 # standard set of includes, and namespace opener. This template takes the | 142 # standard set of includes, and namespace opener. This template takes the |
| 140 # following named parameters: | 143 # following named parameters: |
| 141 # guard_name: The macro to use as the header guard. | 144 # guard_name: The macro to use as the header guard. |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 first usage, the DSO must be present at load time of the main binary. | 513 first usage, the DSO must be present at load time of the main binary. |
| 511 | 514 |
| 512 To simulate the windows delay load procedure, we need to create a set of | 515 To simulate the windows delay load procedure, we need to create a set of |
| 513 stub functions that allow for correct linkage of the main binary, but | 516 stub functions that allow for correct linkage of the main binary, but |
| 514 dispatch to the dynamically resolved symbol when the module is initialized. | 517 dispatch to the dynamically resolved symbol when the module is initialized. |
| 515 | 518 |
| 516 This class takes a list of function signatures, and generates a set of stub | 519 This class takes a list of function signatures, and generates a set of stub |
| 517 functions plus initialization code for them. | 520 functions plus initialization code for them. |
| 518 """ | 521 """ |
| 519 | 522 |
| 520 def __init__(self, module_name, signatures): | 523 def __init__(self, module_name, export_macro, signatures): |
| 521 """Initializes PosixStubWriter for this set of signatures and module_name. | 524 """Initializes PosixStubWriter for this set of signatures and module_name. |
| 522 | 525 |
| 523 Args: | 526 Args: |
| 524 module_name: The name of the module we are writing a stub for. | 527 module_name: The name of the module we are writing a stub for. |
| 528 export_macro: A preprocessor macro used to annotate stub symbols with |
| 529 an EXPORT marking, to control visibility. |
| 525 signatures: The list of signature hashes, as produced by ParseSignatures, | 530 signatures: The list of signature hashes, as produced by ParseSignatures, |
| 526 to create stubs for. | 531 to create stubs for. |
| 527 """ | 532 """ |
| 528 self.signatures = signatures | 533 self.signatures = signatures |
| 529 self.module_name = module_name | 534 self.module_name = module_name |
| 535 self.export_macro = export_macro |
| 530 | 536 |
| 531 @classmethod | 537 @classmethod |
| 532 def CStyleIdentifier(cls, identifier): | 538 def CStyleIdentifier(cls, identifier): |
| 533 """Generates a C style identifier. | 539 """Generates a C style identifier. |
| 534 | 540 |
| 535 The module_name has all invalid identifier characters removed (anything | 541 The module_name has all invalid identifier characters removed (anything |
| 536 that's not [_a-zA-Z0-9]) and is run through string.capwords to try | 542 that's not [_a-zA-Z0-9]) and is run through string.capwords to try |
| 537 and approximate camel case. | 543 and approximate camel case. |
| 538 | 544 |
| 539 Args: | 545 Args: |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 arg_list = '' | 653 arg_list = '' |
| 648 | 654 |
| 649 if arg_list != '' and len(arguments) > 1 and arguments[-1] == '...': | 655 if arg_list != '' and len(arguments) > 1 and arguments[-1] == '...': |
| 650 # If the last argment is ... then this is a variadic function. | 656 # If the last argment is ... then this is a variadic function. |
| 651 if return_prefix != '': | 657 if return_prefix != '': |
| 652 return VARIADIC_STUB_FUNCTION_DEFINITION % { | 658 return VARIADIC_STUB_FUNCTION_DEFINITION % { |
| 653 'return_type': signature['return_type'], | 659 'return_type': signature['return_type'], |
| 654 'name': signature['name'], | 660 'name': signature['name'], |
| 655 'params': ', '.join(signature['params']), | 661 'params': ', '.join(signature['params']), |
| 656 'arg_list': ', '.join(arguments[0:-1]), | 662 'arg_list': ', '.join(arguments[0:-1]), |
| 657 'last_named_arg': arguments[-2]} | 663 'last_named_arg': arguments[-2], |
| 664 'export': signature.get('export', '')} |
| 658 else: | 665 else: |
| 659 return VOID_VARIADIC_STUB_FUNCTION_DEFINITION % { | 666 return VOID_VARIADIC_STUB_FUNCTION_DEFINITION % { |
| 660 'name': signature['name'], | 667 'name': signature['name'], |
| 661 'params': ', '.join(signature['params']), | 668 'params': ', '.join(signature['params']), |
| 662 'arg_list': ', '.join(arguments[0:-1]), | 669 'arg_list': ', '.join(arguments[0:-1]), |
| 663 'last_named_arg': arguments[-2]} | 670 'last_named_arg': arguments[-2], |
| 671 'export': signature.get('export', '')} |
| 664 else: | 672 else: |
| 665 # This is a regular function. | 673 # This is a regular function. |
| 666 return STUB_FUNCTION_DEFINITION % { | 674 return STUB_FUNCTION_DEFINITION % { |
| 667 'return_type': signature['return_type'], | 675 'return_type': signature['return_type'], |
| 668 'name': signature['name'], | 676 'name': signature['name'], |
| 669 'params': ', '.join(signature['params']), | 677 'params': ', '.join(signature['params']), |
| 670 'return_prefix': return_prefix, | 678 'return_prefix': return_prefix, |
| 671 'arg_list': arg_list} | 679 'arg_list': arg_list, |
| 680 'export': signature.get('export', '')} |
| 672 | 681 |
| 673 @classmethod | 682 @classmethod |
| 674 def WriteImplementationPreamble(cls, header_path, outfile): | 683 def WriteImplementationPreamble(cls, header_path, outfile): |
| 675 """Write the necessary includes for the implementation file. | 684 """Write the necessary includes for the implementation file. |
| 676 | 685 |
| 677 Args: | 686 Args: |
| 678 header_path: The path to the header file. | 687 header_path: The path to the header file. |
| 679 outfile: The file handle to populate. | 688 outfile: The file handle to populate. |
| 680 """ | 689 """ |
| 681 outfile.write(IMPLEMENTATION_PREAMBLE % header_path) | 690 outfile.write(IMPLEMENTATION_PREAMBLE % header_path) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 | 818 |
| 810 void FunctionName(A a) { | 819 void FunctionName(A a) { |
| 811 FunctionName_ptr(a); | 820 FunctionName_ptr(a); |
| 812 } | 821 } |
| 813 | 822 |
| 814 Args: | 823 Args: |
| 815 outfile: The file handle to populate. | 824 outfile: The file handle to populate. |
| 816 """ | 825 """ |
| 817 outfile.write('// Stubs that dispatch to the real implementations.\n') | 826 outfile.write('// Stubs that dispatch to the real implementations.\n') |
| 818 for sig in self.signatures: | 827 for sig in self.signatures: |
| 828 sig['export'] = self.export_macro |
| 819 outfile.write('%s\n' % PosixStubWriter.StubFunction(sig)) | 829 outfile.write('%s\n' % PosixStubWriter.StubFunction(sig)) |
| 820 | 830 |
| 821 def WriteModuleInitializeFunctions(self, outfile): | 831 def WriteModuleInitializeFunctions(self, outfile): |
| 822 """Write functions to initialize/query initlialization of the module. | 832 """Write functions to initialize/query initlialization of the module. |
| 823 | 833 |
| 824 This creates 2 functions IsModuleInitialized and InitializeModule where | 834 This creates 2 functions IsModuleInitialized and InitializeModule where |
| 825 "Module" is replaced with the module name, first letter capitalized. | 835 "Module" is replaced with the module name, first letter capitalized. |
| 826 | 836 |
| 827 The InitializeModule function takes a handle that is retrieved from dlopen | 837 The InitializeModule function takes a handle that is retrieved from dlopen |
| 828 and attempts to assign each function pointer above via dlsym. | 838 and attempts to assign each function pointer above via dlsym. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 help=('File to insert after the system includes in the ' | 925 help=('File to insert after the system includes in the ' |
| 916 'generated stub implemenation file. Ignored for ' | 926 'generated stub implemenation file. Ignored for ' |
| 917 '%s and %s types.' % | 927 '%s and %s types.' % |
| 918 (FILE_TYPE_WIN_X86, FILE_TYPE_WIN_X64))) | 928 (FILE_TYPE_WIN_X86, FILE_TYPE_WIN_X64))) |
| 919 parser.add_option('-m', | 929 parser.add_option('-m', |
| 920 '--module_name', | 930 '--module_name', |
| 921 dest='module_name', | 931 dest='module_name', |
| 922 default=None, | 932 default=None, |
| 923 help=('Name of output DLL or LIB for DEF creation using ' | 933 help=('Name of output DLL or LIB for DEF creation using ' |
| 924 '%s type.' % FILE_TYPE_WIN_DEF)) | 934 '%s type.' % FILE_TYPE_WIN_DEF)) |
| 935 parser.add_option('-x', |
| 936 '--export_macro', |
| 937 dest='export_macro', |
| 938 default='', |
| 939 help=('A macro to place between the return type and ' |
| 940 'function name, e.g. MODULE_EXPORT, to control the ' |
| 941 'visbility of the stub functions.')) |
| 925 | 942 |
| 926 return parser | 943 return parser |
| 927 | 944 |
| 928 | 945 |
| 929 def ParseOptions(): | 946 def ParseOptions(): |
| 930 """Parses the options and terminates program if they are not sane. | 947 """Parses the options and terminates program if they are not sane. |
| 931 | 948 |
| 932 Returns: | 949 Returns: |
| 933 The pair (optparse.OptionValues, [string]), that is the output of | 950 The pair (optparse.OptionValues, [string]), that is the output of |
| 934 a successful call to parser.parse_args(). | 951 a successful call to parser.parse_args(). |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 intermediate_dir = os.path.normpath(options.intermediate_dir) | 1006 intermediate_dir = os.path.normpath(options.intermediate_dir) |
| 990 if intermediate_dir is None: | 1007 if intermediate_dir is None: |
| 991 intermediate_dir = out_dir | 1008 intermediate_dir = out_dir |
| 992 | 1009 |
| 993 EnsureDirExists(out_dir) | 1010 EnsureDirExists(out_dir) |
| 994 EnsureDirExists(intermediate_dir) | 1011 EnsureDirExists(intermediate_dir) |
| 995 | 1012 |
| 996 return out_dir, intermediate_dir | 1013 return out_dir, intermediate_dir |
| 997 | 1014 |
| 998 | 1015 |
| 999 def CreateWindowsLibForSigFiles(sig_files, out_dir, intermediate_dir, machine): | 1016 def CreateWindowsLibForSigFiles(sig_files, out_dir, intermediate_dir, machine, |
| 1017 export_macro): |
| 1000 """For each signature file, create a windows lib. | 1018 """For each signature file, create a windows lib. |
| 1001 | 1019 |
| 1002 Args: | 1020 Args: |
| 1003 sig_files: Array of strings with the paths to each signature file. | 1021 sig_files: Array of strings with the paths to each signature file. |
| 1004 out_dir: String holding path to directory where the generated libs go. | 1022 out_dir: String holding path to directory where the generated libs go. |
| 1005 intermediate_dir: String holding path to directory generated intermdiate | 1023 intermediate_dir: String holding path to directory generated intermdiate |
| 1006 artifacts. | 1024 artifacts. |
| 1007 machine: String holding the machine type, 'X86' or 'X64'. | 1025 machine: String holding the machine type, 'X86' or 'X64'. |
| 1026 export_macro: A preprocessor macro used to annotate stub symbols with |
| 1027 an EXPORT marking, to control visibility. |
| 1008 """ | 1028 """ |
| 1009 for input_path in sig_files: | 1029 for input_path in sig_files: |
| 1010 infile = open(input_path, 'r') | 1030 infile = open(input_path, 'r') |
| 1011 try: | 1031 try: |
| 1012 signatures = ParseSignatures(infile) | 1032 signatures = ParseSignatures(infile) |
| 1013 module_name = ExtractModuleName(os.path.basename(input_path)) | 1033 module_name = ExtractModuleName(os.path.basename(input_path)) |
| 1034 for sig in signatures: |
| 1035 sig['export'] = export_macro |
| 1014 CreateWindowsLib(module_name, signatures, intermediate_dir, out_dir, | 1036 CreateWindowsLib(module_name, signatures, intermediate_dir, out_dir, |
| 1015 machine) | 1037 machine) |
| 1016 finally: | 1038 finally: |
| 1017 infile.close() | 1039 infile.close() |
| 1018 | 1040 |
| 1019 | 1041 |
| 1020 def CreateWindowsDefForSigFiles(sig_files, out_dir, module_name): | 1042 def CreateWindowsDefForSigFiles(sig_files, out_dir, module_name): |
| 1021 """For all signature files, create a single windows def file. | 1043 """For all signature files, create a single windows def file. |
| 1022 | 1044 |
| 1023 Args: | 1045 Args: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1038 outfile = open(def_file_path, 'w') | 1060 outfile = open(def_file_path, 'w') |
| 1039 | 1061 |
| 1040 try: | 1062 try: |
| 1041 WriteWindowsDefFile(module_name, signatures, outfile) | 1063 WriteWindowsDefFile(module_name, signatures, outfile) |
| 1042 finally: | 1064 finally: |
| 1043 outfile.close() | 1065 outfile.close() |
| 1044 | 1066 |
| 1045 | 1067 |
| 1046 def CreatePosixStubsForSigFiles(sig_files, stub_name, out_dir, | 1068 def CreatePosixStubsForSigFiles(sig_files, stub_name, out_dir, |
| 1047 intermediate_dir, path_from_source, | 1069 intermediate_dir, path_from_source, |
| 1048 extra_stub_header): | 1070 extra_stub_header, export_macro): |
| 1049 """Create a posix stub library with a module for each signature file. | 1071 """Create a posix stub library with a module for each signature file. |
| 1050 | 1072 |
| 1051 Args: | 1073 Args: |
| 1052 sig_files: Array of strings with the paths to each signature file. | 1074 sig_files: Array of strings with the paths to each signature file. |
| 1053 stub_name: String with the basename of the generated stub file. | 1075 stub_name: String with the basename of the generated stub file. |
| 1054 out_dir: String holding path to directory for the .h files. | 1076 out_dir: String holding path to directory for the .h files. |
| 1055 intermediate_dir: String holding path to directory for the .cc files. | 1077 intermediate_dir: String holding path to directory for the .cc files. |
| 1056 path_from_source: String with relative path of generated files from the | 1078 path_from_source: String with relative path of generated files from the |
| 1057 project root. | 1079 project root. |
| 1058 extra_stub_header: String with path to file of extra lines to insert | 1080 extra_stub_header: String with path to file of extra lines to insert |
| 1059 into the generated header for the stub library. | 1081 into the generated header for the stub library. |
| 1082 export_macro: A preprocessor macro used to annotate stub symbols with |
| 1083 an EXPORT marking, to control visibility. |
| 1060 """ | 1084 """ |
| 1061 header_base_name = stub_name + '.h' | 1085 header_base_name = stub_name + '.h' |
| 1062 header_path = os.path.join(out_dir, header_base_name) | 1086 header_path = os.path.join(out_dir, header_base_name) |
| 1063 impl_path = os.path.join(intermediate_dir, stub_name + '.cc') | 1087 impl_path = os.path.join(intermediate_dir, stub_name + '.cc') |
| 1064 | 1088 |
| 1065 module_names = [ExtractModuleName(path) for path in sig_files] | 1089 module_names = [ExtractModuleName(path) for path in sig_files] |
| 1066 namespace = path_from_source.replace('/', '_').lower() | 1090 namespace = path_from_source.replace('/', '_').lower() |
| 1067 header_guard = '%s_' % namespace.upper() | 1091 header_guard = '%s_' % namespace.upper() |
| 1068 header_include_path = os.path.join(path_from_source, header_base_name) | 1092 header_include_path = os.path.join(path_from_source, header_base_name) |
| 1069 | 1093 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1086 | 1110 |
| 1087 # For each signature file, generate the stub population functions | 1111 # For each signature file, generate the stub population functions |
| 1088 # for that file. Each file represents one module. | 1112 # for that file. Each file represents one module. |
| 1089 for input_path in sig_files: | 1113 for input_path in sig_files: |
| 1090 name = ExtractModuleName(input_path) | 1114 name = ExtractModuleName(input_path) |
| 1091 infile = open(input_path, 'r') | 1115 infile = open(input_path, 'r') |
| 1092 try: | 1116 try: |
| 1093 signatures = ParseSignatures(infile) | 1117 signatures = ParseSignatures(infile) |
| 1094 finally: | 1118 finally: |
| 1095 infile.close() | 1119 infile.close() |
| 1096 writer = PosixStubWriter(name, signatures) | 1120 writer = PosixStubWriter(name, export_macro, signatures) |
| 1097 writer.WriteImplementationContents(namespace, impl_file) | 1121 writer.WriteImplementationContents(namespace, impl_file) |
| 1098 | 1122 |
| 1099 # Lastly, output the umbrella function for the file. | 1123 # Lastly, output the umbrella function for the file. |
| 1100 PosixStubWriter.WriteUmbrellaInitializer(module_names, namespace, | 1124 PosixStubWriter.WriteUmbrellaInitializer(module_names, namespace, |
| 1101 impl_file) | 1125 impl_file) |
| 1102 finally: | 1126 finally: |
| 1103 impl_file.close() | 1127 impl_file.close() |
| 1104 | 1128 |
| 1105 # Then create the associated header file. | 1129 # Then create the associated header file. |
| 1106 header_file = open(header_path, 'w') | 1130 header_file = open(header_path, 'w') |
| 1107 try: | 1131 try: |
| 1108 PosixStubWriter.WriteHeaderContents(module_names, namespace, | 1132 PosixStubWriter.WriteHeaderContents(module_names, namespace, |
| 1109 header_guard, header_file) | 1133 header_guard, header_file) |
| 1110 finally: | 1134 finally: |
| 1111 header_file.close() | 1135 header_file.close() |
| 1112 | 1136 |
| 1113 | 1137 |
| 1114 def main(): | 1138 def main(): |
| 1115 options, args = ParseOptions() | 1139 options, args = ParseOptions() |
| 1116 out_dir, intermediate_dir = CreateOutputDirectories(options) | 1140 out_dir, intermediate_dir = CreateOutputDirectories(options) |
| 1117 | 1141 |
| 1118 if options.type == FILE_TYPE_WIN_X86: | 1142 if options.type == FILE_TYPE_WIN_X86: |
| 1119 CreateWindowsLibForSigFiles(args, out_dir, intermediate_dir, 'X86') | 1143 CreateWindowsLibForSigFiles(args, out_dir, intermediate_dir, 'X86', |
| 1144 options.export_macro) |
| 1120 elif options.type == FILE_TYPE_WIN_X64: | 1145 elif options.type == FILE_TYPE_WIN_X64: |
| 1121 CreateWindowsLibForSigFiles(args, out_dir, intermediate_dir, 'X64') | 1146 CreateWindowsLibForSigFiles(args, out_dir, intermediate_dir, 'X64', |
| 1147 options.export_macro) |
| 1122 elif options.type == FILE_TYPE_POSIX_STUB: | 1148 elif options.type == FILE_TYPE_POSIX_STUB: |
| 1123 CreatePosixStubsForSigFiles(args, options.stubfile_name, out_dir, | 1149 CreatePosixStubsForSigFiles(args, options.stubfile_name, out_dir, |
| 1124 intermediate_dir, options.path_from_source, | 1150 intermediate_dir, options.path_from_source, |
| 1125 options.extra_stub_header) | 1151 options.extra_stub_header, options.export_macro) |
| 1126 elif options.type == FILE_TYPE_WIN_DEF: | 1152 elif options.type == FILE_TYPE_WIN_DEF: |
| 1127 CreateWindowsDefForSigFiles(args, out_dir, options.module_name) | 1153 CreateWindowsDefForSigFiles(args, out_dir, options.module_name) |
| 1128 | 1154 |
| 1129 | 1155 |
| 1130 if __name__ == '__main__': | 1156 if __name__ == '__main__': |
| 1131 main() | 1157 main() |
| OLD | NEW |