• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env ruby
2# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15HEADER = %{
16/**
17* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
18*/
19
20// Autogenerated file -- DO NOT EDIT!
21
22}
23
24def generate(input_file, output_file)
25  data = File.read(input_file)
26  defines = data.scan /"\^\^(\w+) [#\$]?([-+]?\d+)\^\^"/
27  File.open(output_file, "w") do |file|
28    file.puts HEADER
29    defines.sort_by(&:first).each do |define|
30      file.puts "// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)"
31      file.puts "#define #{define[0]} #{define[1]}"
32    end
33  end
34end
35
36abort "Failed: input file required!" if ARGV.size < 2
37
38generate ARGV[0], ARGV[1]
39