# Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. # Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as published by # the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program. If not, see . import argparse import filecmp import os import re import subprocess import sys def run_headers_install(verbose, gen_dir, headers_install, unifdef, prefix, h): if not h.startswith(prefix): print('error: expected prefix [%s] on header [%s]' % (prefix, h)) return False # out_h is combining the relative path to the header file (made in gen_smcinvoke_headers()) to the gen_dir out/soong/.temp/sbox//out/ # ex. out/soong/.temp/sbox//out/linux/smcinvoke.h # After the build is complete, you can find the headers that you exposed located in the following gen path: # out/soong/.intermediates/.../qti_generate_smcinvoke_kernel_headers/gen/ if 'include/uapi' in h: out_h = os.path.join(gen_dir,'include', h[len(prefix):]) else: out_h = os.path.join(gen_dir, h[len(prefix):]) (out_h_dirname, out_h_basename) = os.path.split(out_h) env = os.environ.copy() env["LOC_UNIFDEF"] = unifdef cmd = ["sh", headers_install, h, out_h] if verbose: print('run_headers_install: cmd is %s' % cmd) result = subprocess.call(cmd, env=env) if result != 0: print('error: run_headers_install: cmd %s failed %d' % (cmd, result)) return False return True def gen_smcinvoke_headers(verbose, gen_dir, headers_install, unifdef, smcinvoke_headers_to_expose): error_count = 0 # smcinvoke_headers_to_expose is a string list of individual paths to headers to expose # They are passed using Android.bp variable substition: $(locations