Skip to content

Commit 6f50df5

Browse files
committed
refactor(toolchain): 对stage4的头文件添加system和path选项支持
1 parent c97bd1b commit 6f50df5

File tree

5 files changed

+71
-8
lines changed

5 files changed

+71
-8
lines changed

toolchain/scripts/stage4/install_cereal.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,25 @@ case "$with_cereal" in
9090
echo "--pack-run mode specified, skip system check"
9191
exit 0
9292
fi
93-
add_include_from_paths CEREAL_CFLAGS "cereal/cereal.hpp" $INCLUDE_PATHS
93+
# Find cereal header file and derive package root directory
94+
cereal_header_path="$(find_in_paths "cereal/cereal.hpp" $INCLUDE_PATHS)"
95+
if [ "$cereal_header_path" != "__FALSE__" ]; then
96+
# Derive pkg_install_dir from found header path
97+
# cereal/cereal.hpp -> remove /cereal/cereal.hpp -> get include dir -> get parent dir
98+
cereal_include_dir="$(dirname "$(dirname "$cereal_header_path")")"
99+
pkg_install_dir="$(dirname "$cereal_include_dir")"
100+
echo "Found cereal at: $pkg_install_dir"
101+
CEREAL_CFLAGS="-I'${cereal_include_dir}'"
102+
else
103+
report_error "Cannot find cereal/cereal.hpp in system paths"
104+
exit 1
105+
fi
94106
;;
95107
__DONTUSE__) ;;
96-
108+
97109
*)
98110
echo "==================== Linking CEREAL to user paths ===================="
99-
pkg_install_dir="$with_cereal"
111+
pkg_install_dir="${with_cereal}"
100112
check_dir "${pkg_install_dir}"
101113
CEREAL_CFLAGS="-I'${pkg_install_dir}'"
102114
;;

toolchain/scripts/stage4/install_libcomm.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,25 @@ case "$with_libcomm" in
8989
echo "--pack-run mode specified, skip system check"
9090
exit 0
9191
fi
92-
add_include_from_paths LIBCOMM_CFLAGS "comm/comm.h" $INCLUDE_PATHS
92+
# Find libcomm header file and derive package root directory
93+
libcomm_header_path="$(find_in_paths "Comm/Comm_Tools.h" $INCLUDE_PATHS)"
94+
if [ "$libcomm_header_path" != "__FALSE__" ]; then
95+
# Derive pkg_install_dir from found header path
96+
# Comm/Comm_Tools.h -> remove /Comm/Comm_Tools.h -> get include dir -> get parent dir
97+
libcomm_include_dir="$(dirname "$(dirname "$libcomm_header_path")")"
98+
pkg_install_dir="$(dirname "$libcomm_include_dir")"
99+
echo "Found libcomm at: $pkg_install_dir"
100+
LIBCOMM_CFLAGS="-I'${libcomm_include_dir}'"
101+
else
102+
report_error "Cannot find Comm/Comm_Tools.h in system paths"
103+
exit 1
104+
fi
93105
;;
94106
__DONTUSE__) ;;
95107

96108
*)
97109
echo "==================== Linking LIBCOMM to user paths ===================="
110+
pkg_install_dir="${with_libcomm}"
98111
check_dir "${pkg_install_dir}"
99112
LIBCOMM_CFLAGS="-I'${pkg_install_dir}'"
100113
;;

