| OLD | NEW |
| (Empty) |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import datetime | |
| 6 import util | |
| 7 import os | |
| 8 | |
| 9 H_FILE_TEMPLATE = \ | |
| 10 """// Copyright %(year)d The Chromium Authors. All rights reserved. | |
| 11 // Use of this source code is governed by a BSD-style license that can be | |
| 12 // found in the LICENSE file. | |
| 13 | |
| 14 // NOTE: this file is generated from "%(source)s". Do not modify directly. | |
| 15 | |
| 16 #ifndef %(include_guard)s | |
| 17 #define %(include_guard)s | |
| 18 | |
| 19 #if defined(COMPONENT_BUILD) | |
| 20 | |
| 21 #if defined(WIN32) | |
| 22 | |
| 23 #if defined(%(impl_macro)s) | |
| 24 #define %(export_macro)s __declspec(dllexport) | |
| 25 #else | |
| 26 #define %(export_macro)s __declspec(dllimport) | |
| 27 #endif // defined(%(impl_macro)s) | |
| 28 | |
| 29 #else // defined(WIN32) | |
| 30 | |
| 31 #if defined(%(impl_macro)s) | |
| 32 #define %(export_macro)s __attribute__((visibility("default"))) | |
| 33 #else | |
| 34 #define %(export_macro)s | |
| 35 #endif // defined(%(impl_macro)s) | |
| 36 | |
| 37 #endif // defined(WIN32) | |
| 38 | |
| 39 #else // defined(COMPONENT_BUILD) | |
| 40 | |
| 41 #define %(export_macro)s | |
| 42 | |
| 43 #endif | |
| 44 | |
| 45 #endif // %(include_guard)s | |
| 46 """ | |
| 47 | |
| 48 def GenHFile(declaration): | |
| 49 subs = {} | |
| 50 subs['year'] = datetime.date.today().year | |
| 51 subs['source'] = declaration.path | |
| 52 subs['include_guard'] = util.PathToIncludeGuard( | |
| 53 declaration.export_h_include_path) | |
| 54 subs['export_macro'] = declaration.component_export_macro | |
| 55 subs['impl_macro'] = declaration.component_impl_macro | |
| 56 return H_FILE_TEMPLATE % subs | |
| 57 | |
| 58 def ListOutputs(declaration, destination): | |
| 59 dirname = os.path.join(destination, os.path.dirname(declaration.path)) | |
| 60 h_file_path = os.path.join(dirname, declaration.export_h_name) | |
| 61 return [h_file_path] | |
| 62 | |
| 63 def Gen(declaration, destination): | |
| 64 h_file_path = ListOutputs(declaration, destination)[0] | |
| 65 util.CreateDirIfNotExists(os.path.dirname(h_file_path)) | |
| 66 open(h_file_path, 'w').write(GenHFile(declaration)) | |
| OLD | NEW |