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 24_ver_script = "${perfetto_root_path}tools/write_version_header.py" 25_has_git = false 26if (perfetto_enable_git_rev_version_header) { 27 _has_git = "1" == exec_script(_ver_script, [ "--check_git" ], "trim string") 28} 29 30template("gen_perfetto_version_header") { 31 action(target_name) { 32 script = _ver_script 33 changelog = "${perfetto_root_path}CHANGELOG" 34 inputs = [ changelog ] 35 outputs = [] 36 args = [] 37 if (_has_git) { 38 inputs += [ "${perfetto_root_path}.git/HEAD" ] 39 } 40 41 if (defined(invoker.cpp_out)) { 42 args += [ 43 "--changelog", 44 rebase_path(changelog, root_build_dir), 45 "--cpp_out", 46 rebase_path(invoker.cpp_out, root_build_dir), 47 ] 48 outputs += [ invoker.cpp_out ] 49 } 50 if (defined(invoker.ts_out)) { 51 args += [ 52 "--ts_out", 53 rebase_path(invoker.ts_out, root_build_dir), 54 ] 55 outputs += [ invoker.ts_out ] 56 } 57 if (!_has_git) { 58 args += [ "--no_git" ] 59 } 60 } 61} 62