Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: components/wug/generator/export_h.py

Issue 928163002: Initial implementation of WebUI generator (WUG) toolkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed problems with component build. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/wug/generator/export_h.py
diff --git a/components/wug/generator/export_h.py b/components/wug/generator/export_h.py
new file mode 100644
index 0000000000000000000000000000000000000000..3c4eceb90e70cfe3ac6fcfef023327bfb2df3839
--- /dev/null
+++ b/components/wug/generator/export_h.py
@@ -0,0 +1,66 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import datetime
+import util
+import os
+
+H_FILE_TEMPLATE = \
+"""// Copyright %(year)d The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// NOTE: this file is generated from "%(source)s". Do not modify directly.
+
+#ifndef %(include_guard)s
+#define %(include_guard)s
+
+#if defined(COMPONENT_BUILD)
+
+#if defined(WIN32)
+
+#if defined(%(impl_macro)s)
+#define %(export_macro)s __declspec(dllexport)
+#else
+#define %(export_macro)s __declspec(dllimport)
+#endif // defined(%(impl_macro)s)
+
+#else // defined(WIN32)
+
+#if defined(%(impl_macro)s)
+#define %(export_macro)s __attribute__((visibility("default")))
+#else
+#define %(export_macro)s
+#endif // defined(%(impl_macro)s)
+
+#endif // defined(WIN32)
+
+#else // defined(COMPONENT_BUILD)
+
+#define %(export_macro)s
+
+#endif
+
+#endif // %(include_guard)s
+"""
+
+def GenHFile(declaration):
+ subs = {}
+ subs['year'] = datetime.date.today().year
+ subs['source'] = declaration.path
+ subs['include_guard'] = util.PathToIncludeGuard(
+ declaration.export_h_include_path)
+ subs['export_macro'] = declaration.component_export_macro
+ subs['impl_macro'] = declaration.component_impl_macro
+ return H_FILE_TEMPLATE % subs
+
+def ListOutputs(declaration, destination):
+ dirname = os.path.join(destination, os.path.dirname(declaration.path))
+ h_file_path = os.path.join(dirname, declaration.export_h_name)
+ return [h_file_path]
+
+def Gen(declaration, destination):
+ h_file_path = ListOutputs(declaration, destination)[0]
+ util.CreateDirIfNotExists(os.path.dirname(h_file_path))
+ open(h_file_path, 'w').write(GenHFile(declaration))

Powered by Google App Engine
This is Rietveld 408576698