From: SangYoun Kwak Date: Tue, 14 May 2024 06:27:52 +0000 (+0900) Subject: Modify to create .pc file with BuildRequire packages X-Git-Tag: accepted/tizen/unified/20240719.080553~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50b2b7167228a6c5a4491c3de57aaad2cfd56f10;p=platform%2Fhal%2Fbackend%2Frootstrap-data-common.git Modify to create .pc file with BuildRequire packages If some other package BuildRequires this hal-rootstrap package with pkgconfig, it refers hal-rootstrap.pc for the locations of includes and libraries. Thus, to make them buildable, it is required to include all possible paths of headers and libraries in the .pc file. The script modify_pc.py reads every .pc files then modifies hal-rootstrap.pc file to include them. Change-Id: Icf114a20a705b7fd8854041c0ab59e18a192fc30 Signed-off-by: SangYoun Kwak --- diff --git a/make_rootstrap.sh b/make_rootstrap.sh index a64ff5b..e92e464 100755 --- a/make_rootstrap.sh +++ b/make_rootstrap.sh @@ -319,10 +319,10 @@ if [ "$OPT_TARGET" = true ]; then remove_dir ${DIR_TMP} ${DIR_TARGET} callRootstrapGen target ${RPM_PKG_SVR_TARGET} ${BASE_PKG_SVR_TARGET} - log "[INFO] Postscript ${DIR_TARGET}"; + log "[INFO] Postscript ${GBS_BUILDROOT}"; - mv ${DIR_TARGET}/usr/include/asm-arm ${DIR_TARGET}/usr/include/asm - mv ${DIR_TARGET}/usr/include/base/deprecated/* ${DIR_TARGET}/usr/include/base/ + mv ${GBS_BUILDROOT}/usr/include/asm-arm ${GBS_BUILDROOT}/usr/include/asm + mv ${GBS_BUILDROOT}/usr/include/base/deprecated/* ${GBS_BUILDROOT}/usr/include/base/ if [ "$INTERNAL" = false ]; then echo "remove Non-Public EFL API" @@ -335,16 +335,16 @@ if [ "$OPT_TARGET" = true ]; then if [ "$INTERNAL" = true ]; then log "[INFO] Skip .. removing dlog-internal.h" - find ${DIR_TARGET} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \; + find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \; else - find ${DIR_TARGET} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \; + find ${GBS_BUILDROOT} -name "dlog.h" -exec perl -pi -e 's/#include\ \"dlog-internal\.h\"//g' {} \; fi - if [ ! -d "${DIR_TARGET}/usr/lib" ]; then - mkdir -p ${DIR_TARGET}/usr/lib + if [ ! -d "${GBS_BUILDROOT}/usr/lib" ]; then + mkdir -p ${GBS_BUILDROOT}/usr/lib fi - for FILE in $(find ${DIR_TARGET} -name "*.so.*mobile"); + for FILE in $(find ${GBS_BUILDROOT} -name "*.so.*mobile"); do mv ${FILE} ${FILE%.mobile}; done; diff --git a/modify_pc.py b/modify_pc.py new file mode 100755 index 0000000..b86e2ec --- /dev/null +++ b/modify_pc.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 + +from sys import argv +from os import listdir +from re import compile as regex_compile + +include_dir_root_path = "hal_rootstrap_dir" + +regex_assignment = regex_compile("\s*([-_a-zA-Z0-9]+)\s*=\s*([^\s]*)") +regex_declaration = regex_compile("\s*([-_a-zA-Z0-9]+)\s*:\s*(.+)\s*") +regex_substitution = regex_compile("\${([-_a-zA-Z0-9]+)}") + +libs = { "-L${" + include_dir_root_path + "}" } +cflags = { "-I${" + include_dir_root_path + "}" } +cxxflags = { "-I${" + include_dir_root_path + "}" } + +def parse_pc(fname): + variables = dict() + + f = open(fname, "r") + for line in f: + if matches := regex_assignment.findall(line): + symbol, value = matches[0][0], matches[0][1] + matched_symbols = regex_substitution.findall(value) + for matched_symbol in matched_symbols: + value = value.replace("${{{}}}".format(matched_symbol), "{}".format(variables[matched_symbol])) + variables[symbol] = value + continue + if matches := regex_declaration.findall(line): + symbol, value = matches[0][0], matches[0][1] + matched_symbols = regex_substitution.findall(value) + for matched_symbol in matched_symbols: + value = value.replace("${{{}}}".format(matched_symbol), "{}".format(variables[matched_symbol])) + if symbol == "Libs": + libs.update(set(map(lambda value: value[:2] + "${" + include_dir_root_path + "}" + value[2:] if value[2] == '/' else value, value.split()))) + continue + if symbol == "Cflags": + cflags.update((map(lambda value: value[:2] + "${" + include_dir_root_path + "}" + value[2:] if value[2] == '/' else value, value.split()))) + continue + if symbol == "CXXflags": + cxxflags.update(list(map(lambda value: value[:2] + "${" + include_dir_root_path + "}" + value[2:] if value[2] == '/' else value, value.split()))) + continue + + f.close() + +def write_to_pc(fname): + f = open(fname, "a") + f.write("\n") + f.write("Libs: {}\n".format(' '.join(libs))) + f.write("Cflags: {}\n".format(' '.join(cflags))) + f.write("CXXflags: {}\n".format(' '.join(cxxflags))) + f.close() + +hal_rootstrap_pc_path = argv[1] +pc_dir = argv[2] +pc_files = listdir(pc_dir) + +for pc_file in pc_files: + parse_pc("{}/{}".format(pc_dir, pc_file)) + +write_to_pc(hal_rootstrap_pc_path) diff --git a/packaging/hal-rootstrap.pc.in b/packaging/hal-rootstrap.pc.in index 47071bd..f42c89f 100644 --- a/packaging/hal-rootstrap.pc.in +++ b/packaging/hal-rootstrap.pc.in @@ -3,14 +3,12 @@ package_name=hal-rootstrap prefix=/opt/data/hal-rootstrap@PREFIX@ exec_prefix=/opt/data/hal-rootstrap@EXEC_PREFIX@ -hal_rootstrap_libdir=/opt/data/hal-rootstrap@LIBDIR@ -hal_rootstrap_include_dir=/opt/data/hal-rootstrap@INCLUDEDIR@ +hal_rootstrap_dir=/opt/data/hal-rootstrap +hal_rootstrap_libdir=${hal_rootstrap_dir}@LIBDIR@ +hal_rootstrap_include_dir=${hal_rootstrap_dir}@INCLUDEDIR@ Name: ${package_name} Description: ${package_name} interface Version: @VERSION@ Requires: -Libs: -L${hal_rootstrap_libdir} -Cflags: -I${hal_rootstrap_include_dir} -CXXflags: -I${hal_rootstrap_include_dir} diff --git a/packaging/hal-rootstrap.spec b/packaging/hal-rootstrap.spec index f050978..245be43 100644 --- a/packaging/hal-rootstrap.spec +++ b/packaging/hal-rootstrap.spec @@ -438,6 +438,7 @@ mkdir %{buildroot} mkdir -p %{buildroot}%{_libdir}/pkgconfig/ cp packaging/hal-rootstrap.pc %{buildroot}%{_libdir}/pkgconfig/ +./modify_pc.py "%{buildroot}%{_libdir}/pkgconfig/hal-rootstrap.pc" "%{buildroot}%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig" %files %{hal_rootstrap_install_path}/lib/*