15f9996aaSopenharmony_ci#!/usr/bin/env python3 25f9996aaSopenharmony_ci# -*- coding: utf-8 -*- 35f9996aaSopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd. 45f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 55f9996aaSopenharmony_ci# you may not use this file except in compliance with the License. 65f9996aaSopenharmony_ci# You may obtain a copy of the License at 75f9996aaSopenharmony_ci# 85f9996aaSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 95f9996aaSopenharmony_ci# 105f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 115f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 125f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135f9996aaSopenharmony_ci# See the License for the specific language governing permissions and 145f9996aaSopenharmony_ci# limitations under the License. 155f9996aaSopenharmony_ci 165f9996aaSopenharmony_ciimport argparse 175f9996aaSopenharmony_ciimport sys 185f9996aaSopenharmony_ciimport subprocess 195f9996aaSopenharmony_ciimport shutil 205f9996aaSopenharmony_ciimport os 215f9996aaSopenharmony_ci 225f9996aaSopenharmony_ci 235f9996aaSopenharmony_cidef main(): 245f9996aaSopenharmony_ci parser = argparse.ArgumentParser() 255f9996aaSopenharmony_ci parser.add_argument('--kernel-dir', help='kerner dir') 265f9996aaSopenharmony_ci parser.add_argument('--kernel-out-dir', help='header file out dir') 275f9996aaSopenharmony_ci parser.add_argument('--target-cpu', help='target cpu') 285f9996aaSopenharmony_ci parser.add_argument('--kernel-tools-dir', help='kernel tools dir') 295f9996aaSopenharmony_ci options = parser.parse_args() 305f9996aaSopenharmony_ci make_tools_inc_dir = os.path.join(options.kernel_out_dir, 'bpf') 315f9996aaSopenharmony_ci if not os.path.exists(make_tools_inc_dir): 325f9996aaSopenharmony_ci shutil.copytree(options.kernel_tools_dir, make_tools_inc_dir) 335f9996aaSopenharmony_ci make_uapi_cmd = ['make', '-C', options.kernel_dir, '-sj', 'headers', 345f9996aaSopenharmony_ci 'O={}'.format(options.kernel_out_dir), 355f9996aaSopenharmony_ci 'ARCH={}'.format(options.target_cpu)] 365f9996aaSopenharmony_ci make_tools_uapi_cmd = ['make', '-C', options.kernel_tools_dir, 375f9996aaSopenharmony_ci 'O={}'.format(make_tools_inc_dir), 385f9996aaSopenharmony_ci 'ARCH={}'.format(options.target_cpu)] 395f9996aaSopenharmony_ci subprocess.run(make_uapi_cmd) 405f9996aaSopenharmony_ci subprocess.run(make_tools_uapi_cmd) 415f9996aaSopenharmony_ci 425f9996aaSopenharmony_ciif __name__ == '__main__': 435f9996aaSopenharmony_ci sys.exit(main()) 44