16cd6a6acSopenharmony_ci# Copyright (c) 2021 北京万里红科技有限公司
26cd6a6acSopenharmony_ci# Copyright(c) Huawei Technologies Co.,Ltd.
36cd6a6acSopenharmony_ci# 2020-2021.All rights reserved.
46cd6a6acSopenharmony_ci# Copyright(c)2016,Google inc.
56cd6a6acSopenharmony_ci#
66cd6a6acSopenharmony_ci# Permission to use,copy,modify,and/or distribute this software for any
76cd6a6acSopenharmony_ci# purpose with or without fee is hereby granted,provided that the above
86cd6a6acSopenharmony_ci# copyright notice and this permission notice appear in all copies.
96cd6a6acSopenharmony_ci#
106cd6a6acSopenharmony_ci
116cd6a6acSopenharmony_ciimport("//build/ohos.gni")
126cd6a6acSopenharmony_ci
136cd6a6acSopenharmony_ciLIBSEPOL_ROOT_DIR = "//third_party/selinux/libsepol"
146cd6a6acSopenharmony_ciLIBSELINUX_ROOT_DIR = "//third_party/selinux/libselinux"
156cd6a6acSopenharmony_ciCHECKPOLICY_ROOT_DIR = "//third_party/selinux/checkpolicy"
166cd6a6acSopenharmony_ciSECILC_ROOT_DIR = "//third_party/selinux/secilc"
176cd6a6acSopenharmony_ci
186cd6a6acSopenharmony_ciconfig("third_party_selinux_config") {
196cd6a6acSopenharmony_ci  include_dirs = [
206cd6a6acSopenharmony_ci    "$LIBSELINUX_ROOT_DIR/include",
216cd6a6acSopenharmony_ci    "$LIBSELINUX_ROOT_DIR",
226cd6a6acSopenharmony_ci  ]
236cd6a6acSopenharmony_ci}
246cd6a6acSopenharmony_ci
256cd6a6acSopenharmony_ciconfig("third_party_selinux_nolto_config") {
266cd6a6acSopenharmony_ci  if (use_libfuzzer && !is_mac) {
276cd6a6acSopenharmony_ci    cflags = []
286cd6a6acSopenharmony_ci  } else {
296cd6a6acSopenharmony_ci    cflags = [
306cd6a6acSopenharmony_ci      "-fno-emulated-tls",
316cd6a6acSopenharmony_ci      "-fno-lto",
326cd6a6acSopenharmony_ci      "-fno-whole-program-vtables",
336cd6a6acSopenharmony_ci    ]
346cd6a6acSopenharmony_ci  }
356cd6a6acSopenharmony_ci}
366cd6a6acSopenharmony_ci
376cd6a6acSopenharmony_ciohos_shared_library("libsepol") {
386cd6a6acSopenharmony_ci  md5_check_script = rebase_path("//third_party/selinux/check_md5.sh")
396cd6a6acSopenharmony_ci  _arguments = [
406cd6a6acSopenharmony_ci    rebase_path("libsepol/cil/src/cil_lexer.c"),
416cd6a6acSopenharmony_ci    rebase_path("libsepol/cil/src/cil_lexer.l"),
426cd6a6acSopenharmony_ci    rebase_path("libsepol/cil/src/cil_lexer.md5"),
436cd6a6acSopenharmony_ci  ]
446cd6a6acSopenharmony_ci  result = exec_script(md5_check_script, _arguments, "string")
456cd6a6acSopenharmony_ci  if (result != "") {
466cd6a6acSopenharmony_ci    exec_script("/usr/bin/flex",
476cd6a6acSopenharmony_ci                [
486cd6a6acSopenharmony_ci                  "-o",
496cd6a6acSopenharmony_ci                  rebase_path("libsepol/cil/src/cil_lexer.c"),
506cd6a6acSopenharmony_ci                  rebase_path("libsepol/cil/src/cil_lexer.l"),
516cd6a6acSopenharmony_ci                ],
526cd6a6acSopenharmony_ci                "")
536cd6a6acSopenharmony_ci  }
546cd6a6acSopenharmony_ci
556cd6a6acSopenharmony_ci  output_name = "libsepol"
566cd6a6acSopenharmony_ci  version_script = "libsepol.map"
576cd6a6acSopenharmony_ci  sources = [
586cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil.c",
596cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_binary.c",
606cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_build_ast.c",
616cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_copy_ast.c",
626cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_find.c",
636cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_fqn.c",
646cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_lexer.c",
656cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_list.c",
666cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_log.c",
676cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_mem.c",
686cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_parser.c",
696cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_policy.c",
706cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_post.c",
716cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_reset_ast.c",
726cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_resolve_ast.c",
736cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_stack.c",
746cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_strpool.c",
756cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_symtab.c",
766cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_tree.c",
776cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_verify.c",
786cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/src/cil_write_ast.c",
796cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/assertion.c",
806cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/avrule_block.c",
816cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/avtab.c",
826cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/boolean_record.c",
836cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/booleans.c",
846cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/conditional.c",
856cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/constraint.c",
866cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/context.c",
876cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/context_record.c",
886cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/debug.c",
896cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ebitmap.c",
906cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/expand.c",
916cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/handle.c",
926cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/hashtab.c",
936cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/hierarchy.c",
946cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ibendport_record.c",
956cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ibendports.c",
966cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ibpkey_record.c",
976cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ibpkeys.c",
986cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/iface_record.c",
996cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/interfaces.c",
1006cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/kernel_to_cil.c",
1016cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/kernel_to_common.c",
1026cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/kernel_to_conf.c",
1036cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/link.c",
1046cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/mls.c",
1056cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/module.c",
1066cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/module_to_cil.c",
1076cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/node_record.c",
1086cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/nodes.c",
1096cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/optimize.c",
1106cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/polcaps.c",
1116cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/policydb.c",
1126cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/policydb_convert.c",
1136cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/policydb_public.c",
1146cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/policydb_validate.c",
1156cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/port_record.c",
1166cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/ports.c",
1176cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/services.c",
1186cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/sidtab.c",
1196cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/symtab.c",
1206cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/user_record.c",
1216cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/users.c",
1226cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/util.c",
1236cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/src/write.c",
1246cd6a6acSopenharmony_ci  ]
1256cd6a6acSopenharmony_ci  include_dirs = [
1266cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/include",
1276cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
1286cd6a6acSopenharmony_ci  ]
1296cd6a6acSopenharmony_ci  cflags = [
1306cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
1316cd6a6acSopenharmony_ci    "-DHAVE_REALLOCARRAY",
1326cd6a6acSopenharmony_ci    "-w",
1336cd6a6acSopenharmony_ci  ]
1346cd6a6acSopenharmony_ci  install_enable = true
1356cd6a6acSopenharmony_ci  install_images = [
1366cd6a6acSopenharmony_ci    "system",
1376cd6a6acSopenharmony_ci    "ramdisk",
1386cd6a6acSopenharmony_ci    "updater",
1396cd6a6acSopenharmony_ci  ]
1406cd6a6acSopenharmony_ci  license_file = "$LIBSEPOL_ROOT_DIR/LICENSE"
1416cd6a6acSopenharmony_ci  part_name = "selinux"
1426cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
1436cd6a6acSopenharmony_ci}
1446cd6a6acSopenharmony_ci
1456cd6a6acSopenharmony_ciohos_executable("chkcon") {
1466cd6a6acSopenharmony_ci  install_enable = true
1476cd6a6acSopenharmony_ci  sources = [ "$LIBSEPOL_ROOT_DIR/utils/chkcon.c" ]
1486cd6a6acSopenharmony_ci  deps = [ ":libsepol" ]
1496cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSEPOL_ROOT_DIR/include" ]
1506cd6a6acSopenharmony_ci  cflags = [
1516cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
1526cd6a6acSopenharmony_ci    "-w",
1536cd6a6acSopenharmony_ci  ]
1546cd6a6acSopenharmony_ci  license_file = "$LIBSEPOL_ROOT_DIR/LICENSE"
1556cd6a6acSopenharmony_ci  part_name = "selinux"
1566cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
1576cd6a6acSopenharmony_ci}
1586cd6a6acSopenharmony_ci
1596cd6a6acSopenharmony_ciselinux_sources = [
1606cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/avc.c",
1616cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/avc_internal.c",
1626cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/avc_sidtab.c",
1636cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/booleans.c",
1646cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/callbacks.c",
1656cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/canonicalize_context.c",
1666cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/checkAccess.c",
1676cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/check_context.c",
1686cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/compute_av.c",
1696cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/compute_create.c",
1706cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/compute_member.c",
1716cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/context.c",
1726cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/deny_unknown.c",
1736cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/disable.c",
1746cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/enabled.c",
1756cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/fgetfilecon.c",
1766cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/freecon.c",
1776cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/fsetfilecon.c",
1786cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/get_initial_context.c",
1796cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/getenforce.c",
1806cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/getfilecon.c",
1816cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/getpeercon.c",
1826cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/ignore_path.c",
1836cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/init.c",
1846cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/is_customizable_type.c",
1856cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label.c",
1866cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_backends_android.c",
1876cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_db.c",
1886cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_file.c",
1896cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_media.c",
1906cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_support.c",
1916cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/label_x.c",
1926cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/lgetfilecon.c",
1936cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/load_policy.c",
1946cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/lsetfilecon.c",
1956cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/mapping.c",
1966cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/matchpathcon.c",
1976cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/policyvers.c",
1986cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/procattr.c",
1996cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/regex.c",
2006cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/reject_unknown.c",
2016cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/selinux_config.c",
2026cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/selinux_restorecon.c",
2036cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/sestatus.c",
2046cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/setenforce.c",
2056cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/setfilecon.c",
2066cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/setrans_client.c",
2076cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/seusers.c",
2086cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/sha1.c",
2096cd6a6acSopenharmony_ci  "$LIBSELINUX_ROOT_DIR/src/stringrep.c",
2106cd6a6acSopenharmony_ci]
2116cd6a6acSopenharmony_ci
2126cd6a6acSopenharmony_ciohos_shared_library("libselinux") {
2136cd6a6acSopenharmony_ci  branch_protector_ret = "pac_ret"
2146cd6a6acSopenharmony_ci
2156cd6a6acSopenharmony_ci  output_name = "libselinux"
2166cd6a6acSopenharmony_ci
2176cd6a6acSopenharmony_ci  sources = selinux_sources
2186cd6a6acSopenharmony_ci
2196cd6a6acSopenharmony_ci  if (current_toolchain == host_toolchain) {
2206cd6a6acSopenharmony_ci    # host build
2216cd6a6acSopenharmony_ci    sources += [ "$LIBSELINUX_ROOT_DIR/src/selinux_internal.c" ]
2226cd6a6acSopenharmony_ci  }
2236cd6a6acSopenharmony_ci
2246cd6a6acSopenharmony_ci  include_dirs = [
2256cd6a6acSopenharmony_ci    "$LIBSELINUX_ROOT_DIR/include",
2266cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
2276cd6a6acSopenharmony_ci  ]
2286cd6a6acSopenharmony_ci
2296cd6a6acSopenharmony_ci  configs = [ ":third_party_selinux_nolto_config" ]
2306cd6a6acSopenharmony_ci
2316cd6a6acSopenharmony_ci  public_configs = [ ":third_party_selinux_config" ]
2326cd6a6acSopenharmony_ci
2336cd6a6acSopenharmony_ci  cflags = [
2346cd6a6acSopenharmony_ci    "-DOHOS_FC_INIT",
2356cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
2366cd6a6acSopenharmony_ci    "-w",
2376cd6a6acSopenharmony_ci    "-DSHARED",
2386cd6a6acSopenharmony_ci    "-DUSE_PCRE2",
2396cd6a6acSopenharmony_ci    "-U__BIONIC__",
2406cd6a6acSopenharmony_ci    "-DAUDITD_LOG_TAG=1003",
2416cd6a6acSopenharmony_ci    "-DPCRE2_CODE_UNIT_WIDTH=8",
2426cd6a6acSopenharmony_ci  ]
2436cd6a6acSopenharmony_ci  if (host_cpu == "arm64" && host_os == "linux") {
2446cd6a6acSopenharmony_ci    cflags += [ "-DWITH_FREEBSD" ]
2456cd6a6acSopenharmony_ci  }
2466cd6a6acSopenharmony_ci  external_deps = [ "pcre2:libpcre2" ]
2476cd6a6acSopenharmony_ci  public_external_deps = [ "FreeBSD:libfreebsd_static" ]
2486cd6a6acSopenharmony_ci  install_enable = true
2496cd6a6acSopenharmony_ci  install_images = [
2506cd6a6acSopenharmony_ci    "system",
2516cd6a6acSopenharmony_ci    "ramdisk",
2526cd6a6acSopenharmony_ci    "updater",
2536cd6a6acSopenharmony_ci  ]
2546cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
2556cd6a6acSopenharmony_ci  innerapi_tags = [
2566cd6a6acSopenharmony_ci    "platformsdk_indirect",
2576cd6a6acSopenharmony_ci    "chipsetsdk_indirect",
2586cd6a6acSopenharmony_ci  ]
2596cd6a6acSopenharmony_ci  part_name = "selinux"
2606cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
2616cd6a6acSopenharmony_ci}
2626cd6a6acSopenharmony_ci
2636cd6a6acSopenharmony_ciohos_static_library("libselinux_static") {
2646cd6a6acSopenharmony_ci  output_name = "libselinux_static"
2656cd6a6acSopenharmony_ci
2666cd6a6acSopenharmony_ci  sources = selinux_sources
2676cd6a6acSopenharmony_ci
2686cd6a6acSopenharmony_ci  if (current_toolchain == host_toolchain) {
2696cd6a6acSopenharmony_ci    # host build
2706cd6a6acSopenharmony_ci    sources += [ "$LIBSELINUX_ROOT_DIR/src/selinux_internal.c" ]
2716cd6a6acSopenharmony_ci  }
2726cd6a6acSopenharmony_ci
2736cd6a6acSopenharmony_ci  include_dirs = [
2746cd6a6acSopenharmony_ci    "$LIBSELINUX_ROOT_DIR/include",
2756cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
2766cd6a6acSopenharmony_ci  ]
2776cd6a6acSopenharmony_ci
2786cd6a6acSopenharmony_ci  configs = [ ":third_party_selinux_nolto_config" ]
2796cd6a6acSopenharmony_ci
2806cd6a6acSopenharmony_ci  public_configs = [ ":third_party_selinux_config" ]
2816cd6a6acSopenharmony_ci
2826cd6a6acSopenharmony_ci  cflags = [
2836cd6a6acSopenharmony_ci    "-DOHOS_FC_INIT",
2846cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
2856cd6a6acSopenharmony_ci    "-w",
2866cd6a6acSopenharmony_ci    "-DSHARED",
2876cd6a6acSopenharmony_ci    "-DUSE_PCRE2",
2886cd6a6acSopenharmony_ci    "-U__BIONIC__",
2896cd6a6acSopenharmony_ci    "-DAUDITD_LOG_TAG=1003",
2906cd6a6acSopenharmony_ci    "-DPCRE2_CODE_UNIT_WIDTH=8",
2916cd6a6acSopenharmony_ci  ]
2926cd6a6acSopenharmony_ci  external_deps = [ "pcre2:libpcre2_static" ]
2936cd6a6acSopenharmony_ci  public_external_deps = [ "FreeBSD:libfreebsd_static" ]
2946cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
2956cd6a6acSopenharmony_ci  part_name = "selinux"
2966cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
2976cd6a6acSopenharmony_ci}
2986cd6a6acSopenharmony_ci
2996cd6a6acSopenharmony_ciohos_executable("setenforce") {
3006cd6a6acSopenharmony_ci  install_enable = true
3016cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/setenforce.c" ]
3026cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3036cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3046cd6a6acSopenharmony_ci
3056cd6a6acSopenharmony_ci  cflags = [
3066cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3076cd6a6acSopenharmony_ci    "-w",
3086cd6a6acSopenharmony_ci  ]
3096cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
3106cd6a6acSopenharmony_ci  part_name = "selinux"
3116cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
3126cd6a6acSopenharmony_ci  install_images = [
3136cd6a6acSopenharmony_ci    "system",
3146cd6a6acSopenharmony_ci    "updater",
3156cd6a6acSopenharmony_ci  ]
3166cd6a6acSopenharmony_ci}
3176cd6a6acSopenharmony_ci
3186cd6a6acSopenharmony_ciohos_executable("getenforce") {
3196cd6a6acSopenharmony_ci  install_enable = true
3206cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/getenforce.c" ]
3216cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3226cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3236cd6a6acSopenharmony_ci  cflags = [
3246cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3256cd6a6acSopenharmony_ci    "-w",
3266cd6a6acSopenharmony_ci  ]
3276cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
3286cd6a6acSopenharmony_ci  part_name = "selinux"
3296cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
3306cd6a6acSopenharmony_ci  install_images = [
3316cd6a6acSopenharmony_ci    "system",
3326cd6a6acSopenharmony_ci    "updater",
3336cd6a6acSopenharmony_ci  ]
3346cd6a6acSopenharmony_ci}
3356cd6a6acSopenharmony_ci
3366cd6a6acSopenharmony_ciohos_executable("getfilecon") {
3376cd6a6acSopenharmony_ci  install_enable = true
3386cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/getfilecon.c" ]
3396cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3406cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3416cd6a6acSopenharmony_ci  cflags = [
3426cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3436cd6a6acSopenharmony_ci    "-w",
3446cd6a6acSopenharmony_ci  ]
3456cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
3466cd6a6acSopenharmony_ci  part_name = "selinux"
3476cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
3486cd6a6acSopenharmony_ci  install_images = [
3496cd6a6acSopenharmony_ci    "system",
3506cd6a6acSopenharmony_ci    "updater",
3516cd6a6acSopenharmony_ci  ]
3526cd6a6acSopenharmony_ci}
3536cd6a6acSopenharmony_ci
3546cd6a6acSopenharmony_ciohos_executable("setfilecon") {
3556cd6a6acSopenharmony_ci  install_enable = true
3566cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/setfilecon.c" ]
3576cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3586cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3596cd6a6acSopenharmony_ci  cflags = [
3606cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3616cd6a6acSopenharmony_ci    "-w",
3626cd6a6acSopenharmony_ci  ]
3636cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
3646cd6a6acSopenharmony_ci  part_name = "selinux"
3656cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
3666cd6a6acSopenharmony_ci  install_images = [
3676cd6a6acSopenharmony_ci    "system",
3686cd6a6acSopenharmony_ci    "updater",
3696cd6a6acSopenharmony_ci  ]
3706cd6a6acSopenharmony_ci}
3716cd6a6acSopenharmony_ci
3726cd6a6acSopenharmony_ciohos_executable("selinuxexeccon") {
3736cd6a6acSopenharmony_ci  install_enable = true
3746cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/selinuxexeccon.c" ]
3756cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3766cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3776cd6a6acSopenharmony_ci  cflags = [
3786cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3796cd6a6acSopenharmony_ci    "-w",
3806cd6a6acSopenharmony_ci  ]
3816cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
3826cd6a6acSopenharmony_ci  part_name = "selinux"
3836cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
3846cd6a6acSopenharmony_ci  install_images = [
3856cd6a6acSopenharmony_ci    "system",
3866cd6a6acSopenharmony_ci    "updater",
3876cd6a6acSopenharmony_ci  ]
3886cd6a6acSopenharmony_ci}
3896cd6a6acSopenharmony_ci
3906cd6a6acSopenharmony_ciohos_executable("selinux_check_access") {
3916cd6a6acSopenharmony_ci  install_enable = true
3926cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/selinux_check_access.c" ]
3936cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
3946cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
3956cd6a6acSopenharmony_ci  cflags = [
3966cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
3976cd6a6acSopenharmony_ci    "-w",
3986cd6a6acSopenharmony_ci  ]
3996cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
4006cd6a6acSopenharmony_ci  part_name = "selinux"
4016cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
4026cd6a6acSopenharmony_ci  install_images = [
4036cd6a6acSopenharmony_ci    "system",
4046cd6a6acSopenharmony_ci    "updater",
4056cd6a6acSopenharmony_ci  ]
4066cd6a6acSopenharmony_ci}
4076cd6a6acSopenharmony_ci
4086cd6a6acSopenharmony_ciohos_executable("getpidcon") {
4096cd6a6acSopenharmony_ci  install_enable = true
4106cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/getpidcon.c" ]
4116cd6a6acSopenharmony_ci  deps = [ ":libselinux" ]
4126cd6a6acSopenharmony_ci  include_dirs = [ "$LIBSELINUX_ROOT_DIR/include" ]
4136cd6a6acSopenharmony_ci  cflags = [
4146cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
4156cd6a6acSopenharmony_ci    "-w",
4166cd6a6acSopenharmony_ci  ]
4176cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
4186cd6a6acSopenharmony_ci  part_name = "selinux"
4196cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
4206cd6a6acSopenharmony_ci  install_images = [
4216cd6a6acSopenharmony_ci    "system",
4226cd6a6acSopenharmony_ci    "updater",
4236cd6a6acSopenharmony_ci  ]
4246cd6a6acSopenharmony_ci}
4256cd6a6acSopenharmony_ci
4266cd6a6acSopenharmony_ciohos_executable("checkpolicy") {
4276cd6a6acSopenharmony_ci  md5_check_script = rebase_path("//third_party/selinux/check_md5.sh")
4286cd6a6acSopenharmony_ci  _arguments = [
4296cd6a6acSopenharmony_ci    rebase_path("checkpolicy/y.tab.c"),
4306cd6a6acSopenharmony_ci    rebase_path("checkpolicy/policy_parse.y"),
4316cd6a6acSopenharmony_ci    rebase_path("checkpolicy/y.tab.md5"),
4326cd6a6acSopenharmony_ci  ]
4336cd6a6acSopenharmony_ci  result = exec_script(md5_check_script, _arguments, "string")
4346cd6a6acSopenharmony_ci  if (result != "") {
4356cd6a6acSopenharmony_ci    exec_script("/usr/bin/bison",
4366cd6a6acSopenharmony_ci                [
4376cd6a6acSopenharmony_ci                  "-y",
4386cd6a6acSopenharmony_ci                  "-d",
4396cd6a6acSopenharmony_ci                  rebase_path("checkpolicy/policy_parse.y"),
4406cd6a6acSopenharmony_ci                  "-o",
4416cd6a6acSopenharmony_ci                  rebase_path("checkpolicy/y.tab.c"),
4426cd6a6acSopenharmony_ci                ],
4436cd6a6acSopenharmony_ci                "")
4446cd6a6acSopenharmony_ci  }
4456cd6a6acSopenharmony_ci  _arguments = []
4466cd6a6acSopenharmony_ci  _arguments = [
4476cd6a6acSopenharmony_ci    rebase_path("checkpolicy/policy_scan.c"),
4486cd6a6acSopenharmony_ci    rebase_path("checkpolicy/policy_scan.l"),
4496cd6a6acSopenharmony_ci    rebase_path("checkpolicy/policy_scan.md5"),
4506cd6a6acSopenharmony_ci  ]
4516cd6a6acSopenharmony_ci  result = exec_script(md5_check_script, _arguments, "string")
4526cd6a6acSopenharmony_ci  if (result != "") {
4536cd6a6acSopenharmony_ci    exec_script("/usr/bin/flex",
4546cd6a6acSopenharmony_ci                [
4556cd6a6acSopenharmony_ci                  "-o",
4566cd6a6acSopenharmony_ci                  rebase_path("checkpolicy/policy_scan.c"),
4576cd6a6acSopenharmony_ci                  rebase_path("checkpolicy/policy_scan.l"),
4586cd6a6acSopenharmony_ci                ],
4596cd6a6acSopenharmony_ci                "")
4606cd6a6acSopenharmony_ci  }
4616cd6a6acSopenharmony_ci  install_enable = true
4626cd6a6acSopenharmony_ci  sources = [
4636cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/checkpolicy.c",
4646cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/module_compiler.c",
4656cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/parse_util.c",
4666cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/policy_define.c",
4676cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/policy_scan.c",
4686cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/queue.c",
4696cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR/y.tab.c",
4706cd6a6acSopenharmony_ci  ]
4716cd6a6acSopenharmony_ci  deps = [ ":libsepol" ]
4726cd6a6acSopenharmony_ci  include_dirs = [
4736cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/include",
4746cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
4756cd6a6acSopenharmony_ci    "$CHECKPOLICY_ROOT_DIR",
4766cd6a6acSopenharmony_ci  ]
4776cd6a6acSopenharmony_ci  cflags = [
4786cd6a6acSopenharmony_ci    "-Wall",
4796cd6a6acSopenharmony_ci    "-Werror",
4806cd6a6acSopenharmony_ci    "-Wshadow",
4816cd6a6acSopenharmony_ci  ]
4826cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
4836cd6a6acSopenharmony_ci  part_name = "selinux"
4846cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
4856cd6a6acSopenharmony_ci}
4866cd6a6acSopenharmony_ci
4876cd6a6acSopenharmony_ciohos_executable("secilc") {
4886cd6a6acSopenharmony_ci  install_enable = true
4896cd6a6acSopenharmony_ci  sources = [ "$SECILC_ROOT_DIR/secilc.c" ]
4906cd6a6acSopenharmony_ci  deps = [ ":libsepol" ]
4916cd6a6acSopenharmony_ci  include_dirs = [
4926cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/cil/include",
4936cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
4946cd6a6acSopenharmony_ci  ]
4956cd6a6acSopenharmony_ci  cflags = [
4966cd6a6acSopenharmony_ci    "-Wall",
4976cd6a6acSopenharmony_ci    "-Werror",
4986cd6a6acSopenharmony_ci    "-Wshadow",
4996cd6a6acSopenharmony_ci  ]
5006cd6a6acSopenharmony_ci  license_file = "$LIBSEPOL_ROOT_DIR/LICENSE"
5016cd6a6acSopenharmony_ci  part_name = "selinux"
5026cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
5036cd6a6acSopenharmony_ci}
5046cd6a6acSopenharmony_ci
5056cd6a6acSopenharmony_ciohos_executable("sefcontext_compile") {
5066cd6a6acSopenharmony_ci  install_enable = true
5076cd6a6acSopenharmony_ci  sources = [ "$LIBSELINUX_ROOT_DIR/utils/sefcontext_compile.c" ]
5086cd6a6acSopenharmony_ci  deps = [
5096cd6a6acSopenharmony_ci    ":libselinux",
5106cd6a6acSopenharmony_ci    ":libsepol",
5116cd6a6acSopenharmony_ci  ]
5126cd6a6acSopenharmony_ci  external_deps = [ "pcre2:libpcre2" ]
5136cd6a6acSopenharmony_ci  include_dirs = [
5146cd6a6acSopenharmony_ci    "$LIBSELINUX_ROOT_DIR/include",
5156cd6a6acSopenharmony_ci    "$LIBSEPOL_ROOT_DIR/include",
5166cd6a6acSopenharmony_ci  ]
5176cd6a6acSopenharmony_ci  cflags = [
5186cd6a6acSopenharmony_ci    "-D_GNU_SOURCE",
5196cd6a6acSopenharmony_ci    "-DUSE_PCRE2",
5206cd6a6acSopenharmony_ci    "-DPCRE2_CODE_UNIT_WIDTH=8",
5216cd6a6acSopenharmony_ci    "-w",
5226cd6a6acSopenharmony_ci  ]
5236cd6a6acSopenharmony_ci  license_file = "$LIBSELINUX_ROOT_DIR/LICENSE"
5246cd6a6acSopenharmony_ci  part_name = "selinux"
5256cd6a6acSopenharmony_ci  subsystem_name = "thirdparty"
5266cd6a6acSopenharmony_ci}
527