blob: c091fd13b2349055e065f4be56b97a633ec3e2f6 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001# Copyright (c) 2021 Arm Limited. All rights reserved.
2# SPDX-License-Identifier: Apache-2.0
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""
17Utility script to generate the minimum InputFiles.hpp and cpp files required by an application.
18"""
19import datetime
20import os
21
22from argparse import ArgumentParser
23from jinja2 import Environment, FileSystemLoader
24
25parser = ArgumentParser()
26parser.add_argument("--header_folder_path", type=str, help="path to header folder to be generated.")
27parser.add_argument("--license_template", type=str, help="Header template file",
28 default="header_template.txt")
29args = parser.parse_args()
30
31env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')),
32 trim_blocks=True,
33 lstrip_blocks=True)
34
35
36def write_hpp_file(header_file_path, header_template_file):
37 print(f"++ Generating {header_file_path}")
38 header_template = env.get_template(header_template_file)
39 hdr = header_template.render(script_name=os.path.basename(__file__),
40 gen_time=datetime.datetime.now(),
41 year=datetime.datetime.now().year)
42 env.get_template('default.hpp.template').stream(common_template_header=hdr) \
43 .dump(str(header_file_path))
44
45
46def main(args):
47 header_filename = "InputFiles.hpp"
48 header_filepath = os.path.join(args.header_folder_path, header_filename)
49 write_hpp_file(header_filepath, args.license_template)
50
51
52if __name__ == '__main__':
53 main(args)