From 4b46d32c48d6c2287556b5fb508a07057fe7ea87 Mon Sep 17 00:00:00 2001 From: chencheng31 Date: Thu, 10 Mar 2022 20:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=20BUILD.gn=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chencheng31 --- BUILD.gn | 85 +++ CMakeLists.txt | 10 +- OTA.xml | 5 +- README.md | 33 +- README_zh.md | 33 +- build/bounds_checking_function/BUILD.gn | 37 ++ .../bounds_checking_function/CMakeLists.txt | 0 build/jsoncpp/BUILD.gn | 30 ++ {third_party => build}/jsoncpp/CMakeLists.txt | 0 build/libxml2/BUILD.gn | 143 ++++++ {third_party => build}/libxml2/CMakeLists.txt | 26 +- .../libxml2/config.h.cmake.in | 0 build/libxml2/win32/include/config.h | 288 +++++++++++ .../libxml2/win32/include/libxml/xmlversion.h | 485 ++++++++++++++++++ build/sqlite3/BUILD.gn | 26 + {third_party => build}/sqlite3/CMakeLists.txt | 0 bundle.json | 34 ++ include/file_entry.h | 71 +++ include/resource_item.h | 2 +- include/resource_util.h | 4 +- src/cmd_parser.cpp | 1 - src/file_entry.cpp | 271 ++++++++++ src/file_manager.cpp | 6 +- src/generic_compiler.cpp | 6 +- src/i_resource_compiler.cpp | 32 +- src/id_worker.cpp | 8 +- src/increment_list.cpp | 12 +- src/increment_manager.cpp | 72 +-- src/module_combine.cpp | 24 +- src/preview_manager.cpp | 14 +- src/reference_parser.cpp | 18 +- src/resource_directory.cpp | 32 +- src/resource_item.cpp | 2 +- src/resource_merge.cpp | 5 +- src/resource_module.cpp | 2 +- src/resource_module_inc.cpp | 16 +- src/resource_pack.cpp | 46 +- src/resource_table.cpp | 4 +- src/resource_util.cpp | 31 +- src/solid_xml_compiler.cpp | 1 - src/xml/key_manager.cpp | 6 +- src/xml/xml_converter.cpp | 6 +- test/config.json | 60 +++ test/resources/base/element/strings.json | 5 + test/resources/base/media/icon.png | Bin 0 -> 4331 bytes test/test.py | 27 + 46 files changed, 1811 insertions(+), 208 deletions(-) create mode 100644 BUILD.gn create mode 100644 build/bounds_checking_function/BUILD.gn rename {third_party => build}/bounds_checking_function/CMakeLists.txt (100%) create mode 100644 build/jsoncpp/BUILD.gn rename {third_party => build}/jsoncpp/CMakeLists.txt (100%) create mode 100644 build/libxml2/BUILD.gn rename {third_party => build}/libxml2/CMakeLists.txt (95%) rename {third_party => build}/libxml2/config.h.cmake.in (100%) create mode 100644 build/libxml2/win32/include/config.h create mode 100644 build/libxml2/win32/include/libxml/xmlversion.h create mode 100644 build/sqlite3/BUILD.gn rename {third_party => build}/sqlite3/CMakeLists.txt (100%) create mode 100644 bundle.json create mode 100644 include/file_entry.h create mode 100644 src/file_entry.cpp create mode 100644 test/config.json create mode 100644 test/resources/base/element/strings.json create mode 100644 test/resources/base/media/icon.png create mode 100644 test/test.py diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..e969a8e --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,85 @@ +# 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("//build/ohos.gni") +import("//build/test.gni") +ohos_executable("restool") { + sources = [ + "src/xml/key_manager.cpp", + "src/xml/solid_xml.cpp", + "src/xml/xml_converter.cpp", + "src/xml/xml_key_node.cpp", + "src/cmd_list.cpp", + "src/cmd_parser.cpp", + "src/config_parser.cpp", + "src/factory_resource_compiler.cpp", + "src/file_entry.cpp", + "src/file_manager.cpp", + "src/generic_compiler.cpp", + "src/header.cpp", + "src/i_resource_compiler.cpp", + "src/id_worker.cpp", + "src/increment_index.cpp", + "src/increment_list.cpp", + "src/increment_manager.cpp", + "src/json_compiler.cpp", + "src/key_parser.cpp", + "src/module_combine.cpp", + "src/preview_manager.cpp", + "src/reference_parser.cpp", + "src/resource_directory.cpp", + "src/resource_item.cpp", + "src/resource_merge.cpp", + "src/resource_module.cpp", + "src/resource_module_inc.cpp", + "src/resource_pack.cpp", + "src/resource_table.cpp", + "src/resource_util.cpp", + "src/restool.cpp", + "src/solid_xml_compiler.cpp", + "src/sqlite_database.cpp", + "src/task_handle.cpp" + ] + + include_dirs = [] + if (is_mingw) { + include_dirs += [ + "//developtools/global_resource_tool/build/libxml2/win32/include" + ] + } + include_dirs += [ + "include", + "//third_party/libxml2/include", + "//third_party/jsoncpp/include", + "//third_party/sqlite/include", + "//third_party/bounds_checking_function/include" + ] + + deps = [ + "//developtools/global_resource_tool/build/jsoncpp:restool_jsoncpp", + "//developtools/global_resource_tool/build/sqlite3:restool_sqlite", + "//developtools/global_resource_tool/build/libxml2:restool_libxml2", + "//developtools/global_resource_tool/build/bounds_checking_function:restool_bounds_checking_function" + ] + + cflags = [ "-std=c++17" ] + if (is_mingw) { + ldflags = [ "-static", "-lws2_32" ] + } + subsystem_name = "developtools" + part_name = "global_restool" +} + +ohos_unittest_py("restool_test") { + sources = [ "test/test.py" ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a1bfca4..f32cef8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(sqlite3_dir ${CMAKE_SOURCE_DIR}/../../third_party/sqlite) include_directories(include) include_directories(${jsoncpp_dir}/include) include_directories(${bound_checking_function_dir}/include) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/libxml2/libxml2/include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/build/libxml2/include) include_directories(${sqlite3_dir}/include) aux_source_directory(src restool_source) @@ -31,7 +31,7 @@ aux_source_directory(src/xml restool_source) add_executable(restool ${restool_source}) target_link_libraries(restool myxml2 jsoncpp securec sqlite3) -add_subdirectory(third_party/libxml2) -add_subdirectory(third_party/jsoncpp) -add_subdirectory(third_party/bounds_checking_function) -add_subdirectory(third_party/sqlite3) +add_subdirectory(build/libxml2) +add_subdirectory(build/jsoncpp) +add_subdirectory(build/bounds_checking_function) +add_subdirectory(build/sqlite3) diff --git a/OTA.xml b/OTA.xml index 29f7b9f..973cadd 100644 --- a/OTA.xml +++ b/OTA.xml @@ -63,9 +63,12 @@ - + + + + diff --git a/README.md b/README.md index b1ec3df..c24713e 100644 --- a/README.md +++ b/README.md @@ -10,22 +10,37 @@ restool(resource tool) is used in computer.In OpenHarmony SDK toolchain.When IDE |----global_resource_tool | |----include | |----src -| |----third_party dependence third patry lib make script +| |----test +| |----build dependence third patry lib make script | |----CMakeLists.txt +| |----BUILD.gn | |----win32.cmake windows cross compile script ``` ## Instructions -### Compile +### Quickly Build -1. gcc/g++ version 9.3.0 required -2. cmake version mini 3.15 required -3. mkdir build -4. cd build -5. cmake ../restool_standard -6. make -7. compile result restool binary +1. ubuntu 18 preinstalled gcc/g++ +2. cmake version mini 3.15 required +3. mkdir build +4. cd build +5. cmake ../global_resource_tool +6. make +7. compile result restool binary + +### SDK Build + +1. ./build.sh --product-name ohos-sdk + +SDK build refer to https://gitee.com/openharmony/build/blob/master/README_zh.md + +### Test + +1.in PC, run python test/test.py param1 param2 + +param1: restool path +param2: result path ### Help diff --git a/README_zh.md b/README_zh.md index b2997f8..72cea9c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -10,22 +10,37 @@ |----global_resource_tool | |----include | |----src -| |----third_party 依赖三方库编译脚本 +| |----test +| |----build 依赖三方库编译脚本 +| |----BUILD.gn | |----CMakeLists.txt | |----win32.cmake windows交叉编译脚本 ``` ## 使用说明 -### 代码编译命令 +### 快速调试编译 -1. 编译环境gcc/g++ 9.3.0 -2. cmake 版本最低3.15 -3. 与global_resource_tool同级目录新建build -4. cd build -5. cmake ../global_resource_tool -6. make -7. 编译结果输出restool +1. ubuntu 18 系统预装 gcc/g++ +2. cmake 版本最低3.15 +3. 与global_resource_tool同级目录新建build +4. cd build +5. cmake ../global_resource_tool +6. make +7. 编译结果输出restool + +### SDK编译命令 + +1. ./build.sh --product-nane ohos-sdk + +SDK 编译参考https://gitee.com/openharmony/build/blob/master/README_zh.md 仓编译sdk说明。 + +### 测试用例 + +1.PC 上运行 python test/test.py 参数1 参数2 + +参数1 restool 命令路径 +参数2 输出结果路径 ### 命令帮助 diff --git a/build/bounds_checking_function/BUILD.gn b/build/bounds_checking_function/BUILD.gn new file mode 100644 index 0000000..ce63238 --- /dev/null +++ b/build/bounds_checking_function/BUILD.gn @@ -0,0 +1,37 @@ +# 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("//build/ohos.gni") +import("//third_party/bounds_checking_function/libsec_src.gni") +ohos_static_library("restool_bounds_checking_function") { + sources = libsec_sources + + include_dirs = [ + "//third_party/bounds_checking_function/include" + ] + + cflags_cc = [ "-std=c++17" ] + cflags_c =[ + "-Wno-attributes", + "-Wno-inconsistent-dllimport", + "-D_INC_STRING_S", + "-D_INC_WCHAR_S", + "-D_SECIMP=//", + "-D_STDIO_S_DEFINED", + "-D_INC_STDIO_S", + "-D_INC_STDLIB_S", + "-D_INC_MEMORY_S" + ] + subsystem_name = "developtools" + part_name = "global_restool" +} \ No newline at end of file diff --git a/third_party/bounds_checking_function/CMakeLists.txt b/build/bounds_checking_function/CMakeLists.txt similarity index 100% rename from third_party/bounds_checking_function/CMakeLists.txt rename to build/bounds_checking_function/CMakeLists.txt diff --git a/build/jsoncpp/BUILD.gn b/build/jsoncpp/BUILD.gn new file mode 100644 index 0000000..b1bdff1 --- /dev/null +++ b/build/jsoncpp/BUILD.gn @@ -0,0 +1,30 @@ +# 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("//build/ohos.gni") +ohos_static_library("restool_jsoncpp") { + sources = [ + "//third_party/jsoncpp/src/lib_json/json_reader.cpp", + "//third_party/jsoncpp/src/lib_json/json_value.cpp", + "//third_party/jsoncpp/src/lib_json/json_writer.cpp" + ] + + include_dirs = [ + "//third_party/jsoncpp/include" + ] + + cflags = [ "-std=c++17" ] + use_exceptions = true + subsystem_name = "developtools" + part_name = "global_restool" +} \ No newline at end of file diff --git a/third_party/jsoncpp/CMakeLists.txt b/build/jsoncpp/CMakeLists.txt similarity index 100% rename from third_party/jsoncpp/CMakeLists.txt rename to build/jsoncpp/CMakeLists.txt diff --git a/build/libxml2/BUILD.gn b/build/libxml2/BUILD.gn new file mode 100644 index 0000000..be0c3ce --- /dev/null +++ b/build/libxml2/BUILD.gn @@ -0,0 +1,143 @@ +# 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("//build/ohos.gni") +LIBXML_PATH = "//third_party/libxml2" + +config("restool_libxml2_config") { + include_dirs = [] + if (is_mingw) { + include_dirs += [ + "//developtools/global_resource_tool/build/libxml2/win32/include" + ] + defines = [ "LIBXML_STATIC"] + } else { + include_dirs += [ + "${LIBXML_PATH}/config" + ] + } + + include_dirs += [ + "${LIBXML_PATH}/include" + ] + + cflags_cc = [ + "-std=c++17" + ] + + cflags_c = [ + "-Wno-implicit-fallthrough", + "-Wno-implicit-function-declaration", + "-Wno-int-conversion" + ] +} + +ohos_static_library("restool_libxml2") { + sources = [ + "${LIBXML_PATH}/DOCBparser.c", + "${LIBXML_PATH}/HTMLparser.c", + "${LIBXML_PATH}/HTMLtree.c", + "${LIBXML_PATH}/SAX.c", + "${LIBXML_PATH}/SAX2.c", + "${LIBXML_PATH}/buf.c", + "${LIBXML_PATH}/c14n.c", + "${LIBXML_PATH}/catalog.c", + "${LIBXML_PATH}/chvalid.c", + "${LIBXML_PATH}/debugXML.c", + "${LIBXML_PATH}/dict.c", + "${LIBXML_PATH}/encoding.c", + "${LIBXML_PATH}/entities.c", + "${LIBXML_PATH}/error.c", + "${LIBXML_PATH}/globals.c", + "${LIBXML_PATH}/hash.c", + "${LIBXML_PATH}/include/libxml/DOCBparser.h", + "${LIBXML_PATH}/include/libxml/HTMLparser.h", + "${LIBXML_PATH}/include/libxml/HTMLtree.h", + "${LIBXML_PATH}/include/libxml/SAX.h", + "${LIBXML_PATH}/include/libxml/SAX2.h", + "${LIBXML_PATH}/include/libxml/c14n.h", + "${LIBXML_PATH}/include/libxml/catalog.h", + "${LIBXML_PATH}/include/libxml/chvalid.h", + "${LIBXML_PATH}/include/libxml/debugXML.h", + "${LIBXML_PATH}/include/libxml/dict.h", + "${LIBXML_PATH}/include/libxml/encoding.h", + "${LIBXML_PATH}/include/libxml/entities.h", + "${LIBXML_PATH}/include/libxml/globals.h", + "${LIBXML_PATH}/include/libxml/hash.h", + "${LIBXML_PATH}/include/libxml/list.h", + "${LIBXML_PATH}/include/libxml/nanoftp.h", + "${LIBXML_PATH}/include/libxml/nanohttp.h", + "${LIBXML_PATH}/include/libxml/parser.h", + "${LIBXML_PATH}/include/libxml/parserInternals.h", + "${LIBXML_PATH}/include/libxml/pattern.h", + "${LIBXML_PATH}/include/libxml/relaxng.h", + "${LIBXML_PATH}/include/libxml/schemasInternals.h", + "${LIBXML_PATH}/include/libxml/schematron.h", + "${LIBXML_PATH}/include/libxml/threads.h", + "${LIBXML_PATH}/include/libxml/tree.h", + "${LIBXML_PATH}/include/libxml/uri.h", + "${LIBXML_PATH}/include/libxml/valid.h", + "${LIBXML_PATH}/include/libxml/xinclude.h", + "${LIBXML_PATH}/include/libxml/xlink.h", + "${LIBXML_PATH}/include/libxml/xmlIO.h", + "${LIBXML_PATH}/include/libxml/xmlautomata.h", + "${LIBXML_PATH}/include/libxml/xmlerror.h", + "${LIBXML_PATH}/include/libxml/xmlexports.h", + "${LIBXML_PATH}/include/libxml/xmlmemory.h", + "${LIBXML_PATH}/include/libxml/xmlmodule.h", + "${LIBXML_PATH}/include/libxml/xmlreader.h", + "${LIBXML_PATH}/include/libxml/xmlregexp.h", + "${LIBXML_PATH}/include/libxml/xmlsave.h", + "${LIBXML_PATH}/include/libxml/xmlschemas.h", + "${LIBXML_PATH}/include/libxml/xmlschemastypes.h", + "${LIBXML_PATH}/include/libxml/xmlstring.h", + "${LIBXML_PATH}/include/libxml/xmlunicode.h", + "${LIBXML_PATH}/include/libxml/xmlwriter.h", + "${LIBXML_PATH}/include/libxml/xpath.h", + "${LIBXML_PATH}/include/libxml/xpathInternals.h", + "${LIBXML_PATH}/include/libxml/xpointer.h", + "${LIBXML_PATH}/legacy.c", + "${LIBXML_PATH}/list.c", + "${LIBXML_PATH}/nanoftp.c", + "${LIBXML_PATH}/nanohttp.c", + "${LIBXML_PATH}/parser.c", + "${LIBXML_PATH}/parserInternals.c", + "${LIBXML_PATH}/pattern.c", + "${LIBXML_PATH}/relaxng.c", + "${LIBXML_PATH}/schematron.c", + "${LIBXML_PATH}/threads.c", + "${LIBXML_PATH}/tree.c", + "${LIBXML_PATH}/uri.c", + "${LIBXML_PATH}/valid.c", + "${LIBXML_PATH}/xinclude.c", + "${LIBXML_PATH}/xlink.c", + "${LIBXML_PATH}/xmlIO.c", + "${LIBXML_PATH}/xmlmemory.c", + "${LIBXML_PATH}/xmlmodule.c", + "${LIBXML_PATH}/xmlreader.c", + "${LIBXML_PATH}/xmlregexp.c", + "${LIBXML_PATH}/xmlsave.c", + "${LIBXML_PATH}/xmlschemas.c", + "${LIBXML_PATH}/xmlschemastypes.c", + "${LIBXML_PATH}/xmlstring.c", + "${LIBXML_PATH}/xmlunicode.c", + "${LIBXML_PATH}/xmlwriter.c", + "${LIBXML_PATH}/xpath.c", + "${LIBXML_PATH}/xpointer.c", + "${LIBXML_PATH}/xzlib.c" + ] + + public_configs = [ ":restool_libxml2_config" ] + + subsystem_name = "developtools" + part_name = "global_restool" +} \ No newline at end of file diff --git a/third_party/libxml2/CMakeLists.txt b/build/libxml2/CMakeLists.txt similarity index 95% rename from third_party/libxml2/CMakeLists.txt rename to build/libxml2/CMakeLists.txt index fee8468..f54e26e 100644 --- a/third_party/libxml2/CMakeLists.txt +++ b/build/libxml2/CMakeLists.txt @@ -1,9 +1,22 @@ +cmake_minimum_required(VERSION 3.15) + +project(myxml2 LANGUAGES C) +#include(CheckCSourceCompiles) +#include(CheckIncludeFiles) +#include(CheckStructHasMember) +#include(CheckFunctionExists) +#include(CheckLibraryExists) +#include(CheckSymbolExists) + include(CheckCSourceCompiles) -include(CheckIncludeFiles) -include(CheckStructHasMember) include(CheckFunctionExists) +include(CheckIncludeFiles) +include(CheckIncludeFile) include(CheckLibraryExists) +include(CheckStructHasMember) include(CheckSymbolExists) +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) set(LIBXML2_WITH_AUTOMATA ON) @@ -77,7 +90,7 @@ if(NOT GETHOSTBYNAME_ARG_CAST_CONST) else() set(GETHOSTBYNAME_ARG_CAST "/**/") endif() -check_include_files(arpa/inet.h HAVE_ARPA_INET_H) +CHECK_INCLUDE_FILE(arpa/inet.h HAVE_ARPA_INET_H) check_include_files(arpa/nameser.h HAVE_ARPA_NAMESER_H) check_struct_has_member("struct sockaddr_storage" ss_family "sys/socket.h;sys/types.h" HAVE_SS_FAMILY) check_struct_has_member("struct sockaddr_storage" __ss_family "sys/socket.h;sys/types.h" HAVE_BROKEN_SS_FAMILY) @@ -337,6 +350,8 @@ set(libxml2_original_source ${libxml2_original}/xzlib.c ) +#set(CMAKE_THREAD_LIBS_INIT "-lpthread") +#message("pthread " ${CMAKE_THREAD_LIBS_INIT}) find_package(Threads REQUIRED) add_library(myxml2 STATIC ${libxml2_original_header} ${libxml2_original_other_header} ${libxml2_original_source}) target_link_libraries(myxml2 PRIVATE Threads::Threads) @@ -345,4 +360,7 @@ if(WIN32) target_link_libraries(myxml2 PRIVATE ws2_32) set(WIN32_EXTRA_LIBADD "-lws2_32") endif() -configure_file(${libxml2_original}/include/libxml/xmlversion.h.in ${libxml2_original}/include/libxml/xmlversion.h) \ No newline at end of file +configure_file(${libxml2_original}/include/libxml/xmlversion.h.in ${libxml2_original}/include/libxml/xmlversion.h) + +file(COPY ${libxml2_original_header} DESTINATION ./include/libxml) +file(COPY ${libxml2_original}/include/libxml/xmlversion.h DESTINATION ./include/libxml) \ No newline at end of file diff --git a/third_party/libxml2/config.h.cmake.in b/build/libxml2/config.h.cmake.in similarity index 100% rename from third_party/libxml2/config.h.cmake.in rename to build/libxml2/config.h.cmake.in diff --git a/build/libxml2/win32/include/config.h b/build/libxml2/win32/include/config.h new file mode 100644 index 0000000..5611fd8 --- /dev/null +++ b/build/libxml2/win32/include/config.h @@ -0,0 +1,288 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if __attribute__((destructor)) is accepted */ +#define ATTRIBUTE_DESTRUCTOR 1 + +/* Type cast for the gethostbyname() argument */ +#define GETHOSTBYNAME_ARG_CAST (char *) + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ARPA_INET_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ARPA_NAMESER_H */ + +/* Whether struct sockaddr::__ss_family exists */ +/* #undef HAVE_BROKEN_SS_FAMILY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Have dlopen based dso */ +/* #undef HAVE_DLOPEN */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FLOAT_H 1 + +/* Define to 1 if you have the `fprintf' function. */ +#define HAVE_FPRINTF 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define if getaddrinfo is there */ +/* #undef HAVE_GETADDRINFO */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isascii' function. */ +#define HAVE_ISASCII 1 + +/* Define if isinf is there */ +/* #undef HAVE_ISINF */ + +/* Define if isnan is there */ +#define HAVE_ISNAN 1 + +/* Define if history library is there (-lhistory) */ +/* #undef HAVE_LIBHISTORY */ + +/* Define if pthread library is there (-lpthread) */ +#define HAVE_LIBPTHREAD 1 + +/* Define if readline library is there (-lreadline) */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the `localtime' function. */ +#define HAVE_LOCALTIME 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMA_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MATH_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +/* #undef HAVE_MMAP */ + +/* Define to 1 if you have the `munmap' function. */ +/* #undef HAVE_MUNMAP */ + +/* mmap() is no good without munmap() */ +#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP) +# undef /**/ HAVE_MMAP +#endif + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETDB_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETINET_IN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_POLL_H */ + +/* Define to 1 if you have the `printf' function. */ +#define HAVE_PRINTF 1 + +/* Define if is there */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `rand' function. */ +#define HAVE_RAND 1 + +/* Define to 1 if you have the `rand_r' function. */ +/* #undef HAVE_RAND_R */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* Have shl_load based dso */ +/* #undef HAVE_SHLLOAD */ + +/* Define to 1 if you have the `signal' function. */ +#define HAVE_SIGNAL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the `sprintf' function. */ +#define HAVE_SPRINTF 1 + +/* Define to 1 if you have the `srand' function. */ +#define HAVE_SRAND 1 + +/* Define to 1 if you have the `sscanf' function. */ +#define HAVE_SSCANF 1 + +/* Define to 1 if you have the `stat' function. */ +#define HAVE_STAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MMAN_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMEB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `time' function. */ +#define HAVE_TIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Whether va_copy() is available */ +/* #undef HAVE_VA_COPY */ + +/* Define to 1 if you have the `vfprintf' function. */ +#define HAVE_VFPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `vsprintf' function. */ +#define HAVE_VSPRINTF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZLIB_H */ + +/* Whether __va_copy() is available */ +/* #undef HAVE___VA_COPY */ + +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST const + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Type cast for the send() function 2nd arg */ +#define SEND_ARG2_CAST (char *) + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Support for IPv6 */ +/* #undef SUPPORT_IP6 */ + +/* Define if va_list is an array type */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Version number of package */ +#define VERSION "2.9.10" + +/* Determine what socket length (socklen_t) data type is */ +#define XML_SOCKLEN_T int + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* ss_family is not defined here, use __ss_family instead */ +/* #undef ss_family */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ diff --git a/build/libxml2/win32/include/libxml/xmlversion.h b/build/libxml2/win32/include/libxml/xmlversion.h new file mode 100644 index 0000000..f7991db --- /dev/null +++ b/build/libxml2/win32/include/libxml/xmlversion.h @@ -0,0 +1,485 @@ +/* + * Summary: compile-time version informations + * Description: compile-time version informations for the XML library + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +XMLPUBFUN void XMLCALL xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "2.9.10" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 10203 + */ +#define LIBXML_VERSION 209010 + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "10203" + */ +#define LIBXML_VERSION_STRING "209010" + +/** + * LIBXML_VERSION_EXTRA: + * + * extra version information, used to show a CVS compilation + */ +#define LIBXML_VERSION_EXTRA "" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(209010); + +#ifndef VMS +#if 0 +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO +#else +/** + * WITHOUT_TRIO: + * + * defined if the trio support should not be configured in + */ +#define WITHOUT_TRIO +#endif +#else /* VMS */ +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO 1 +#endif /* VMS */ + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if 1 +#define LIBXML_THREAD_ENABLED +#endif + +/** + * LIBXML_THREAD_ALLOC_ENABLED: + * + * Whether the allocation hooks are per-thread + */ +#if 0 +#define LIBXML_THREAD_ALLOC_ENABLED +#endif + +/** + * LIBXML_TREE_ENABLED: + * + * Whether the DOM like tree manipulation API support is configured in + */ +#if 1 +#define LIBXML_TREE_ENABLED +#endif + +/** + * LIBXML_OUTPUT_ENABLED: + * + * Whether the serialization/saving support is configured in + */ +#if 1 +#define LIBXML_OUTPUT_ENABLED +#endif + +/** + * LIBXML_PUSH_ENABLED: + * + * Whether the push parsing interfaces are configured in + */ +#if 1 +#define LIBXML_PUSH_ENABLED +#endif + +/** + * LIBXML_READER_ENABLED: + * + * Whether the xmlReader parsing interface is configured in + */ +#if 1 +#define LIBXML_READER_ENABLED +#endif + +/** + * LIBXML_PATTERN_ENABLED: + * + * Whether the xmlPattern node selection interface is configured in + */ +#if 1 +#define LIBXML_PATTERN_ENABLED +#endif + +/** + * LIBXML_WRITER_ENABLED: + * + * Whether the xmlWriter saving interface is configured in + */ +#if 1 +#define LIBXML_WRITER_ENABLED +#endif + +/** + * LIBXML_SAX1_ENABLED: + * + * Whether the older SAX1 interface is configured in + */ +#if 1 +#define LIBXML_SAX1_ENABLED +#endif + +/** + * LIBXML_FTP_ENABLED: + * + * Whether the FTP support is configured in + */ +#if 1 +#define LIBXML_FTP_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if 1 +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_VALID_ENABLED: + * + * Whether the DTD validation support is configured in + */ +#if 1 +#define LIBXML_VALID_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if 1 +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_LEGACY_ENABLED: + * + * Whether the deprecated APIs are compiled in for compatibility + */ +#if 1 +#define LIBXML_LEGACY_ENABLED +#endif + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if 1 +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if 1 +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_DOCB_ENABLED: + * + * Whether the SGML Docbook support is configured in + */ +#if 1 +#define LIBXML_DOCB_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if 1 +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if 1 +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if 1 +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if 0 +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_ICU_ENABLED: + * + * Whether icu support is available + */ +#if 0 +#define LIBXML_ICU_ENABLED +#endif + +/** + * LIBXML_ISO8859X_ENABLED: + * + * Whether ISO-8859-* support is made available in case iconv is not + */ +#if 1 +#define LIBXML_ISO8859X_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if 1 +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * Whether the memory debugging is configured in + */ +#if 0 +#define DEBUG_MEMORY_LOCATION +#endif + +/** + * LIBXML_DEBUG_RUNTIME: + * + * Whether the runtime debugging is configured in + */ +#if 0 +#define LIBXML_DEBUG_RUNTIME +#endif + +/** + * LIBXML_UNICODE_ENABLED: + * + * Whether the Unicode related interfaces are compiled in + */ +#if 1 +#define LIBXML_UNICODE_ENABLED +#endif + +/** + * LIBXML_REGEXP_ENABLED: + * + * Whether the regular expressions interfaces are compiled in + */ +#if 1 +#define LIBXML_REGEXP_ENABLED +#endif + +/** + * LIBXML_AUTOMATA_ENABLED: + * + * Whether the automata interfaces are compiled in + */ +#if 1 +#define LIBXML_AUTOMATA_ENABLED +#endif + +/** + * LIBXML_EXPR_ENABLED: + * + * Whether the formal expressions interfaces are compiled in + * + * This code is unused and disabled unconditionally for now. + */ +#if 0 +#define LIBXML_EXPR_ENABLED +#endif + +/** + * LIBXML_SCHEMAS_ENABLED: + * + * Whether the Schemas validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMAS_ENABLED +#endif + +/** + * LIBXML_SCHEMATRON_ENABLED: + * + * Whether the Schematron validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMATRON_ENABLED +#endif + +/** + * LIBXML_MODULES_ENABLED: + * + * Whether the module interfaces are compiled in + */ +#if 1 +#define LIBXML_MODULES_ENABLED +/** + * LIBXML_MODULE_EXTENSION: + * + * the string suffix used by dynamic modules (usually shared libraries) + */ +#define LIBXML_MODULE_EXTENSION "" +#endif + +/** + * LIBXML_ZLIB_ENABLED: + * + * Whether the Zlib support is compiled in + */ +#if 0 +#define LIBXML_ZLIB_ENABLED +#endif + +/** + * LIBXML_LZMA_ENABLED: + * + * Whether the Lzma support is compiled in + */ +#if 0 +#define LIBXML_LZMA_ENABLED +#endif + +#ifdef __GNUC__ + +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ + +#ifndef ATTRIBUTE_UNUSED +# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) +# define ATTRIBUTE_UNUSED __attribute__((unused)) +# else +# define ATTRIBUTE_UNUSED +# endif +#endif + +/** + * LIBXML_ATTR_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ + +#ifndef LIBXML_ATTR_ALLOC_SIZE +# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) +# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) +# else +# define LIBXML_ATTR_ALLOC_SIZE(x) +# endif +#else +# define LIBXML_ATTR_ALLOC_SIZE(x) +#endif + +/** + * LIBXML_ATTR_FORMAT: + * + * Macro used to indicate to GCC the parameter are printf like + */ + +#ifndef LIBXML_ATTR_FORMAT +# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) +# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args))) +# else +# define LIBXML_ATTR_FORMAT(fmt,args) +# endif +#else +# define LIBXML_ATTR_FORMAT(fmt,args) +#endif + +#else /* ! __GNUC__ */ +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ +#define ATTRIBUTE_UNUSED +/** + * LIBXML_ATTR_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ +#define LIBXML_ATTR_ALLOC_SIZE(x) +/** + * LIBXML_ATTR_FORMAT: + * + * Macro used to indicate to GCC the parameter are printf like + */ +#define LIBXML_ATTR_FORMAT(fmt,args) +#endif /* __GNUC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif + + diff --git a/build/sqlite3/BUILD.gn b/build/sqlite3/BUILD.gn new file mode 100644 index 0000000..fdb8aca --- /dev/null +++ b/build/sqlite3/BUILD.gn @@ -0,0 +1,26 @@ +# 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("//build/ohos.gni") +ohos_static_library("restool_sqlite") { + sources = [ + "//third_party/sqlite/src/sqlite3.c" + ] + + include_dirs = [ + "//third_party/sqlite/include" + ] + + subsystem_name = "developtools" + part_name = "global_restool" +} \ No newline at end of file diff --git a/third_party/sqlite3/CMakeLists.txt b/build/sqlite3/CMakeLists.txt similarity index 100% rename from third_party/sqlite3/CMakeLists.txt rename to build/sqlite3/CMakeLists.txt diff --git a/bundle.json b/bundle.json new file mode 100644 index 0000000..44c574a --- /dev/null +++ b/bundle.json @@ -0,0 +1,34 @@ +{ + "name": "@ohos/restool", + "description": "OpenHarmony resource compile.", + "version": "3.1", + "license": "Apache License 2.0", + "pubiishAs": "code-segment", + "segment": { + "destPath": "developtools/global_resource_tool" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "restool", + "subsystem": "developtools", + "syscap": [], + "feature": [], + "adapted_system_type": ["mini", "small", "standard" ], + "deps": { + "components": [], + "third_party": [ + "bounds_checking_function", + "libxml2", + "jsoncpp", + "sqlite" + ] + }, + "build": { + "sub_component": [ "//developtools/global_resource_tool:restool" ], + "inner_kits": [], + "test": [] + } + } + } + \ No newline at end of file diff --git a/include/file_entry.h b/include/file_entry.h new file mode 100644 index 0000000..3d75161 --- /dev/null +++ b/include/file_entry.h @@ -0,0 +1,71 @@ +/* + * 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. + */ + +#ifndef OHOS_RESTOOL_FILE_ENTRY_H +#define OHOS_RESTOOL_FILE_ENTRY_H + +#include +#include +#include + +namespace OHOS { +namespace Global { +namespace Restool { +class FileEntry { +public: + class FilePath { + public: + FilePath(const std::string &path); + virtual ~FilePath(); + FilePath Append(const std::string &path); + FilePath ReplaceExtension(const std::string &extension); + FilePath GetParent(); + const std::string &GetPath() const; + const std::string &GetFilename() const; + const std::string &GetExtension() const; + const std::vector GetSegments() const; + private: + void Init(); + void Format(); + std::string filePath_; + std::string filename_; + std::string parent_; + std::string extension_; + }; + + FileEntry(const std::string &path); + virtual ~FileEntry(); + bool Init(); + const std::vector> GetChilds() const; + bool IsFile() const; + const FilePath &GetFilePath() const; + static bool Exist(const std::string &path); + static bool RemoveAllDir(const std::string &path); + static bool CreateDirs(const std::string &path); + static bool CopyFile(const std::string &src, const std::string &dst); + static bool IsDirectory(const std::string &path); + +private: + bool IsIgnore(const std::string &filename) const; + static bool RemoveAllDirInner(const FileEntry &entry); + static bool CreateDirsInner(const std::string &path, std::string::size_type offset); + FilePath filePath_; + bool isFile_; + static const std::string SEPARATE; +}; +} +} +} +#endif \ No newline at end of file diff --git a/include/resource_item.h b/include/resource_item.h index bf7a842..835199f 100644 --- a/include/resource_item.h +++ b/include/resource_item.h @@ -35,7 +35,7 @@ public: void SetLimitKey(const std::string &limitKey); const int8_t *GetData() const; - const uint32_t GetDataLength() const; + uint32_t GetDataLength() const; const std::string &GetName() const; const ResType &GetResType() const; const std::vector &GetKeyParam() const; diff --git a/include/resource_util.h b/include/resource_util.h index 73e775c..8a17b7f 100644 --- a/include/resource_util.h +++ b/include/resource_util.h @@ -16,7 +16,6 @@ #ifndef OHOS_RESTOOL_RESOURCE_UTIL_H #define OHOS_RESTOOL_RESOURCE_UTIL_H -#include #include #include "resource_data.h" #include "json/json.h" @@ -126,9 +125,10 @@ public: /** * @brief ignore file or directory * @param filename: file or directory name + * @param isFile: ture if is file, other false * @return true if ignore, other false */ - static bool IsIgnoreFile(const std::string &filename, std::filesystem::file_type type); + static bool IsIgnoreFile(const std::string &filename, bool isFile); /** * @brief need convert to solid xml diff --git a/src/cmd_parser.cpp b/src/cmd_parser.cpp index 9cc94d4..e39dd30 100644 --- a/src/cmd_parser.cpp +++ b/src/cmd_parser.cpp @@ -153,7 +153,6 @@ uint32_t PackageParser::ForceWrite() uint32_t PackageParser::PrintVersion() { cout << "Info: Restool version= " << RESTOOL_VERSION << endl; - cout << "time = (" << __DATE__ << " " << __TIME__ << ")" << endl; exit(RESTOOL_SUCCESS); return RESTOOL_SUCCESS; } diff --git a/src/file_entry.cpp b/src/file_entry.cpp new file mode 100644 index 0000000..f301c0b --- /dev/null +++ b/src/file_entry.cpp @@ -0,0 +1,271 @@ +/* + * 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. + */ + +#include "file_entry.h" +#include +#include +#include "dirent.h" +#include "sys/stat.h" +#include "unistd.h" + +namespace OHOS { +namespace Global { +namespace Restool { +#ifdef _WIN32 +const std::string FileEntry::SEPARATE = "\\"; +#else +const std::string FileEntry::SEPARATE = "/"; +#endif + +using namespace std; +FileEntry::FileEntry(const string &path) + : filePath_(path), isFile_(false) +{ +} + +FileEntry::~FileEntry() +{ +} + +bool FileEntry::Init() +{ + string filePath = filePath_.GetPath(); + if (!Exist(filePath)) { + cerr << "Error: '" << filePath << "' not exists." << endl; + return false; + } + + isFile_ = !IsDirectory(filePath); + return true; +} + +const vector> FileEntry::GetChilds() const +{ + vector> children; + struct dirent *entry; + string filePath = filePath_.GetPath(); + DIR *handle = opendir(filePath.c_str()); + while ((entry = readdir(handle)) != nullptr) { + string filename(entry->d_name); + if (IsIgnore(filename)) { + continue; + } + + filePath = filePath_.GetPath() + SEPARATE + filename; + unique_ptr f = make_unique(filePath); + cout << filePath << endl; + f->Init(); + children.push_back(move(f)); + } + closedir(handle); + return children; +} + +bool FileEntry::IsFile() const +{ + return isFile_; +} + +const FileEntry::FilePath &FileEntry::GetFilePath() const +{ + return filePath_; +} + +bool FileEntry::Exist(const string &path) +{ + struct stat s; + if (stat(path.c_str(), &s) != 0) { + return false; + } + return true; +} + +bool FileEntry::RemoveAllDir(const string &path) +{ + FileEntry f(path); + if (!f.Init()) { + return false; + } + + if (f.IsFile()) { + cerr << "Error: RemoveAllDir '" << path << "' not directory." << endl; + return false; + } + return RemoveAllDirInner(f); +} + +bool FileEntry::CreateDirs(const string &path) +{ + return CreateDirsInner(path, 0); +} + +bool FileEntry::CopyFile(const string &src, const string &dst) +{ + ifstream in(src, ios::binary); + ofstream out(dst, ios::binary); + if (!in || !out) { + cerr << "Error: CopyFile '" << src << "' or '" << dst << "' open fail." << endl; + return false; + } + out << in.rdbuf(); + return true; +} + +bool FileEntry::IsDirectory(const string &path) +{ + struct stat s; + stat(path.c_str(), &s); + return S_ISDIR(s.st_mode); +} + +FileEntry::FilePath::FilePath(const string &path) : filePath_(path) +{ + Format(); + Init(); +} + +FileEntry::FilePath::~FilePath() +{ +} + +FileEntry::FilePath FileEntry::FilePath::Append(const string &path) +{ + Format(); + string filePath = filePath_ + SEPARATE + path; + return FilePath(filePath); +} + +FileEntry::FilePath FileEntry::FilePath::ReplaceExtension(const string &extension) +{ + string filePath; + if (!parent_.empty()) { + filePath += parent_ + SEPARATE; + } + + filePath += filename_.substr(0, filename_.length() - extension_.length()) + extension; + return FilePath(filePath); +} + +FileEntry::FilePath FileEntry::FilePath::GetParent() +{ + return FilePath(parent_); +} + +const string &FileEntry::FilePath::GetPath() const +{ + return filePath_; +} + +const string &FileEntry::FilePath::GetFilename() const +{ + return filename_; +} + +const string &FileEntry::FilePath::GetExtension() const +{ + return extension_; +} + +const vector FileEntry::FilePath::GetSegments() const +{ + vector segments; + string::size_type offset = 0; + string::size_type pos = filePath_.find_first_of(SEPARATE.front(), offset); + while (pos != string::npos) { + segments.push_back(filePath_.substr(offset, pos - offset)); + offset = pos + 1; + pos = filePath_.find_first_of(SEPARATE.front(), offset); + } + + if (offset < filePath_.length()) { + segments.push_back(filePath_.substr(offset)); + } + return segments; +} + +// below private +bool FileEntry::IsIgnore(const string &filename) const +{ + if (filename == "." || filename == "..") { + return true; + } + return false; +} + +bool FileEntry::RemoveAllDirInner(const FileEntry &entry) +{ + if (entry.IsFile()) { + return remove(entry.GetFilePath().GetPath().c_str()) == 0; + } + + for (const auto &iter : entry.GetChilds()) { + if (!RemoveAllDirInner(*iter)) { + return false; + } + } + return rmdir(entry.GetFilePath().GetPath().c_str()) == 0; +} + +bool FileEntry::CreateDirsInner(const string &path, string::size_type offset) +{ + string::size_type pos = path.find_first_of(SEPARATE.front(), offset); + if (pos == string::npos) { +#if _WIN32 + return mkdir(path.c_str()); + #else + return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0; +#endif + } + + string subPath = path.substr(0, pos); + if (!Exist(subPath)) { +#if _WIN32 + if (mkdir(subPath.c_str()) != 0) { +#else + if (mkdir(subPath.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { +#endif + return false; + } + } + return CreateDirsInner(path, pos + 1); +} + +void FileEntry::FilePath::Format() +{ + if (filePath_.back() != SEPARATE.front()) { + return; + } + filePath_.pop_back(); +} + +void FileEntry::FilePath::Init() +{ + filename_ = filePath_; + string::size_type pos = filePath_.find_last_of(SEPARATE.front()); + if (pos != string::npos) { + parent_ = filePath_.substr(0, pos); + if (pos + 1 < filePath_.length()) { + filename_ = filePath_.substr(pos + 1); + } + } + + pos = filename_.find_last_of('.'); + if (pos != string::npos && pos + 1 < filename_.length()) { + extension_ = filename_.substr(pos); + } +} +} +} +} \ No newline at end of file diff --git a/src/file_manager.cpp b/src/file_manager.cpp index c8f0fbf..8ed66e1 100644 --- a/src/file_manager.cpp +++ b/src/file_manager.cpp @@ -15,9 +15,9 @@ #include "file_manager.h" #include -#include #include #include "factory_resource_compiler.h" +#include "file_entry.h" #include "key_parser.h" #include "reference_parser.h" #include "resource_directory.h" @@ -97,8 +97,8 @@ void FileManager::FilterRefSolidXml(const string &output, vector &output continue; } for (const auto &resourceDir : iter.second) { - string outputPath = filesystem::path(output).append(RESOURCES_DIR).append(resourceDir.limitKey) - .append(resourceDir.fileCluster).string(); + string outputPath = FileEntry::FilePath(output).Append(RESOURCES_DIR).Append(resourceDir.limitKey) + .Append(resourceDir.fileCluster).GetPath(); if (find(outputPaths.begin(), outputPaths.end(), outputPath) == outputPaths.end()) { outputPaths.push_back(outputPath); } diff --git a/src/generic_compiler.cpp b/src/generic_compiler.cpp index 96f1646..3dd5e26 100644 --- a/src/generic_compiler.cpp +++ b/src/generic_compiler.cpp @@ -14,8 +14,8 @@ */ #include "generic_compiler.h" -#include #include +#include "file_entry.h" #include "resource_util.h" #include "restool_errors.h" @@ -55,7 +55,7 @@ bool GenericCompiler::PostFile(const FileInfo &fileInfo) string data = fileInfo.filename; if (IsConvertToSolidXml(fileInfo)) { - data = filesystem::path(data).replace_extension(".sxml").string(); + data = FileEntry::FilePath(data).ReplaceExtension(".sxml").GetPath(); } data = moduleName_ + SEPARATOR + RESOURCES_DIR + SEPARATOR + \ fileInfo.limitKey + SEPARATOR + fileInfo.fileCluster + SEPARATOR + data; @@ -69,7 +69,7 @@ bool GenericCompiler::PostFile(const FileInfo &fileInfo) string GenericCompiler::GetOutputFilePath(const FileInfo &fileInfo) const { string outputFolder = GetOutputFolder(fileInfo); - string outputFilePath = filesystem::path(outputFolder).append(fileInfo.filename).string(); + string outputFilePath = FileEntry::FilePath(outputFolder).Append(fileInfo.filename).GetPath(); return outputFilePath; } diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp index 2956486..09b0edc 100644 --- a/src/i_resource_compiler.cpp +++ b/src/i_resource_compiler.cpp @@ -14,8 +14,9 @@ */ #include "i_resource_compiler.h" -#include +#include #include +#include "file_entry.h" #include "id_worker.h" #include "resource_util.h" #include "restool_errors.h" @@ -43,17 +44,21 @@ uint32_t IResourceCompiler::Compile(const vector &directoryInfos) map> setsByDirectory; for (const auto &directoryInfo : directoryInfos) { string outputFolder = GetOutputFolder(directoryInfo); - for (const auto &it : filesystem::directory_iterator(directoryInfo.dirPath)) { - if (ResourceUtil::IsIgnoreFile(it.path().filename().string(), it.status().type())) { + FileEntry f(directoryInfo.dirPath); + if (!f.Init()) { + return RESTOOL_ERROR; + } + for (const auto &it : f.GetChilds()) { + if (ResourceUtil::IsIgnoreFile(it->GetFilePath().GetFilename(), it->IsFile())) { continue; } - if (it.is_directory()) { - cout << "Error: '" << it.path().string() << "' not regular." << endl; + if (!it->IsFile()) { + cout << "Error: '" << it->GetFilePath().GetPath() << "' not regular." << endl; return RESTOOL_ERROR; } - FileInfo fileInfo = { directoryInfo, it.path().string(), it.path().filename().string() }; + FileInfo fileInfo = { directoryInfo, it->GetFilePath().GetPath(), it->GetFilePath().GetFilename() }; fileInfos.push_back(fileInfo); setsByDirectory[outputFolder].push_back(fileInfo); } @@ -63,6 +68,7 @@ uint32_t IResourceCompiler::Compile(const vector &directoryInfos) return a.filePath < b.filePath; }); for (const auto &fileInfo : fileInfos) { + cout << "compile " << fileInfo.filePath << endl; if (CompileSingleFile(fileInfo) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } @@ -93,8 +99,8 @@ uint32_t IResourceCompiler::Compile(const FileInfo &fileInfo) } map> setsByDirectory; if (NeedIfConvertToSolidXml()) { - string outputFolder = filesystem::path(output_).append(RESOURCES_DIR) - .append(fileInfo.limitKey).append(fileInfo.fileCluster).string(); + string outputFolder = FileEntry::FilePath(output_).Append(RESOURCES_DIR) + .Append(fileInfo.limitKey).Append(fileInfo.fileCluster).GetPath(); setsByDirectory[outputFolder].push_back(fileInfo); } @@ -201,7 +207,7 @@ void IResourceCompiler::ListXmlFile(const vector &fileInfos, vector #include #include #include "cmd_parser.h" +#include "file_entry.h" namespace OHOS { namespace Global { @@ -173,8 +173,8 @@ uint32_t IdWorker::InitIdDefined() string idDefinedPath; if (type_ == ResourceIdCluster::RES_ID_SYS) { for (const auto &inputPath : packageParser.GetInputs()) { - idDefinedPath = filesystem::path(inputPath).append(RESOURCES_DIR) - .append("base").append("element").append(ID_DEFINED_FILE).string(); + idDefinedPath = FileEntry::FilePath(inputPath).Append(RESOURCES_DIR) + .Append("base").Append("element").Append(ID_DEFINED_FILE).GetPath(); if (InitIdDefined(idDefinedPath) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } @@ -182,7 +182,7 @@ uint32_t IdWorker::InitIdDefined() return RESTOOL_SUCCESS; } - idDefinedPath = filesystem::path(packageParser.GetRestoolPath()).parent_path().append(ID_DEFINED_FILE).string(); + idDefinedPath = FileEntry::FilePath(packageParser.GetRestoolPath()).GetParent().Append(ID_DEFINED_FILE).GetPath(); if (InitIdDefined(idDefinedPath) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } diff --git a/src/increment_list.cpp b/src/increment_list.cpp index 1f9c659..9c4dd4f 100644 --- a/src/increment_list.cpp +++ b/src/increment_list.cpp @@ -15,8 +15,8 @@ #include "increment_list.h" #include -#include #include +#include "file_entry.h" #include "key_parser.h" namespace OHOS { @@ -52,14 +52,14 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con return false; } info.rootPath = folder_[priority]; - string rootPath = filesystem::path(info.rootPath).append("").string(); + string rootPath = FileEntry::FilePath(info.rootPath).Append("").GetPath(); info.relativePath = filePath.substr(rootPath.length()); vector segments; if (!ParseSegment(info.relativePath, segments)) { return false; } - info.dirPath = filesystem::path(filePath).parent_path().string(); + info.dirPath = FileEntry::FilePath(filePath).GetParent().GetPath(); info.filePath = filePath; info.limitKey = segments[SEG_LIMIT_KEY]; if (info.limitKey == RAW_FILE_DIR) { @@ -84,7 +84,7 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con int32_t IncrementList::GetPriority(const string &filePath) const { auto result = find_if(folder_.begin(), folder_.end(), [&filePath](auto &iter) { - string rootPath = filesystem::path(iter).append("").string(); + string rootPath = FileEntry::FilePath(iter).Append("").GetPath(); if (filePath.length() <= rootPath.length()) { return false; } @@ -101,8 +101,8 @@ int32_t IncrementList::GetPriority(const string &filePath) const bool IncrementList::ParseSegment(const string &filePath, vector &segments) const { - for (const auto &it : filesystem::path(filePath)) { - segments.push_back(it.string()); + for (const auto &it : FileEntry::FilePath(filePath).GetSegments()) { + segments.push_back(it); } if (segments.size() >= (SEG_RESOURCE + 1) && segments[SEG_RESOURCE] != RESOURCES_DIR) { diff --git a/src/increment_manager.cpp b/src/increment_manager.cpp index 625f7d5..c834a25 100644 --- a/src/increment_manager.cpp +++ b/src/increment_manager.cpp @@ -16,14 +16,14 @@ #include "increment_manager.h" #include #include +#include "file_entry.h" #include "id_worker.h" #include "key_parser.h" +#include "module_combine.h" +#include "resource_module_inc.h" #include "restool_errors.h" #include "xml_key_node.h" -#include "resource_module_inc.h" -#include "module_combine.h" - namespace OHOS { namespace Global { namespace Restool { @@ -65,7 +65,7 @@ uint32_t IncrementManager::Init(const string &cachePath, const vector &d for (auto &iter : moduleInfos) { string pathHash = ResourceUtil::GenerateHash(iter.rootPath); - string moduleCachePath = filesystem::path(cachePath_).append(pathHash).string(); + string moduleCachePath = FileEntry::FilePath(cachePath_).Append(pathHash).GetPath(); ResourceModuleInc resourceModuleInc(iter.rootPath, moduleCachePath, moduleName_, folder_); if (FirstIncrement()) { if (resourceModuleInc.ResourceModule::ScanResource() != RESTOOL_SUCCESS) { @@ -125,7 +125,7 @@ bool IncrementManager::ScanModules(const vector &d bool IncrementManager::InitList(vector &dels) const { - string listPath = filesystem::path(cachePath_).append(IncrementList::RESTOOL_LIST_FILE).string(); + string listPath = FileEntry::FilePath(cachePath_).Append(IncrementList::RESTOOL_LIST_FILE).GetPath(); if (!ResourceUtil::FileExist(listPath)) { return true; } @@ -158,7 +158,7 @@ bool IncrementManager::SaveIdJson() const root[to_string(iter.first)] = node; } - string idJsonPath = filesystem::path(cachePath_).append(ID_JSON_FILE).string(); + string idJsonPath = FileEntry::FilePath(cachePath_).Append(ID_JSON_FILE).GetPath(); if (!ResourceUtil::SaveToJsonFile(idJsonPath, root)) { return false; } @@ -168,7 +168,7 @@ bool IncrementManager::SaveIdJson() const bool IncrementManager::LoadIdJson() { Json::Value root; - string idJsonPath = filesystem::path(cachePath_).append(ID_JSON_FILE).string(); + string idJsonPath = FileEntry::FilePath(cachePath_).Append(ID_JSON_FILE).GetPath(); if (!ResourceUtil::OpenJsonFile(idJsonPath, root)) { return false; } @@ -229,15 +229,15 @@ void IncrementManager::DeleteRawFile(vector &dels) it++; continue; } - string rawFilePath = filesystem::path(outputPath_).append(it->relativePath).string(); - filesystem::remove(rawFilePath); + string rawFilePath = FileEntry::FilePath(outputPath_).Append(it->relativePath).GetPath(); + remove(rawFilePath.c_str()); it = dels.erase(it); } } bool IncrementManager::ClearSolidXml() const { - string resourceDir = filesystem::path(outputPath_).append(RESOURCES_DIR).string(); + string resourceDir = FileEntry::FilePath(outputPath_).Append(RESOURCES_DIR).GetPath(); if (!ResourceUtil::FileExist(resourceDir)) { return true; } @@ -248,19 +248,24 @@ bool IncrementManager::ClearSolidXml() const return true; } - for (const auto &entry : filesystem::directory_iterator(info.dirPath)) { - if (entry.is_directory()) { - cerr << "Error: '" << entry.path().string() << "' is directroy." << endl; + FileEntry f(info.dirPath); + if (!f.Init()) { + return false; + } + + for (const auto &entry : f.GetChilds()) { + if (!entry->IsFile()) { + cerr << "Error: '" << entry->GetFilePath().GetPath() << "' is directroy." << endl; return false; } - string extension = entry.path().extension().string(); + string extension = entry->GetFilePath().GetExtension(); if (extension != ".sxml" && extension != ".key" && extension != ".json") { continue; } - if (!filesystem::remove(entry.path().string())) { - cerr << "Error: remove '" << entry.path().string() << "' fail." << endl; + if (remove(entry->GetFilePath().GetPath().c_str()) != 0) { + cerr << "Error: remove '" << entry->GetFilePath().GetPath() << "' fail." << endl; return false; } } @@ -270,39 +275,6 @@ bool IncrementManager::ClearSolidXml() const } return true; } -/* -{ - "0x01000000": - { - "name":"xxxxx", - "type":"string" - } -} -{ - "header":{ - "folder":["xxxx", "xxxx", "xxxx", "xxxx"] - }, - "index":{ - "0x01000000":{ - "filepath":{ - "data":"xxxx", - "name":"xxxx", - "type":"xxxx", - "limitkey":"xxxx" - } - }, - } -} - -{ - "del":[ - "xx/xx/xx/xxx" - ], - "fix":[ - "xxx/xxx/xx" - ] -} -*/ } } } \ No newline at end of file diff --git a/src/module_combine.cpp b/src/module_combine.cpp index 5cfaa9b..81ae75a 100644 --- a/src/module_combine.cpp +++ b/src/module_combine.cpp @@ -15,8 +15,8 @@ #include "module_combine.h" #include -#include #include +#include "file_entry.h" #include "key_manager.h" #include "resource_util.h" #include "solid_xml.h" @@ -32,7 +32,7 @@ ModuleCombine::ModuleCombine(const string &modulePath, const string &outputPath) bool ModuleCombine::Combine() { - string resourceDir = filesystem::path(modulePath_).append(RESOURCES_DIR).string(); + string resourceDir = FileEntry::FilePath(modulePath_).Append(RESOURCES_DIR).GetPath(); ResourceDirectory resourceDirectory; if (!resourceDirectory.ScanResources(resourceDir, [this](const DirectoryInfo &info) -> bool { return CombineDirectory(info); @@ -45,27 +45,31 @@ bool ModuleCombine::Combine() // below private bool ModuleCombine::CombineDirectory(const DirectoryInfo &directoryInfo) { - string outputFolder = filesystem::path(outputPath_).append(RESOURCES_DIR) - .append(directoryInfo.limitKey).append(directoryInfo.fileCluster).string(); + string outputFolder = FileEntry::FilePath(outputPath_).Append(RESOURCES_DIR) + .Append(directoryInfo.limitKey).Append(directoryInfo.fileCluster).GetPath(); if (!ResourceUtil::CreateDirs(outputFolder)) { return false; } map sxmlPaths; - for (const auto &entry : filesystem::directory_iterator(directoryInfo.dirPath)) { - string src = entry.path().string(); - if (entry.is_directory()) { + FileEntry f(directoryInfo.dirPath); + if (!f.Init()) { + return false; + } + for (const auto &entry : f.GetChilds()) { + string src = entry->GetFilePath().GetPath(); + if (!entry->IsFile()) { cerr << "Error: " << src << " is directory." << endl; return false; } - string filename = entry.path().filename().string(); - string dst = filesystem::path(outputFolder).append(filename).string(); + string filename = entry->GetFilePath().GetFilename(); + string dst = FileEntry::FilePath(outputFolder).Append(filename).GetPath(); if (ResourceUtil::FileExist(dst)) { continue; } - if (entry.path().extension().string() == ".sxml") { + if (entry->GetFilePath().GetExtension() == ".sxml") { sxmlPaths.emplace(src, dst); continue; } diff --git a/src/preview_manager.cpp b/src/preview_manager.cpp index 099265e..5814855 100644 --- a/src/preview_manager.cpp +++ b/src/preview_manager.cpp @@ -14,9 +14,9 @@ */ #include "preview_manager.h" -#include #include #include "factory_resource_compiler.h" +#include "file_entry.h" #include "key_parser.h" #include "resource_module.h" #include "resource_util.h" @@ -36,7 +36,7 @@ uint32_t PreviewManager::ScanModules(const vector &modulePaths, const st { SqliteDatabase &database = SqliteDatabase::GetInstance(); - string dbPath = filesystem::path(output).append("resources.db").string(); + string dbPath = FileEntry::FilePath(output).Append("resources.db").GetPath(); database.Init(dbPath); if(!database.OpenDatabase()) { return RESTOOL_ERROR; @@ -48,7 +48,7 @@ uint32_t PreviewManager::ScanModules(const vector &modulePaths, const st } for (const auto &iter : modulePaths) { - if (filesystem::is_directory(iter)) { + if (FileEntry::IsDirectory(iter)) { ResourceModule resourceMoudle(iter, output, ""); resourceMoudle.SetPreviewMode(true); database.SetPriority(priority); @@ -74,10 +74,10 @@ bool PreviewManager::ScanFile(const string &filePath, int32_t priority) } FileInfo fileInfo; fileInfo.filePath = filePath; - fileInfo.filename = filesystem::path(filePath).filename().string(); - fileInfo.dirPath = filesystem::path(filePath).parent_path().string(); - fileInfo.fileCluster = filesystem::path(fileInfo.dirPath).filename().string(); - fileInfo.limitKey = filesystem::path(fileInfo.dirPath).parent_path().filename().string(); + fileInfo.filename = FileEntry::FilePath(filePath).GetFilename(); + fileInfo.dirPath = FileEntry::FilePath(filePath).GetParent().GetPath(); + fileInfo.fileCluster = FileEntry::FilePath(fileInfo.dirPath).GetFilename(); + fileInfo.limitKey = FileEntry::FilePath(fileInfo.dirPath).GetParent().GetFilename(); fileInfo.dirType = ResourceUtil::GetResTypeByDir(fileInfo.fileCluster); if (fileInfo.dirType == ResType::INVALID_RES_TYPE) { diff --git a/src/reference_parser.cpp b/src/reference_parser.cpp index 3c00532..abc55b3 100644 --- a/src/reference_parser.cpp +++ b/src/reference_parser.cpp @@ -16,6 +16,7 @@ #include "reference_parser.h" #include #include +#include "file_entry.h" #include "restool_errors.h" #include "xml_key_node.h" @@ -66,8 +67,8 @@ ReferenceParser::~ReferenceParser() uint32_t ReferenceParser::ParseRefInSolidXml(const vector &solidXmlFolders) const { for (const auto &solidXmlFolder : solidXmlFolders) { - string filePath = filesystem::path(solidXmlFolder) - .append(XmlKeyNode::KEY_TO_FILE_NAME.at(XmlKeyNode::KeyType::CONSTANT)).string(); + string filePath = FileEntry::FilePath(solidXmlFolder) + .Append(XmlKeyNode::KEY_TO_FILE_NAME.at(XmlKeyNode::KeyType::CONSTANT)).GetPath(); if (!ResourceUtil::FileExist(filePath)) { continue; } @@ -111,22 +112,23 @@ uint32_t ReferenceParser::ParseRefInString(string &value, bool &update) const uint32_t ReferenceParser::ParseRefInProfile(const string &output) const { - string profileFolder = filesystem::path(output).append(RESOURCES_DIR).append("base").append("profile").string(); + string profileFolder = FileEntry::FilePath(output).Append(RESOURCES_DIR).Append("base").Append("profile").GetPath(); if (!ResourceUtil::FileExist(profileFolder)) { return RESTOOL_SUCCESS; } - for (const auto &entry : filesystem::directory_iterator(profileFolder)) { - if (entry.is_directory()) { - cerr << "Error: '" << entry.path().string() << "' is directory." << endl; + FileEntry f(profileFolder); + for (const auto &entry : f.GetChilds()) { + if (!entry->IsFile()) { + cerr << "Error: '" << entry->GetFilePath().GetPath() << "' is directory." << endl; return false; } - if (entry.path().extension() != ".json" ) { + if (entry->GetFilePath().GetExtension() != ".json" ) { continue; } - if (ParseRefInJson(entry.path().string()) != RESTOOL_SUCCESS) { + if (ParseRefInJson(entry->GetFilePath().GetPath()) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } } diff --git a/src/resource_directory.cpp b/src/resource_directory.cpp index a92b3f9..c9a37ab 100644 --- a/src/resource_directory.cpp +++ b/src/resource_directory.cpp @@ -15,6 +15,7 @@ #include "resource_directory.h" #include +#include "file_entry.h" #include "resource_util.h" namespace OHOS { @@ -23,14 +24,19 @@ namespace Restool { using namespace std; bool ResourceDirectory::ScanResources(const string &resourcesDir, function callback) const { - for (auto &it : filesystem::directory_iterator(resourcesDir)) { - string limitKey = it.path().filename().string(); - if (ResourceUtil::IsIgnoreFile(limitKey, it.status().type())) { + FileEntry f(resourcesDir); + if (!f.Init()) { + return false; + } + + for (const auto &it : f.GetChilds()) { + string limitKey = it->GetFilePath().GetFilename(); + if (ResourceUtil::IsIgnoreFile(limitKey, it->IsFile())) { continue; } - if (!it.is_directory()) { - cerr << "Error: '" << it.path().string() << "' not directory." << endl; + if (it->IsFile()) { + cerr << "Error: '" << it->GetFilePath().GetPath() << "' not directory." << endl; return false; } @@ -38,7 +44,7 @@ bool ResourceDirectory::ScanResources(const string &resourcesDir, functionGetFilePath().GetPath(), limitKey, callback)) { return false; } } @@ -55,14 +61,18 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c return false; } - for (auto &it : filesystem::directory_iterator(resourceTypeDir)) { - string dirPath = it.path().string(); - string fileCluster = it.path().filename().string(); - if (ResourceUtil::IsIgnoreFile(fileCluster, it.status().type())) { + FileEntry f(resourceTypeDir); + if (!f.Init()) { + return false; + } + for (const auto &it : f.GetChilds()) { + string dirPath = it->GetFilePath().GetPath(); + string fileCluster = it->GetFilePath().GetFilename(); + if (ResourceUtil::IsIgnoreFile(fileCluster, it->IsFile())) { continue; } - if (!it.is_directory()) { + if (it->IsFile()) { cerr << "Error: '" << dirPath << "' not directory." << endl; return false; } diff --git a/src/resource_item.cpp b/src/resource_item.cpp index c84a5f9..6db4b36 100644 --- a/src/resource_item.cpp +++ b/src/resource_item.cpp @@ -79,7 +79,7 @@ const int8_t *ResourceItem::GetData() const return data_; } -const uint32_t ResourceItem::GetDataLength() const +uint32_t ResourceItem::GetDataLength() const { return dataLen_; } diff --git a/src/resource_merge.cpp b/src/resource_merge.cpp index ac62b09..80a12c9 100644 --- a/src/resource_merge.cpp +++ b/src/resource_merge.cpp @@ -15,6 +15,7 @@ #include "resource_merge.h" #include "cmd_parser.h" +#include "file_entry.h" namespace OHOS { namespace Global { @@ -46,8 +47,8 @@ uint32_t ResourceMerge::Init() map> inputTypes; for (auto it = inputs.crbegin(); it != inputs.crend(); it++) { - string filePath = filesystem::path(*it).append(ConfigParser::GetConfigName()).string(); - string resourceDir = filesystem::path(*it).append(RESOURCES_DIR).string(); + string filePath = FileEntry::FilePath(*it).Append(ConfigParser::GetConfigName()).GetPath(); + string resourceDir = FileEntry::FilePath(*it).Append(RESOURCES_DIR).GetPath(); ConfigParser::ModuleType moduleType = ConfigParser::ModuleType::NONE; if (!ResourceUtil::FileExist(filePath)) { inputTypes[moduleType].push_back(resourceDir); diff --git a/src/resource_module.cpp b/src/resource_module.cpp index f21322c..d018321 100644 --- a/src/resource_module.cpp +++ b/src/resource_module.cpp @@ -14,7 +14,7 @@ */ #include "resource_module.h" -#include +#include #include #include "factory_resource_compiler.h" #include "restool_errors.h" diff --git a/src/resource_module_inc.cpp b/src/resource_module_inc.cpp index c1b5038..bd24514 100644 --- a/src/resource_module_inc.cpp +++ b/src/resource_module_inc.cpp @@ -14,9 +14,9 @@ */ #include "resource_module_inc.h" -#include #include #include "factory_resource_compiler.h" +#include "file_entry.h" #include "increment_index.h" #include "restool_errors.h" @@ -38,19 +38,19 @@ uint32_t ResourceModuleInc::ScanResource(const vector -#include +#include +#include "file_entry.h" #include "file_manager.h" #include "header.h" #include "increment_manager.h" @@ -141,14 +142,14 @@ void ResourcePack::InitHeaderCreater() uint32_t ResourcePack::InitOutput() const { string cachePath = packageParser_.GetCachePath(); - string indexPath = filesystem::path(cachePath).append(IncrementManager::ID_JSON_FILE).string(); + string indexPath = FileEntry::FilePath(cachePath).Append(IncrementManager::ID_JSON_FILE).GetPath(); if (!cachePath.empty() && ResourceUtil::FileExist(indexPath)) { return RESTOOL_SUCCESS; } bool forceWrite = packageParser_.GetForceWrite(); string output = packageParser_.GetOutput(); - string resourcesPath = filesystem::path(output).append(RESOURCES_DIR).string(); + string resourcesPath = FileEntry::FilePath(output).Append(RESOURCES_DIR).GetPath(); if (ResourceUtil::FileExist(resourcesPath)) { if (!forceWrite) { cerr << "Error: output path '" << resourcesPath << "' exists." << endl; @@ -165,10 +166,10 @@ uint32_t ResourcePack::InitOutput() const uint32_t ResourcePack::GenerateHeader() const { auto headerPaths = packageParser_.GetResourceHeaders(); - string textPath = filesystem::path(packageParser_.GetOutput()).append("ResourceTable.txt").string(); + string textPath = FileEntry::FilePath(packageParser_.GetOutput()).Append("ResourceTable.txt").GetPath(); headerPaths.push_back(textPath); for (const auto &headerPath : headerPaths) { - string extension = filesystem::path(headerPath).extension().string(); + string extension = FileEntry::FilePath(headerPath).GetExtension(); auto it = headerCreaters_.find(extension); if (it == headerCreaters_.end()) { cout << "Warning: don't support header file format '" << headerPath << "'" << endl; @@ -189,13 +190,13 @@ uint32_t ResourcePack::InitConfigJson() cerr << "Error: more input path, -j config.json empty" << endl; return RESTOOL_ERROR; } - config = filesystem::path(packageParser_.GetInputs()[0]).append(CONFIG_JSON).string(); + config = FileEntry::FilePath(packageParser_.GetInputs()[0]).Append(CONFIG_JSON).GetPath(); if (!ResourceUtil::FileExist(config)) { - config = filesystem::path(packageParser_.GetInputs()[0]).append(MODULE_JSON).string(); + config = FileEntry::FilePath(packageParser_.GetInputs()[0]).Append(MODULE_JSON).GetPath(); } } - if (filesystem::path(config).filename().string() == MODULE_JSON) { + if (FileEntry::FilePath(config).GetFilename() == MODULE_JSON) { ConfigParser::SetUseModule(); } configJson_ = ConfigParser(config); @@ -274,17 +275,18 @@ uint32_t ResourcePack::GenerateJsHeader(const std::string &headerPath) const uint32_t ResourcePack::CopyRawFile(const vector &inputs) const { for (const auto &input : inputs) { - string rawfilePath = filesystem::path(input).append(RAW_FILE_DIR).string(); + string rawfilePath = FileEntry::FilePath(input).Append(RAW_FILE_DIR).GetPath(); if (!ResourceUtil::FileExist(rawfilePath)) { continue; } - if (!filesystem::is_directory(rawfilePath)) { + if (!FileEntry::IsDirectory(rawfilePath)) { cerr << "Error: '" << rawfilePath << "' not directory." << endl; return RESTOOL_ERROR; } - string dst = filesystem::path(packageParser_.GetOutput()).append(RESOURCES_DIR).append(RAW_FILE_DIR).string(); + string dst = FileEntry::FilePath(packageParser_.GetOutput()) + .Append(RESOURCES_DIR).Append(RAW_FILE_DIR).GetPath(); if (CopyRawFileImpl(rawfilePath, dst) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } @@ -297,22 +299,27 @@ uint32_t ResourcePack::CopyRawFileImpl(const string &src, const string &dst) con if (!ResourceUtil::CreateDirs(dst)) { return RESTOOL_ERROR; } - for (const auto &entry : filesystem::directory_iterator(src)) { - string filename = entry.path().filename().string(); - if (ResourceUtil::IsIgnoreFile(filename, entry.status().type())) { + + FileEntry f(src); + if (!f.Init()) { + return RESTOOL_ERROR; + } + for (const auto &entry : f.GetChilds()) { + string filename = entry->GetFilePath().GetFilename(); + if (ResourceUtil::IsIgnoreFile(filename, entry->IsFile())) { continue; } - string subPath = filesystem::path(dst).append(filename).string(); - if (entry.is_directory()) { - if (CopyRawFileImpl(entry.path().string(), subPath) != RESTOOL_SUCCESS) { + string subPath = FileEntry::FilePath(dst).Append(filename).GetPath(); + if (!entry->IsFile()) { + if (CopyRawFileImpl(entry->GetFilePath().GetPath(), subPath) != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } } else { if (ResourceUtil::FileExist(subPath)) { continue; } - if (!ResourceUtil::CopyFleInner(entry.path().string(), subPath)) { + if (!ResourceUtil::CopyFleInner(entry->GetFilePath().GetPath(), subPath)) { return RESTOOL_ERROR; } } @@ -325,7 +332,8 @@ uint32_t ResourcePack::GenerateConfigJson() if (configJson_.ParseRefence() != RESTOOL_SUCCESS) { return RESTOOL_ERROR; } - string outputPath = filesystem::path(packageParser_.GetOutput()).append(ConfigParser::GetConfigName()).string(); + string outputPath = FileEntry::FilePath(packageParser_.GetOutput()) + .Append(ConfigParser::GetConfigName()).GetPath(); return configJson_.Save(outputPath); } diff --git a/src/resource_table.cpp b/src/resource_table.cpp index 813ee8c..4a2fcbc 100644 --- a/src/resource_table.cpp +++ b/src/resource_table.cpp @@ -14,8 +14,8 @@ */ #include "resource_table.h" -#include #include "cmd_parser.h" +#include "file_entry.h" #include "file_manager.h" #include "resource_util.h" #include "securec.h" @@ -28,7 +28,7 @@ ResourceTable::ResourceTable() { auto &parser =CmdParser::GetInstance(); auto &packageParser = parser.GetCmdParser(); - indexFilePath_ = filesystem::path(packageParser.GetOutput()).append(RESOURCE_INDEX_FILE).string(); + indexFilePath_ = FileEntry::FilePath(packageParser.GetOutput()).Append(RESOURCE_INDEX_FILE).GetPath(); } ResourceTable::~ResourceTable() diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 81f3cb4..51a699c 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "file_entry.h" #ifdef __WIN32 #include "windows.h" #endif @@ -62,18 +63,12 @@ void ResourceUtil::Split(const string &str, vector &out, const string &s bool ResourceUtil::FileExist(const string &path) { - return filesystem::exists(path); + return FileEntry::Exist(path); } bool ResourceUtil::RmoveAllDir(const string &path) { - error_code err; - filesystem::remove_all(path, err); - if (err) { - cerr << "Error: remove all " << path << " failed, msg :=" << err.message() << endl; - return false; - } - return true; + return FileEntry::RemoveAllDir(path); } bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root) @@ -225,12 +220,8 @@ bool ResourceUtil::CopyFleInner(const string &src, const string &dst) return false; } #else - error_code err; - filesystem::path from(src); - filesystem::path to(dst); - if (!filesystem::copy_file(from, to, filesystem::copy_options::overwrite_existing, err)) { + if (!FileEntry::CopyFile(src, dst)) { cerr << "Error: copy file fail from '" << src << "' to '" << dst << "'" << endl; - cerr << err.message() << endl; return false; } #endif @@ -242,22 +233,20 @@ bool ResourceUtil::CreateDirs(const string &filePath) if (FileExist(filePath)) { return true; } - - error_code err; - if (!filesystem::create_directories(filePath, err)) { - cerr << "Error: create directory fail '" << filePath << "'" << endl; - return false; + + if (!FileEntry::CreateDirs(filePath)) { + cerr << "Error: create dir fail '" << filePath << "'" << endl; } return true; } -bool ResourceUtil::IsIgnoreFile(const string &filename, filesystem::file_type type) +bool ResourceUtil::IsIgnoreFile(const string &filename, bool isFile) { string key = filename; transform(key.begin(), key.end(), key.begin(), ::tolower); for (const auto &iter : IGNORE_FILE_REGEX) { - if ((iter.second == IgnoreType::IGNORE_FILE && type != filesystem::file_type::regular) || - (iter.second == IgnoreType::IGNORE_DIR && type != filesystem::file_type::directory)) { + if ((iter.second == IgnoreType::IGNORE_FILE && !isFile) || + (iter.second == IgnoreType::IGNORE_DIR && isFile)) { continue; } if (regex_match(key, regex(iter.first))) { diff --git a/src/solid_xml_compiler.cpp b/src/solid_xml_compiler.cpp index fd2c2d8..fa4d893 100644 --- a/src/solid_xml_compiler.cpp +++ b/src/solid_xml_compiler.cpp @@ -14,7 +14,6 @@ */ #include "solid_xml_compiler.h" -#include #include #include #include "resource_util.h" diff --git a/src/xml/key_manager.cpp b/src/xml/key_manager.cpp index c3c6c5c..8536357 100644 --- a/src/xml/key_manager.cpp +++ b/src/xml/key_manager.cpp @@ -14,7 +14,7 @@ */ #include "key_manager.h" -#include +#include "file_entry.h" #include "resource_util.h" namespace OHOS { @@ -32,7 +32,7 @@ KeyManager::KeyManager() bool KeyManager::LoadKey(const string &keysPath) { for (auto &key : keys_) { - string keyPath = filesystem::path(keysPath).append(XmlKeyNode::KEY_TO_FILE_NAME.at(key.first)).string(); + string keyPath = FileEntry::FilePath(keysPath).Append(XmlKeyNode::KEY_TO_FILE_NAME.at(key.first)).GetPath(); if (!ResourceUtil::FileExist(keyPath)) { continue; } @@ -46,7 +46,7 @@ bool KeyManager::LoadKey(const string &keysPath) bool KeyManager::SaveKey(const string &keysPath) { for (const auto &iter : keys_) { - string keyPath = filesystem::path(keysPath).append(XmlKeyNode::KEY_TO_FILE_NAME.at(iter.first)).string(); + string keyPath = FileEntry::FilePath(keysPath).Append(XmlKeyNode::KEY_TO_FILE_NAME.at(iter.first)).GetPath(); if (!iter.second->SaveToFile(keyPath)) { return false; } diff --git a/src/xml/xml_converter.cpp b/src/xml/xml_converter.cpp index 0bd983f..826a4a1 100644 --- a/src/xml/xml_converter.cpp +++ b/src/xml/xml_converter.cpp @@ -14,7 +14,7 @@ */ #include "xml_converter.h" -#include +#include "file_entry.h" #include "resource_util.h" #include "solid_xml.h" @@ -38,8 +38,8 @@ bool XmlConverter::GenerateSolidXml() } for (const auto &xmlPath : xmlPaths_) { SolidXml solidXml(xmlPath, keyManager.GetKeys()); - string filename = filesystem::path(xmlPath).filename().string(); - string filePath = filesystem::path(outputPath_).append(filename).replace_extension(".sxml").string(); + string filename = FileEntry::FilePath(xmlPath).GetFilename(); + string filePath = FileEntry::FilePath(outputPath_).Append(filename).ReplaceExtension(".sxml").GetPath(); if (!solidXml.GenerateSolidXml(filePath)) { return false; } diff --git a/test/config.json b/test/config.json new file mode 100644 index 0000000..390d25b --- /dev/null +++ b/test/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/test/resources/base/element/strings.json b/test/resources/base/element/strings.json new file mode 100644 index 0000000..acef8b4 --- /dev/null +++ b/test/resources/base/element/strings.json @@ -0,0 +1,5 @@ +{ + "string":[ + { "name":"mainability_description", "value":"my testing application"} + ] +} \ No newline at end of file diff --git a/test/resources/base/media/icon.png b/test/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ef70bd6b5d33d5eab52f56e7f163bce440e37522 GIT binary patch literal 4331 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 literal 0 HcmV?d00001 diff --git a/test/test.py b/test/test.py new file mode 100644 index 0000000..fe57518 --- /dev/null +++ b/test/test.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# 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 os +import sys + +restool_cmd = sys.argv[1] +output_path = sys.argv[2] + +run_cmd = restool_cmd +run_cmd = run_cmd + " -i " + os.path.join(".") +run_cmd = run_cmd + " -o " + output_path +run_cmd = run_cmd + " -r " + os.path.join(output_path, "ResourceTable.h") +run_cmd = run_cmd + " -p com.example.myapplication" +os.system(run_cmd) \ No newline at end of file -- Gitee