From 44b28e9f8eba6a2943481d5f54ef6f2d21f11f55 Mon Sep 17 00:00:00 2001 From: yinchuang Date: Fri, 5 Aug 2022 15:26:18 +0800 Subject: [PATCH] Add incremental compilation judge for pcre2.h Issue:https://gitee.com/openharmony/third_party_pcre2/issues/I5KXGS Signed-off-by: yinchuang Signed-off-by: yinchuang --- BUILD.gn | 66 +++++++++++++++++++++++++++++++++------------- OAT.xml | 1 + pcre2/check_md5.sh | 25 ++++++++++++++++++ 3 files changed, 74 insertions(+), 18 deletions(-) create mode 100755 pcre2/check_md5.sh diff --git a/BUILD.gn b/BUILD.gn index 42b5846..e4ba690 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,24 +17,54 @@ import("//build/ohos.gni") PCRE2_LIB_DIR = "//third_party/pcre2/pcre2" ohos_shared_library("libpcre2") { - exec_script("/usr/bin/env", - [ - "cp", - rebase_path("$PCRE2_LIB_DIR/src/config.h.generic"), - rebase_path("$PCRE2_LIB_DIR/src/config.h"), - ]) - exec_script("/usr/bin/env", - [ - "cp", - rebase_path("$PCRE2_LIB_DIR/src/pcre2.h.generic"), - rebase_path("$PCRE2_LIB_DIR/src/pcre2.h"), - ]) - exec_script("/usr/bin/env", - [ - "cp", - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c"), - ]) + md5_check_script = rebase_path("$PCRE2_LIB_DIR/check_md5.sh") + _arguments_config = [ + rebase_path("$PCRE2_LIB_DIR/src/config.h.generic"), + rebase_path("$PCRE2_LIB_DIR/src/config.h"), + ] + + check_config_result = + exec_script(md5_check_script, _arguments_config, "string") + if (check_config_result == "") { + exec_script("/usr/bin/env", + [ + "cp", + rebase_path("$PCRE2_LIB_DIR/src/config.h.generic"), + rebase_path("$PCRE2_LIB_DIR/src/config.h"), + ]) + } + + _arguments_pcre2 = [ + rebase_path("$PCRE2_LIB_DIR/src/pcre2.h.generic"), + rebase_path("$PCRE2_LIB_DIR/src/pcre2.h"), + ] + + check_pcre2_result = exec_script(md5_check_script, _arguments_pcre2, "string") + if (check_pcre2_result == "") { + exec_script("/usr/bin/env", + [ + "cp", + rebase_path("$PCRE2_LIB_DIR/src/pcre2.h.generic"), + rebase_path("$PCRE2_LIB_DIR/src/pcre2.h"), + ]) + } + + _arguments_pcre2_chartables = [ + rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), + rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c"), + ] + + check_pcre2_chartables_result = + exec_script(md5_check_script, _arguments_pcre2_chartables, "string") + if (check_pcre2_chartables_result == "") { + exec_script("/usr/bin/env", + [ + "cp", + rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), + rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c"), + ]) + } + output_name = "libpcre2" sources = [ "$PCRE2_LIB_DIR/src/pcre2_auto_possess.c", diff --git a/OAT.xml b/OAT.xml index 9ebf3fd..e87f067 100644 --- a/OAT.xml +++ b/OAT.xml @@ -24,6 +24,7 @@ + diff --git a/pcre2/check_md5.sh b/pcre2/check_md5.sh new file mode 100755 index 0000000..ba03c0e --- /dev/null +++ b/pcre2/check_md5.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +# 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. + +input_file=$1 +output_file=$2 + +if [ -f $input_file ] && [ -f $output_file ];then + input_file_md5=$(md5sum ${input_file} | awk '{print $1}') + output_file_md5=$(md5sum ${output_file} | awk '{print $1}') + if [ "${input_file_md5}"x == "${output_file_md5}"x ];then + echo "ok" + fi +fi -- Gitee