libxml2编译脚本归一

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2023-02-11 07:38:42 +00:00
parent 4ba16a64f1
commit 93ac9569ac
5 changed files with 457 additions and 95 deletions
+170 -95
View File
@@ -47,102 +47,103 @@ group("libxml2") {
public_deps = [ ":xml2" ]
}
ohos_shared_library("xml2") {
sources = [
"DOCBparser.c",
"HTMLparser.c",
"HTMLtree.c",
"SAX.c",
"SAX2.c",
"buf.c",
"c14n.c",
"catalog.c",
"chvalid.c",
"debugXML.c",
"dict.c",
"encoding.c",
"entities.c",
"error.c",
"globals.c",
"hash.c",
"include/libxml/DOCBparser.h",
"include/libxml/HTMLparser.h",
"include/libxml/HTMLtree.h",
"include/libxml/SAX.h",
"include/libxml/SAX2.h",
"include/libxml/c14n.h",
"include/libxml/catalog.h",
"include/libxml/chvalid.h",
"include/libxml/debugXML.h",
"include/libxml/dict.h",
"include/libxml/encoding.h",
"include/libxml/entities.h",
"include/libxml/globals.h",
"include/libxml/hash.h",
"include/libxml/list.h",
"include/libxml/nanoftp.h",
"include/libxml/nanohttp.h",
"include/libxml/parser.h",
"include/libxml/parserInternals.h",
"include/libxml/pattern.h",
"include/libxml/relaxng.h",
"include/libxml/schemasInternals.h",
"include/libxml/schematron.h",
"include/libxml/threads.h",
"include/libxml/tree.h",
"include/libxml/uri.h",
"include/libxml/valid.h",
"include/libxml/xinclude.h",
"include/libxml/xlink.h",
"include/libxml/xmlIO.h",
"include/libxml/xmlautomata.h",
"include/libxml/xmlerror.h",
"include/libxml/xmlexports.h",
"include/libxml/xmlmemory.h",
"include/libxml/xmlmodule.h",
"include/libxml/xmlreader.h",
"include/libxml/xmlregexp.h",
"include/libxml/xmlsave.h",
"include/libxml/xmlschemas.h",
"include/libxml/xmlschemastypes.h",
"include/libxml/xmlstring.h",
"include/libxml/xmlunicode.h",
"include/libxml/xmlversion.h",
"include/libxml/xmlwriter.h",
"include/libxml/xpath.h",
"include/libxml/xpathInternals.h",
"include/libxml/xpointer.h",
"legacy.c",
"list.c",
"nanoftp.c",
"nanohttp.c",
"parser.c",
"parserInternals.c",
"pattern.c",
"relaxng.c",
"schematron.c",
"threads.c",
"tree.c",
"uri.c",
"valid.c",
"xinclude.c",
"xlink.c",
"xmlIO.c",
"xmlmemory.c",
"xmlmodule.c",
"xmlreader.c",
"xmlregexp.c",
"xmlsave.c",
"xmlschemas.c",
"xmlschemastypes.c",
"xmlstring.c",
"xmlunicode.c",
"xmlwriter.c",
"xpath.c",
"xpointer.c",
"xzlib.c",
]
manager_sources = [
"DOCBparser.c",
"HTMLparser.c",
"HTMLtree.c",
"SAX.c",
"SAX2.c",
"buf.c",
"c14n.c",
"catalog.c",
"chvalid.c",
"debugXML.c",
"dict.c",
"encoding.c",
"entities.c",
"error.c",
"globals.c",
"hash.c",
"include/libxml/DOCBparser.h",
"include/libxml/HTMLparser.h",
"include/libxml/HTMLtree.h",
"include/libxml/SAX.h",
"include/libxml/SAX2.h",
"include/libxml/c14n.h",
"include/libxml/catalog.h",
"include/libxml/chvalid.h",
"include/libxml/debugXML.h",
"include/libxml/dict.h",
"include/libxml/encoding.h",
"include/libxml/entities.h",
"include/libxml/globals.h",
"include/libxml/hash.h",
"include/libxml/list.h",
"include/libxml/nanoftp.h",
"include/libxml/nanohttp.h",
"include/libxml/parser.h",
"include/libxml/parserInternals.h",
"include/libxml/pattern.h",
"include/libxml/relaxng.h",
"include/libxml/schemasInternals.h",
"include/libxml/schematron.h",
"include/libxml/threads.h",
"include/libxml/tree.h",
"include/libxml/uri.h",
"include/libxml/valid.h",
"include/libxml/xinclude.h",
"include/libxml/xlink.h",
"include/libxml/xmlIO.h",
"include/libxml/xmlautomata.h",
"include/libxml/xmlerror.h",
"include/libxml/xmlexports.h",
"include/libxml/xmlmemory.h",
"include/libxml/xmlmodule.h",
"include/libxml/xmlreader.h",
"include/libxml/xmlregexp.h",
"include/libxml/xmlsave.h",
"include/libxml/xmlschemas.h",
"include/libxml/xmlschemastypes.h",
"include/libxml/xmlstring.h",
"include/libxml/xmlunicode.h",
"include/libxml/xmlversion.h",
"include/libxml/xmlwriter.h",
"include/libxml/xpath.h",
"include/libxml/xpathInternals.h",
"include/libxml/xpointer.h",
"legacy.c",
"list.c",
"nanoftp.c",
"nanohttp.c",
"parser.c",
"parserInternals.c",
"pattern.c",
"relaxng.c",
"schematron.c",
"threads.c",
"tree.c",
"uri.c",
"valid.c",
"xinclude.c",
"xlink.c",
"xmlIO.c",
"xmlmemory.c",
"xmlmodule.c",
"xmlreader.c",
"xmlregexp.c",
"xmlsave.c",
"xmlschemas.c",
"xmlschemastypes.c",
"xmlstring.c",
"xmlunicode.c",
"xmlwriter.c",
"xpath.c",
"xpointer.c",
"xzlib.c",
]
ohos_shared_library("xml2") {
sources = manager_sources
public_configs = [ ":libxml2_config" ]
configs = [ ":libxml2_private_config" ]
@@ -155,3 +156,77 @@ ohos_shared_library("xml2") {
part_name = "libxml2"
subsystem_name = "thirdparty"
}
config("libxml2_static_config") {
cflags = [
"-Wno-implicit-fallthrough",
"-Wno-implicit-function-declaration",
"-Wno-int-conversion",
"-Wno-uninitialized",
"-Wno-sometimes-uninitialized",
]
include_dirs = []
if (is_mingw) {
defines = [ "LIBXML_STATIC" ]
include_dirs += [ get_label_info(":libxml2_generate_header",
"target_out_dir") + "/include" ]
} else if (is_mac) {
defines = [ "LIBXML_THREAD_ENABLED" ]
} else if (is_linux) {
include_dirs += [ get_label_info(":libxml2_generate_header",
"target_out_dir") + "/include" ]
}
include_dirs += [ "include" ]
cflags_cc = [ "-std=c++17" ]
}
ohos_static_library("static_libxml2") {
sources = manager_sources
public_configs = [ ":libxml2_static_config" ]
deps = [ ":libxml2_generate_header" ]
subsystem_name = "thirdparty"
part_name = "libxml2"
}
action("libxml2_generate_header") {
script = "generate_header.py"
inputs = [
"config.h.cmake.in",
"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_json_path ]
inputs += [ 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.h.cmake.in", root_build_dir),
"--config-path",
rebase_path(config_path, root_build_dir),
"--xmlversion-input-path",
rebase_path("include/libxml/xmlversion.h.in", 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),
]
}
+76
View File
@@ -0,0 +1,76 @@
{
"ATTRIBUTE_DESTRUCTOR":"1",
"GETHOSTBYNAME_ARG_CAST":"(char *)",
"HAVE_CTYPE_H":"1",
"HAVE_DIRENT_H":"1",
"HAVE_ERRNO_H":"1",
"HAVE_FCNTL_H":"1",
"HAVE_FLOAT_H":"1",
"HAVE_FPRINTF":"1",
"HAVE_FTIME":"1",
"HAVE_GETTIMEOFDAY":"1",
"HAVE_INTTYPES_H":"1",
"HAVE_ISASCII":"1",
"HAVE_ISNAN":"1",
"HAVE_LIBPTHREAD":"1",
"HAVE_LIMITS_H":"1",
"HAVE_LOCALTIME":"1",
"HAVE_MALLOC_H":"1",
"HAVE_MATH_H":"1",
"HAVE_MEMORY_H":"1",
"HAVE_PRINTF":"1",
"HAVE_PTHREAD_H":"1",
"HAVE_PUTENV":"1",
"HAVE_RAND":"1",
"HAVE_SIGNAL":"1",
"HAVE_SIGNAL_H":"1",
"HAVE_SNPRINTF":"1",
"HAVE_SPRINTF":"1",
"HAVE_SRAND":"1",
"HAVE_SSCANF":"1",
"HAVE_STAT":"1",
"HAVE_STDARG_H":"1",
"HAVE_STDINT_H":"1",
"HAVE_STDLIB_H":"1",
"HAVE_STRFTIME":"1",
"HAVE_STRINGS_H":"1",
"HAVE_STRING_H":"1",
"HAVE_SYS_STAT_H":"1",
"HAVE_SYS_TIMEB_H":"1",
"HAVE_SYS_TIME_H":"1",
"HAVE_SYS_TYPES_H":"1",
"HAVE_TIME":"1",
"HAVE_TIME_H":"1",
"HAVE_UNISTD_H":"1",
"HAVE_VFPRINTF":"1",
"HAVE_VSNPRINTF":"1",
"HAVE_VSPRINTF":"1",
"ICONV_CONST":"const",
"PACKAGE":"libxml2",
"PACKAGE_BUGREPORT":"xml@gnome.org",
"PACKAGE_NAME":"libxml2",
"PACKAGE_STRING":"libxml2 2.9.13",
"PACKAGE_TARNAME":"libxml2",
"PACKAGE_URL":"http://www.xmlsoft.org/",
"PACKAGE_VERSION":"2.9.13",
"SEND_ARG2_CAST":"",
"STDC_HEADERS":"1",
"VA_LIST_IS_ARRAY":"1",
"VERSION":"2.9.13",
"XML_SOCKLEN_T":"socklen_t",
"HAVE_ARPA_INET_H":"1",
"HAVE_ARPA_NAMESER_H":1,
"HAVE_DLFCN_H":"1",
"HAVE_DLOPEN":"1",
"HAVE_GETADDRINFO":"1",
"HAVE_ISINF":"1",
"HAVE_MMAP":"1",
"HAVE_NETDB_H":"1",
"HAVE_NETINET_IN_H":"1",
"HAVE_POLL_H":"1",
"HAVE_RAND_R":"1",
"HAVE_RESOLV_H":"1",
"HAVE_SYS_MMAN_H":"1",
"HAVE_SYS_SELECT_H":"1",
"HAVE_SYS_SOCKET_H":"1"
}
+61
View File
@@ -0,0 +1,61 @@
{
"ATTRIBUTE_DESTRUCTOR":"1",
"GETHOSTBYNAME_ARG_CAST":"(char *)",
"HAVE_CTYPE_H":"1",
"HAVE_DIRENT_H":"1",
"HAVE_ERRNO_H":"1",
"HAVE_FCNTL_H":"1",
"HAVE_FLOAT_H":"1",
"HAVE_FPRINTF":"1",
"HAVE_FTIME":"1",
"HAVE_GETTIMEOFDAY":"1",
"HAVE_INTTYPES_H":"1",
"HAVE_ISASCII":"1",
"HAVE_ISNAN":"1",
"HAVE_LIBPTHREAD":"1",
"HAVE_LIMITS_H":"1",
"HAVE_LOCALTIME":"1",
"HAVE_MALLOC_H":"1",
"HAVE_MATH_H":"1",
"HAVE_MEMORY_H":"1",
"HAVE_PRINTF":"1",
"HAVE_PTHREAD_H":"1",
"HAVE_PUTENV":"1",
"HAVE_RAND":"1",
"HAVE_SIGNAL":"1",
"HAVE_SIGNAL_H":"1",
"HAVE_SNPRINTF":"1",
"HAVE_SPRINTF":"1",
"HAVE_SRAND":"1",
"HAVE_SSCANF":"1",
"HAVE_STAT":"1",
"HAVE_STDARG_H":"1",
"HAVE_STDINT_H":"1",
"HAVE_STDLIB_H":"1",
"HAVE_STRFTIME":"1",
"HAVE_STRINGS_H":"1",
"HAVE_STRING_H":"1",
"HAVE_SYS_STAT_H":"1",
"HAVE_SYS_TIMEB_H":"1",
"HAVE_SYS_TIME_H":"1",
"HAVE_SYS_TYPES_H":"1",
"HAVE_TIME":"1",
"HAVE_TIME_H":"1",
"HAVE_UNISTD_H":"1",
"HAVE_VFPRINTF":"1",
"HAVE_VSNPRINTF":"1",
"HAVE_VSPRINTF":"1",
"ICONV_CONST":"",
"PACKAGE":"libxml2",
"PACKAGE_BUGREPORT":"xml@gnome.org",
"PACKAGE_NAME":"libxml2",
"PACKAGE_STRING":"libxml2 2.9.13",
"PACKAGE_TARNAME":"libxml2",
"PACKAGE_URL":"http://www.xmlsoft.org/",
"PACKAGE_VERSION":"2.9.13",
"SEND_ARG2_CAST":"(char*)",
"STDC_HEADERS":"1",
"VA_LIST_IS_ARRAY":"1",
"VERSION":"2.9.13",
"XML_SOCKLEN_T":"int"
}
+119
View File
@@ -0,0 +1,119 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2022 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 argparse
import json
import os
import re
class ConfigHeader:
def __init__(self, config_json_path):
self.read_buffer = []
self.write_buffer = []
with os.fdopen(os.open(config_json_path, os.O_RDONLY, 0o755), 'r') as file:
self.configs = json.load(file)
def parse_file(self, file_path):
with os.fdopen(os.open(file_path, os.O_RDONLY, 0o755), 'r') as file:
self.read_buffer = file.readlines()
for item in self.read_buffer:
if not item.startswith("#cmakedefine") and not item.startswith("#define"):
self.write_buffer.append(item)
continue
value = item
if item.startswith("#cmakedefine"):
value = item.replace("#cmakedefine", "#define")
match_object = re.search(r' \w+ ', value)
if match_object is None:
self.write_buffer.append("/* " + item + " */")
continue
key = match_object.group()
key_index = key.replace(" ", "")
if key_index not in self.configs:
self.write_buffer.append("/* " + item + " */")
continue
match_object = re.search(r'@\w+@', value)
if match_object is None:
self.write_buffer.append(value)
continue
key = match_object.group()
key_index = key.replace("@", "")
if key_index not in self.configs:
self.write_buffer.append("/* " + item + " */")
continue
value = value.replace(key, self.configs[key_index])
self.write_buffer.append(value)
def write_file(self, file_path):
with os.fdopen(os.open(file_path, os.O_WRONLY | os.O_CREAT, 0o755), 'w') as file:
file.writelines(self.write_buffer)
class XmlVersionHeader:
def __init__(self, xmlversion_json_path):
self.read_buffer = []
self.write_buffer = []
with os.fdopen(os.open(xmlversion_json_path, os.O_RDONLY, 0o755), 'r') as file:
self.configs = json.load(file)
def parse_file(self, file_path):
with os.fdopen(os.open(file_path, os.O_RDONLY, 0o755), 'r') as file:
self.read_buffer = file.readlines()
for item in self.read_buffer:
if not item.startswith("#if") and not item.startswith("#define"):
self.write_buffer.append(item)
continue
match_object = re.search(r'@\w+@', item)
if match_object is None:
self.write_buffer.append(item)
continue
key = match_object.group()
index_key = key.replace("@", "")
value = ""
if index_key in self.configs:
value = item.replace(key, self.configs[index_key])
else:
value = item.replace(key, "0")
self.write_buffer.append(value)
def write_file(self, file_path):
with os.fdopen(os.open(file_path, os.O_WRONLY | os.O_CREAT, 0o755), 'w') as file:
file.writelines(self.write_buffer)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--config-input-path', help='input path to config.h')
parser.add_argument('--config-path', help='output path to config.h')
parser.add_argument('--xmlversion-input-path', help='input path to xmlversion.h')
parser.add_argument('--xmlversion-path', help='output path to xmlversion.h')
parser.add_argument('--config-json', help='config value for config.h')
parser.add_argument('--xmlversion-json', help='config value for xmlversion.h')
options = parser.parse_args()
config_header = ConfigHeader(options.config_json)
config_header.parse_file(options.config_input_path)
config_header.write_file(options.config_path)
xmlversion_header = XmlVersionHeader(options.xmlversion_json)
xmlversion_header.parse_file(options.xmlversion_input_path)
xmlversion_header.write_file(options.xmlversion_path)
+31
View File
@@ -0,0 +1,31 @@
{
"VERSION":"2.9.13",
"LIBXML_VERSION_NUMBER":"209013",
"LIBXML_VERSION_EXTRA":"",
"WITH_THREADS":"1",
"WITH_TREE":"1",
"WITH_OUTPUT":"1",
"WITH_PUSH":"1",
"WITH_READER":"1",
"WITH_PATTERN":"1",
"WITH_WRITER":"1",
"WITH_SAX1":"1",
"WITH_FTP":"1",
"WITH_HTTP":"1",
"WITH_VALID":"1",
"WITH_HTML":"1",
"WITH_LEGACY":"1",
"WITH_C14N":"1",
"WITH_CATALOG":"1",
"WITH_DOCB":"1",
"WITH_XPATH":"1",
"WITH_XPTR":"1",
"WITH_XINCLUDE":"1",
"WITH_ISO8859X":"1",
"WITH_DEBUG":"1",
"WITH_REGEXPS":"1",
"WITH_SCHEMAS":"1",
"WITH_SCHEMATRON":"1",
"WITH_MODULES":"1",
"MODULE_EXTENSION":".so"
}