加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BUILD.gn 8.01 KB
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 2024-09-10 11:35 . 添加PAC后向CFI
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/config.gni")
import("//build/ohos.gni")
# Execute the script and extract libxml2
action("libxml2_install_action") {
script = "//third_party/libxml2/install.py"
outputs = [
"${target_gen_dir}/libxml2-2.9.14/config.h.cmake.in",
"${target_gen_dir}/libxml2-2.9.14/include/libxml/xmlversion.h.in",
"${target_gen_dir}/libxml2-2.9.14/DOCBparser.c",
"${target_gen_dir}/libxml2-2.9.14/HTMLparser.c",
"${target_gen_dir}/libxml2-2.9.14/HTMLtree.c",
"${target_gen_dir}/libxml2-2.9.14/SAX.c",
"${target_gen_dir}/libxml2-2.9.14/SAX2.c",
"${target_gen_dir}/libxml2-2.9.14/buf.c",
"${target_gen_dir}/libxml2-2.9.14/c14n.c",
"${target_gen_dir}/libxml2-2.9.14/catalog.c",
"${target_gen_dir}/libxml2-2.9.14/chvalid.c",
"${target_gen_dir}/libxml2-2.9.14/debugXML.c",
"${target_gen_dir}/libxml2-2.9.14/dict.c",
"${target_gen_dir}/libxml2-2.9.14/encoding.c",
"${target_gen_dir}/libxml2-2.9.14/entities.c",
"${target_gen_dir}/libxml2-2.9.14/error.c",
"${target_gen_dir}/libxml2-2.9.14/globals.c",
"${target_gen_dir}/libxml2-2.9.14/hash.c",
"${target_gen_dir}/libxml2-2.9.14/legacy.c",
"${target_gen_dir}/libxml2-2.9.14/list.c",
"${target_gen_dir}/libxml2-2.9.14/nanoftp.c",
"${target_gen_dir}/libxml2-2.9.14/nanohttp.c",
"${target_gen_dir}/libxml2-2.9.14/parser.c",
"${target_gen_dir}/libxml2-2.9.14/parserInternals.c",
"${target_gen_dir}/libxml2-2.9.14/pattern.c",
"${target_gen_dir}/libxml2-2.9.14/relaxng.c",
"${target_gen_dir}/libxml2-2.9.14/schematron.c",
"${target_gen_dir}/libxml2-2.9.14/threads.c",
"${target_gen_dir}/libxml2-2.9.14/tree.c",
"${target_gen_dir}/libxml2-2.9.14/uri.c",
"${target_gen_dir}/libxml2-2.9.14/valid.c",
"${target_gen_dir}/libxml2-2.9.14/xinclude.c",
"${target_gen_dir}/libxml2-2.9.14/xlink.c",
"${target_gen_dir}/libxml2-2.9.14/xmlIO.c",
"${target_gen_dir}/libxml2-2.9.14/xmlmemory.c",
"${target_gen_dir}/libxml2-2.9.14/xmlmodule.c",
"${target_gen_dir}/libxml2-2.9.14/xmlreader.c",
"${target_gen_dir}/libxml2-2.9.14/xmlregexp.c",
"${target_gen_dir}/libxml2-2.9.14/xmlsave.c",
"${target_gen_dir}/libxml2-2.9.14/xmlschemas.c",
"${target_gen_dir}/libxml2-2.9.14/xmlschemastypes.c",
"${target_gen_dir}/libxml2-2.9.14/xmlstring.c",
"${target_gen_dir}/libxml2-2.9.14/xmlunicode.c",
"${target_gen_dir}/libxml2-2.9.14/xmlwriter.c",
"${target_gen_dir}/libxml2-2.9.14/xpath.c",
"${target_gen_dir}/libxml2-2.9.14/xpointer.c",
"${target_gen_dir}/libxml2-2.9.14/xzlib.c",
]
inputs = [ "//third_party/libxml2/libxml2-2.9.14.tar.xz" ]
args = [
"--gen-dir",
rebase_path("${target_gen_dir}", root_build_dir),
"--source-file",
rebase_path("//third_party/libxml2"),
]
}
# This is the configuration needed to use libxml2.
config("libxml2_config") {
include_dirs = [
get_label_info(":libxml2_generate_header", "target_out_dir") + "/include",
get_label_info(":libxml2_install_action", "target_gen_dir") +
"/libxml2-2.9.14/include",
]
}
# This is the configuration used to build libxml2 itself. It should not be needed outside of this
# library.
#
# This has to be a config instead of flags directly specified on the libxml2 target so the -Wno-*
# flags are ordered after the -Werror flags from the default configs.
config("libxml2_private_config") {
visibility = [ ":*" ]
cflags = [
"-Wno-empty-body",
"-Wno-incompatible-pointer-types",
"-Wno-missing-field-initializers",
"-Wno-self-assign",
"-Wno-sign-compare",
"-Wno-tautological-pointer-compare",
"-Wno-unused-function",
"-Wno-enum-compare",
"-Wno-int-conversion",
"-Wno-uninitialized",
]
defines = [
"HAVE_CONFIG_H",
"_REENTRANT",
]
if (is_linux) {
defines += [ "_GNU_SOURCE" ]
}
}
# This is the configuration needed to use static libxml2.
config("libxml2_static_config") {
include_dirs = [
get_label_info(":libxml2_generate_header", "target_out_dir") + "/include",
get_label_info(":libxml2_install_action", "target_gen_dir") +
"/libxml2-2.9.14/include",
]
if (is_mingw) {
defines = [ "LIBXML_STATIC" ]
} else {
defines = [
"HAVE_CONFIG_H",
"_REENTRANT",
]
}
}
config("libxml2_static_private_config") {
cflags = [
"-Wno-implicit-fallthrough",
"-Wno-implicit-function-declaration",
"-Wno-int-conversion",
"-Wno-uninitialized",
"-Wno-sometimes-uninitialized",
]
cflags_cc = [ "-std=c++17" ]
}
group("xml2") {
public_deps = [ ":libxml2" ]
}
ohos_shared_library("libxml2") {
branch_protector_ret = "pac_ret"
output_values = get_target_outputs(":libxml2_install_action")
sources = filter_exclude(output_values,
[
"*.h.cmake.in",
"*.h.in",
])
public_configs = [ ":libxml2_config" ]
configs = [ ":libxml2_private_config" ]
if (is_linux) {
libs = [ "dl" ]
}
if (current_os == "ios") {
ldflags = [
"-Wl",
"-install_name",
"@rpath/libxml2_shared.framework/libxml2_shared",
]
output_name = "xml2_shared"
}
deps = [
":libxml2_generate_header",
":libxml2_install_action",
]
innerapi_tags = [
"chipsetsdk",
"platformsdk",
"sasdk",
]
install_images = [
"updater",
"system",
]
part_name = "libxml2"
subsystem_name = "thirdparty"
}
if (current_os == "ios") {
ohos_combine_darwin_framework("libxml2_shared") {
deps = [ ":libxml2" ]
subsystem_name = "thirdparty"
part_name = "libxml2"
}
}
ohos_static_library("static_libxml2") {
output_values = get_target_outputs(":libxml2_install_action")
sources = filter_exclude(output_values,
[
"*.h.cmake.in",
"*.h.in",
])
public_configs = [ ":libxml2_static_config" ]
configs = [ ":libxml2_static_private_config" ]
deps = [
":libxml2_generate_header",
":libxml2_install_action",
]
part_name = "libxml2"
subsystem_name = "thirdparty"
}
action("libxml2_generate_header") {
script = "generate_header.py"
config_in_path = get_label_info(":libxml2_install_action", "target_gen_dir") +
"/libxml2-2.9.14/config.h.cmake.in"
xmlversion_in_path =
get_label_info(":libxml2_install_action", "target_gen_dir") +
"/libxml2-2.9.14/include/libxml/xmlversion.h.in"
config_json_path = "config_linux.json"
xml_version_json_path = "xml_version.json"
if (is_mingw) {
config_json_path = "config_win.json"
}
inputs = [
config_in_path,
xmlversion_in_path,
config_json_path,
xml_version_json_path,
]
config_path = get_label_info(":libxml2_generate_header", "target_out_dir") +
"/include/config.h"
xmlversion_path =
get_label_info(":libxml2_generate_header", "target_out_dir") +
"/include/libxml/xmlversion.h"
outputs = [
config_path,
xmlversion_path,
]
args = [
"--config-input-path",
rebase_path(config_in_path, root_build_dir),
"--config-path",
rebase_path(config_path, root_build_dir),
"--xmlversion-input-path",
rebase_path(xmlversion_in_path, root_build_dir),
"--xmlversion-path",
rebase_path(xmlversion_path, root_build_dir),
"--config-json",
rebase_path(config_json_path, root_build_dir),
"--xmlversion-json",
rebase_path(xml_version_json_path, root_build_dir),
]
deps = [ ":libxml2_install_action" ]
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化