xref: /build/templates/bpf/BUILD.gn (revision 5f9996aa)
15f9996aaSopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
25f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
35f9996aaSopenharmony_ci# you may not use this file except in compliance with the License.
45f9996aaSopenharmony_ci# You may obtain a copy of the License at
55f9996aaSopenharmony_ci#
65f9996aaSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
75f9996aaSopenharmony_ci#
85f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
95f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
105f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115f9996aaSopenharmony_ci# See the License for the specific language governing permissions and
125f9996aaSopenharmony_ci# limitations under the License.
135f9996aaSopenharmony_ci
145f9996aaSopenharmony_ciimport("//build/templates/bpf/ohos_bpf_config.gni")
155f9996aaSopenharmony_ci
165f9996aaSopenharmony_ci_script = "//build/ohos/file_exists.py"
175f9996aaSopenharmony_ci_args = [
185f9996aaSopenharmony_ci  "--filename",
195f9996aaSopenharmony_ci  rebase_path(bpf_linux_kernel_dir, root_build_dir),
205f9996aaSopenharmony_ci  "--type",
215f9996aaSopenharmony_ci  "dir",
225f9996aaSopenharmony_ci]
235f9996aaSopenharmony_ci_result = exec_script(_script, _args, "string")
245f9996aaSopenharmony_ciif (_result == "False") {
255f9996aaSopenharmony_ci  bpf_linux_kernel_dir = "//kernel/linux-5.10-lts"
265f9996aaSopenharmony_ci  kernel_tools_dir = "${bpf_linux_kernel_dir}/tools/lib/bpf"
275f9996aaSopenharmony_ci}
285f9996aaSopenharmony_ci
295f9996aaSopenharmony_ciaction("gen_bpf_uapi") {
305f9996aaSopenharmony_ci  kernel_dir = rebase_path(bpf_linux_kernel_dir, root_build_dir)
315f9996aaSopenharmony_ci  kernel_out_dir = rebase_path("${target_out_dir}/${bpf_inc_out_dir}")
325f9996aaSopenharmony_ci  kernel_tools_dir = rebase_path(kernel_tools_dir, root_build_dir)
335f9996aaSopenharmony_ci
345f9996aaSopenharmony_ci  script = "//build/templates/bpf/gen_bpf_uapi.py"
355f9996aaSopenharmony_ci  outputs = [ "${target_out_dir}/${target_name}.stamp" ]
365f9996aaSopenharmony_ci  args = [
375f9996aaSopenharmony_ci    "--kernel-dir",
385f9996aaSopenharmony_ci    kernel_dir,
395f9996aaSopenharmony_ci    "--kernel-out-dir",
405f9996aaSopenharmony_ci    kernel_out_dir,
415f9996aaSopenharmony_ci    "--target-cpu",
425f9996aaSopenharmony_ci    target_cpu,
435f9996aaSopenharmony_ci    "--kernel-tools-dir",
445f9996aaSopenharmony_ci    kernel_tools_dir,
455f9996aaSopenharmony_ci  ]
465f9996aaSopenharmony_ci}
47