diff --git a/BUILD.gn b/BUILD.gn index 42b58469edd477a95bb87a79a887c91cf3976bad..e4ba69032b1afd2bdb7d5e02320a2d97d7763452 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 9ebf3fd4a55ed077a51ccca975a3c4288596bf00..e87f06702a2b5e6fec9c01ef40fcf19033a98ba9 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 0000000000000000000000000000000000000000..ba03c0ef0f381c3b8b7b9818efe2be952ca545c2 --- /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