Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / components / webui_generator / generator / export_h.py
blob3c4eceb90e70cfe3ac6fcfef023327bfb2df3839
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.
5 import datetime
6 import util
7 import os
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.
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)
21 #if defined(WIN32)
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)
29 #else // defined(WIN32)
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)
37 #endif // defined(WIN32)
39 #else // defined(COMPONENT_BUILD)
41 #define %(export_macro)s
43 #endif
45 #endif // %(include_guard)s
46 """
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
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]
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))