Commit 86d349e1 authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

[style_var_gen] Add generation source info and license header to output.

Bug: 1018654
Change-Id: Idec68bbbcf642f7048d06490de765d423218a61c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217511Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772507}
parent 5da23de5
......@@ -54,6 +54,7 @@ class BaseGenerator:
def __init__(self):
self.out_file_path = None
self.in_files = []
self._mode_variables = dict()
# The mode that colors will fallback to when not specified in a
# non-default mode. An error will be raised if a color in any mode is
......@@ -72,6 +73,7 @@ class BaseGenerator:
self._mode_variables[mode].AddColor(name, value_obj[mode])
def AddJSONFileToModel(self, path):
self.in_files.append(path)
with open(path, 'r') as f:
# TODO(calamity): Add allow_duplicate_keys=False once pyjson5 is
# rolled.
......
/* Copyright 2020 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. */
/* This file is generated from:
* colors_test.json5
*/
html:not(body) {
--google-grey-900-rgb: 32, 33, 36;
--google-grey-900: rgb(var(--google-grey-900-rgb));
......
......@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is generated from:
// colors_test.json5
#ifndef TOOLS_STYLE_VARIABLE_GENERATOR_COLORS_TEST_EXPECTED_H_
#define TOOLS_STYLE_VARIABLE_GENERATOR_COLORS_TEST_EXPECTED_H_
......
......@@ -29,6 +29,7 @@ class CSSStyleGenerator(BaseGenerator):
def GetGlobals(self):
return {
'css_color_from_rgb_var': self._CssColorFromRGBVar,
'in_files': self.in_files,
}
def _ToVarName(self, var_name):
......
/* Copyright 2020 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. */
/* This file is generated from:
{%- for path in in_files %}
* {{path}}
{%- endfor %}
*/
{#
The :not(body) adds extra selector specificity so that these colors 'win'
against paper-styles/color.html.
......
......@@ -60,7 +60,6 @@ template("style_variable_generator") {
]
out_file = "$target_gen_dir/${original_target_name}.h"
outputs = [ out_file ]
args = [
"--generator=Views",
"--out-file",
......
......@@ -30,6 +30,7 @@ class ViewsStyleGenerator(BaseGenerator):
'Modes': Modes,
'out_file_path': None,
'namespace_name': None,
'in_files': self.in_files,
}
if self.out_file_path:
globals['out_file_path'] = self.out_file_path
......
......@@ -6,6 +6,11 @@
out_file_path|upper|replace("/","_")|replace(".","_")|
replace("-", "_")) %}
// This file is generated from:
{%- for path in in_files %}
// {{path}}
{%- endfor %}
#ifndef {{header_guard}}
#define {{header_guard}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment