diff options
Diffstat (limited to 'third_party/ffmpeg/generate_stubs.py')
-rwxr-xr-x | third_party/ffmpeg/generate_stubs.py | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/third_party/ffmpeg/generate_stubs.py b/third_party/ffmpeg/generate_stubs.py index 1288697..b1a6385 100755 --- a/third_party/ffmpeg/generate_stubs.py +++ b/third_party/ffmpeg/generate_stubs.py @@ -144,16 +144,18 @@ class WindowsLibCreator(object): logic. """ - def __init__(self, module_name, signatures, outdir_path): + def __init__(self, module_name, signatures, intermediate_dir, outdir_path): """Initializes the WindowsLibCreator for creating a library stub. Args: module_name: The name of the module we are writing a stub for. signatures: The list of signatures to create stubs for. - outdir_path: The directory that generated files should go into. + intermediate_dir: The directory where the generated .def files should go. + outdir_path: The directory where generated .lib files should go. """ self.module_name = module_name self.signatures = signatures + self.intermediate_dir = intermediate_dir self.outdir_path = outdir_path def DefFilePath(self): @@ -163,7 +165,7 @@ class WindowsLibCreator(object): A string with the path to the def file. """ # Output file name is in the form "module_name.def". - return '%s/%s.def' % (self.outdir_path, self.module_name) + return '%s/%s.def' % (self.intermediate_dir, self.module_name) def LibFilePath(self): """Generates the path of the lib file for the given module_name. @@ -575,6 +577,7 @@ void %s(); // Umbrella initializer for all the modules in this stub file. bool InitializeStubs(const StubPathMap& path_map); + } // namespace %s #endif // %s @@ -588,15 +591,17 @@ bool InitializeStubs(const StubPathMap& path_map); outfile: The file handle to populate. """ outfile.write('extern "C" {\n') + outfile.write('\n') self.WriteFunctionPointers(outfile) self.WriteStubFunctions(outfile) + outfile.write('\n') outfile.write('} // extern "C"\n') outfile.write('\n') outfile.write('namespace %s {\n' % namespace) outfile.write('\n') self.WriteModuleInitializeFunctions(outfile) - outfile.write('} // namespace %s\n' % namespace) + outfile.write('} // namespace %s\n\n' % namespace) def WriteFunctionPointers(self, outfile): """Write the function pointer declarations needed by the stubs. @@ -704,6 +709,11 @@ def main(): dest='out_dir', default=None, help='Output location.') + parser.add_option('-i', + '--intermediate_dir', + dest='intermediate_dir', + default=None, + help='Locaiton of intermediate files.') parser.add_option('-t', '--type', dest='type', @@ -738,7 +748,7 @@ def main(): if options.out_dir is None: parser.error('Output location not specified') - if args: + if len(args) == 0: parser.error('No inputs specified') if options.type not in [FILE_TYPE_WIN, FILE_TYPE_POSIX_STUB]: @@ -750,10 +760,17 @@ def main(): if options.path_from_source is None: parser.error('Path from source needed for %s' % FILE_TYPE_POSIX_STUB) - # Make sure output directory exists. + # Get the names for the output directory and intermdiate directory. out_dir = RemoveTrailingSlashes(options.out_dir) + intermediate_dir = RemoveTrailingSlashes(options.intermediate_dir) + if intermediate_dir is None: + intermediate_dir = out_dir + + # Make sure the directories exists. if not os.path.exists(out_dir): os.makedirs(out_dir) + if not os.path.exists(intermediate_dir): + os.makedirs(intermediate_dir) if options.type == FILE_TYPE_WIN: for input_path in args: @@ -761,7 +778,7 @@ def main(): infile = open(input_path, 'r') signatures = ParseSignatures(infile) module_name = ExtractModuleName(os.path.basename(input_path)) - WindowsLibCreator(module_name, signatures, out_dir).CreateLib() + WindowsLibCreator(module_name, signatures, intermediate_dir, out_dir).CreateLib() finally: if infile is not None: infile.close() @@ -770,7 +787,7 @@ def main(): header_path = PosixStubWriter.HeaderFilePath(options.stubfile_name, out_dir) impl_path = PosixStubWriter.ImplementationFilePath(options.stubfile_name, - out_dir) + intermediate_dir) # Generate some convenience variables for bits of data needed below. module_names = [ExtractModuleName(path) for path in args] @@ -788,6 +805,7 @@ def main(): impl_file) if options.extra_stub_header is not None: try: + impl_file.write('\n') extra_header_file = open(options.extra_stub_header, 'r') for line in extra_header_file: impl_file.write(line) |