1# Copyright (C) 2020 The Android Open Source Project 2# 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 15# This action generates a perfetto_version.gen.h which exposes some 16# PERFETTO_VERSION_xxx() macros that contains the git revision and release 17# number from the CHANGELOG. 18# This template is used only in two places: in //base (for C++ code) and in 19# //ui. This teamplate exists only to keep the logic consistent and avoid that 20# base's and ui's logic diverge. 21 22import("perfetto.gni") 23 24template("gen_perfetto_version_header") { 25 action(target_name) { 26 script = "${perfetto_root_path}tools/write_version_header.py" 27 changelog = "${perfetto_root_path}CHANGELOG" 28 inputs = [ changelog ] 29 outputs = [] 30 args = [] 31 if (perfetto_build_standalone && !is_perfetto_build_generator && 32 perfetto_enable_git_rev_version_header) { 33 inputs += [ "${perfetto_root_path}.git/HEAD" ] 34 } 35 36 if (defined(invoker.cpp_out)) { 37 args += [ 38 "--changelog", 39 rebase_path(changelog, root_build_dir), 40 "--cpp_out", 41 rebase_path(invoker.cpp_out, root_build_dir), 42 ] 43 outputs += [ invoker.cpp_out ] 44 } 45 if (defined(invoker.ts_out)) { 46 args += [ 47 "--ts_out", 48 rebase_path(invoker.ts_out, root_build_dir), 49 ] 50 outputs += [ invoker.ts_out ] 51 } 52 if (!perfetto_enable_git_rev_version_header) { 53 args += [ "--no_git" ] 54 } 55 } 56} 57