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.
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.
14 // NOTE: this file is generated from "%(source)s". Do not modify directly.
16 #ifndef %(include_guard)s
17 #define %(include_guard)s
19 #if defined(COMPONENT_BUILD)
23 #if defined(%(impl_macro)s)
24 #define %(export_macro)s __declspec(dllexport)
26 #define %(export_macro)s __declspec(dllimport)
27 #endif // defined(%(impl_macro)s)
29 #else // defined(WIN32)
31 #if defined(%(impl_macro)s)
32 #define %(export_macro)s __attribute__((visibility("default")))
34 #define %(export_macro)s
35 #endif // defined(%(impl_macro)s)
37 #endif // defined(WIN32)
39 #else // defined(COMPONENT_BUILD)
41 #define %(export_macro)s
45 #endif // %(include_guard)s
48 def GenHFile(declaration
):
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
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
)
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
))