From c23a1540c7a3001ccd3b2309d4dde3afa6452ef6 Mon Sep 17 00:00:00 2001 From: zhenghui Date: Sun, 4 May 2025 15:59:22 +0800 Subject: [PATCH] =?UTF-8?q?exec=5Fscript=E5=87=BD=E6=95=B0=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhenghui --- BUILD.gn | 105 ++++----------------------------------------- pcre2/check_md5.sh | 37 +++++++++++++--- 2 files changed, 39 insertions(+), 103 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 6ff9dd6..c6fcbbb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,60 +50,22 @@ pcre2_sources = [ "$PCRE2_LIB_DIR/src/pcre2_xclass.c", ] -ohos_shared_library("libpcre2") { - branch_protector_ret = "pac_ret" - - md5_check_script = rebase_path("$PCRE2_LIB_DIR/check_md5.sh") - _arguments_config = [ +action("check_md5") { + script = rebase_path("$PCRE2_LIB_DIR/check_md5.sh") + args = [ 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", - "-f", - 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", - "-f", - 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"), ] + outputs = [ "$target_out_dir" ] +} - check_pcre2_chartables_result = - exec_script(md5_check_script, _arguments_pcre2_chartables, "string") - if (check_pcre2_chartables_result == "") { - exec_script("/usr/bin/env", - [ - "cp", - "-f", - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c"), - ]) - } - +ohos_shared_library("libpcre2") { + branch_protector_ret = "pac_ret" + deps = [ ":check_md5" ] output_name = "libpcre2" sources = pcre2_sources sources += [ "$PCRE2_LIB_DIR/src/pcre2_chartables.c" ] @@ -138,57 +100,8 @@ ohos_static_library("libpcre2_static") { "-p", rebase_path("$PCRE2_LIB_DIR/src_static"), ]) - 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_static/config.h"), - ] - - check_config_result = - exec_script(md5_check_script, _arguments_config, "string") - if (check_config_result == "") { - exec_script("/usr/bin/env", - [ - "cp", - "-f", - rebase_path("$PCRE2_LIB_DIR/src/config.h.generic"), - rebase_path("$PCRE2_LIB_DIR/src_static/config.h"), - ]) - } - - _arguments_pcre2 = [ - rebase_path("$PCRE2_LIB_DIR/src/pcre2.h.generic"), - rebase_path("$PCRE2_LIB_DIR/src_static/pcre2.h"), - ] - - check_pcre2_result = exec_script(md5_check_script, _arguments_pcre2, "string") - if (check_pcre2_result == "") { - exec_script("/usr/bin/env", - [ - "cp", - "-f", - rebase_path("$PCRE2_LIB_DIR/src/pcre2.h.generic"), - rebase_path("$PCRE2_LIB_DIR/src_static/pcre2.h"), - ]) - } - - _arguments_pcre2_chartables = [ - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), - rebase_path("$PCRE2_LIB_DIR/src_static/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", - "-f", - rebase_path("$PCRE2_LIB_DIR/src/pcre2_chartables.c.dist"), - rebase_path("$PCRE2_LIB_DIR/src_static/pcre2_chartables.c"), - ]) - } + deps = [ ":check_md5" ] output_name = "libpcre2_static" sources = pcre2_sources sources += [ "$PCRE2_LIB_DIR/src_static/pcre2_chartables.c" ] diff --git a/pcre2/check_md5.sh b/pcre2/check_md5.sh index ba03c0e..f60e2f0 100755 --- a/pcre2/check_md5.sh +++ b/pcre2/check_md5.sh @@ -13,13 +13,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -input_file=$1 -output_file=$2 +input_file_1=$1 +output_file_1=$2 +input_file_2=$3 +output_file_2=$4 +input_file_3=$5 +output_file_3=$6 -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" +if [ -f $input_file_1 ] && [ -f $output_file_1 ];then + input_file_1_md5=$(md5sum ${input_file_1} | awk '{print $1}') + output_file_1_md5=$(md5sum ${output_file_1} | awk '{print $1}') + if [ "${input_file_1_md5}"x != "${output_file_1_md5}"x ];then + echo "input_file_1_md5 not epual output_file_1_md5" + cp -p ${input_file_1} ${output_file_1} + fi +fi + +if [ -f $input_file_2 ] && [ -f $output_file_2 ];then + input_file_2_md5=$(md5sum ${input_file_2} | awk '{print $1}') + output_file_2_md5=$(md5sum ${output_file_2} | awk '{print $1}') + if [ "${input_file_2_md5}"x != "${output_file_2_md5}"x ];then + echo "input_file_2_md5 not epual output_file_2_md5" + cp -p ${input_file_2} ${output_file_2} + fi +fi + +if [ -f $input_file_3 ] && [ -f $output_file_3 ];then + input_file_3_md5=$(md5sum ${input_file_3} | awk '{print $1}') + output_file_3_md5=$(md5sum ${output_file_3} | awk '{print $1}') + if [ "${input_file_3_md5}"x != "${output_file_3_md5}"x ];then + echo "input_file_3_md5 not epual output_file_3_md5" + cp -p ${input_file_3} ${output_file_3} fi fi -- Gitee