toolchain/scripts/stage4/install_libnpy.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,25 @@ case "$with_libnpy" in
8080
echo "--pack-run mode specified, skip system check"
8181
exit 0
8282
fi
83-
add_include_from_paths LIBNPY_CFLAGS "npy.hpp" $INCLUDE_PATHS
83+
# Find libnpy header file and derive package root directory
84+
libnpy_header_path="$(find_in_paths "npy.hpp" $INCLUDE_PATHS)"
85+
if [ "$libnpy_header_path" != "__FALSE__" ]; then
86+
# Derive pkg_install_dir from found header path
87+
# npy.hpp -> get include dir -> get parent dir
88+
libnpy_include_dir="$(dirname "$libnpy_header_path")"
89+
pkg_install_dir="$(dirname "$libnpy_include_dir")"
90+
echo "Found libnpy at: $pkg_install_dir"
91+
LIBNPY_CFLAGS="-I'${libnpy_include_dir}'"
92+
else
93+
report_error "Cannot find npy.hpp in system paths"
94+
exit 1
95+
fi
8496
;;
8597
__DONTUSE__) ;;
8698

8799
*)
88100
echo "==================== Linking LIBNPY to user paths ===================="
101+
pkg_install_dir="${with_libnpy}"
89102
check_dir "${pkg_install_dir}"
90103
LIBNPY_CFLAGS="-I'${pkg_install_dir}'"
91104
;;

toolchain/scripts/stage4/install_libri.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,25 @@ case "$with_libri" in
8888
echo "--pack-run mode specified, skip system check"
8989
exit 0
9090
fi
91-
add_include_from_paths LIBRI_CFLAGS "RI/RI.h" $INCLUDE_PATHS
91+
# Find libri header file and derive package root directory
92+
libri_header_path="$(find_in_paths "RI/version.h" $INCLUDE_PATHS)"
93+
if [ "$libri_header_path" != "__FALSE__" ]; then
94+
# Derive pkg_install_dir from found header path
95+
# RI/version.h -> remove /RI/version.h -> get include dir -> get parent dir
96+
libri_include_dir="$(dirname "$(dirname "$libri_header_path")")"
97+
pkg_install_dir="$(dirname "$libri_include_dir")"
98+
echo "Found libri at: $pkg_install_dir"
99+
LIBRI_CFLAGS="-I'${libri_include_dir}'"
100+
else
101+
report_error "Cannot find RI/version.h in system paths"
102+
exit 1
103+
fi
92104
;;
93105
__DONTUSE__) ;;
94106

95107
*)
96108
echo "==================== Linking LIBRI to user paths ===================="
109+
pkg_install_dir="${with_libri}"
97110
check_dir "${pkg_install_dir}"
98111
LIBRI_CFLAGS="-I'${pkg_install_dir}'"
99112
;;

toolchain/scripts/stage4/install_rapidjson.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,25 @@ EOF
9393
echo "--pack-run mode specified, skip system check"
9494
exit 0
9595
fi
96-
add_include_from_paths RAPIDJSON_CFLAGS "rapidjson/rapidjson.h" $INCLUDE_PATHS
96+
# Find rapidjson header file and derive package root directory
97+
rapidjson_header_path="$(find_in_paths "rapidjson/rapidjson.h" $INCLUDE_PATHS)"
98+
if [ "$rapidjson_header_path" != "__FALSE__" ]; then
99+
# Derive pkg_install_dir from found header path
100+
# rapidjson/rapidjson.h -> remove /rapidjson/rapidjson.h -> get include dir -> get parent dir
101+
rapidjson_include_dir="$(dirname "$(dirname "$rapidjson_header_path")")"
102+
pkg_install_dir="$(dirname "$rapidjson_include_dir")"
103+
echo "Found rapidjson at: $pkg_install_dir"
104+
RAPIDJSON_CFLAGS="-I'${rapidjson_include_dir}'"
105+
else
106+
report_error "Cannot find rapidjson/rapidjson.h in system paths"
107+
exit 1
108+
fi
97109
;;
98110
__DONTUSE__) ;;
99111

100112
*)
101113
echo "==================== Linking RapidJSON to user paths ===================="
102-
pkg_install_dir="$with_rapidjson"
114+
pkg_install_dir="${with_rapidjson}"
103115
check_dir "${pkg_install_dir}"
104116
RAPIDJSON_CFLAGS="-I'${pkg_install_dir}/include'"
105117
;;

0 commit comments

Comments
 (0)