Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
valord577 committed Nov 6, 2024
1 parent 871055d commit f56d961
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 61 deletions.
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ function compile() {
popd
fi
bash "${PROJ_ROOT}/scripts/${PKG_NAME}.sh"


if [ "${CLANGD_CODE_COMPLETION}" != "1" ]; then
{ command -v tree >/dev/null 2>&1; } \
&& { tree -L 3 ${PKG_INST_DIR}; } \
|| { ls -alh -- ${PKG_INST_DIR}; }
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ%:z')
printf "\e[1m\e[35m%s\e[0m\n" "${SUBPROJ_SRC} - Build Done @${BUILD_DATE}"
)
}

Expand Down
13 changes: 12 additions & 1 deletion env-linux-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ if [ -z "${CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE}" ]; then
fi
CROSS_TOOLCHAIN_FILE_CMAKE="${CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE}.${TARGET_TRIPLE}"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_TOOLCHAIN_FILE=${CROSS_TOOLCHAIN_FILE_CMAKE}"
# meson toolchain file
if [ -z "${CROSS_TOOLCHAIN_FILE_PREFIX_MESON}" ]; then
CROSS_TOOLCHAIN_FILE_PREFIX_MESON="${CROSS_TOOLCHAIN_ROOT}/toolchain-meson-template"
fi
CROSS_TOOLCHAIN_FILE_MESON="${CROSS_TOOLCHAIN_FILE_PREFIX_MESON}.${TARGET_TRIPLE}"
export MESON_EXTRA="${MESON_EXTRA} --cross-file ${CROSS_TOOLCHAIN_FILE_MESON}"
# pkgconf bin
if [ -z "${CROSS_TOOLCHAIN_PKGCONF_PREFIX}" ]; then
CROSS_TOOLCHAIN_PKGCONF_PREFIX="${CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper"
Expand All @@ -57,8 +63,13 @@ export AR="$(command -v llvm-ar)";
export AS="$(command -v llvm-as)";
export RANLIB="$(command -v llvm-ranlib)";
export STRIP="$(command -v llvm-strip)";
export OBJCOPY="$(command -v llvm-objcopy)";

export CROSS_FLAGS="--target=${TARGET_TRIPLE} --gcc-toolchain=${CROSS_TOOLCHAIN_ROOT} -Wno-unused-command-line-argument -fuse-ld=${LD} --sysroot=${SYSROOT}"
export CROSS_FLAGS="--target=${TARGET_TRIPLE} --gcc-toolchain=${CROSS_TOOLCHAIN_ROOT} --sysroot=${SYSROOT}"
if [ "${TARGET_ARCH}" == "armv7" ]; then
export CROSS_FLAGS="${CROSS_FLAGS} -march=armv7-a -mfpu=neon-vfpv4"
fi
export CROSS_LDFLAGS="-fuse-ld=${LD} --sysroot=${SYSROOT}"
export CC="$(command -v clang) ${CROSS_FLAGS}";
export CXX="$(command -v clang++) ${CROSS_FLAGS}";
export CPP="$(command -v clang-cpp) ${CROSS_FLAGS}";
17 changes: 17 additions & 0 deletions env-linux-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ case "$(uname -m)" in
;;
esac

# check libc implementation
if ! command -v ldd >/dev/null 2>&1 ; then
printf "\e[1m\e[31m%s\e[0m\n" "Unknown exec 'ldd'."
exit 1
fi
libc_is_musl=$(ldd --version | grep 'musl' 2>&1 >/dev/null; echo $?)
if [ "${libc_is_musl}" == "0" ]; then
export TARGET_LIBC="musl"
else
if [ "${TARGET_ARCH}" == "armv7" ]; then
export TARGET_LIBC="gnueabihf"
else
export TARGET_LIBC="gnu"
fi
fi


export PARALLEL_JOBS="$(nproc)"
if command -v ccache >/dev/null 2>&1 ; then
export CCACHE_SRC="$(command -v ccache)"
Expand Down
12 changes: 0 additions & 12 deletions patches/mbedtls/01_fix_cross_shared_build.patch

This file was deleted.

23 changes: 20 additions & 3 deletions pkg-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,25 @@ function dl_pkgc() {
fi

export PKG_DEPS_ARGS="${PKG_DEPS_ARGS} ${5}"
if [ "${3}" == "shared" ]; then { export PKG_DEPS_SHARED="${PKG_DEPS_SHARED} ${1}"; } fi

export PKG_DEPS_CMAKE="${dep_libs_dir}/${1};${PKG_DEPS_CMAKE}"
export PKG_CONFIG_PATH="${dep_libs_dir}/${1}/lib/pkgconfig:${PKG_CONFIG_PATH}"

# mark libraries (shared static)
# - PKG_DEPS_SHARED
# - PKG_DEPS_STATIC
eval export "PKG_DEPS_${3^^}=\"\${PKG_DEPS_${3^^}} ${dep_libs_dir}/${1}\""

# https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html
cmake_search_path="${dep_libs_dir}/${1}"
if [ -n "${6}" ]; then
cmake_search_path="${dep_libs_dir}/${1}/${6}"
fi
export PKG_DEPS_CMAKE="${cmake_search_path};${PKG_DEPS_CMAKE}"

# for shared library's own dependencies
if [ -n "${7}" ]; then
triplet_values=(${7//:/ })
for path in ${triplet_values[@]}; do
export LD_LIBRARY_PATH="${dep_libs_dir}/${1}/${path}:${LD_LIBRARY_PATH}"
done
fi
}
32 changes: 12 additions & 20 deletions scripts/ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ fi
# ----------------------------
# compile :p
# ----------------------------
{ rm -rf ${PKG_BULD_DIR}; mkdir -p "${PKG_BULD_DIR}"; }
{ rm -rf ${PKG_INST_DIR}; mkdir -p "${PKG_INST_DIR}"; }

if [ "${CLANGD_CODE_COMPLETION}" == "1" ]; then { PKG_BULD_DIR="${SUBPROJ_SRC}"; } fi
if [ "${CLANGD_CODE_COMPLETION}" == "1" ]; then
PKG_BULD_DIR="${PROJ_ROOT}"
else
{ rm -rf ${PKG_BULD_DIR}; mkdir -p "${PKG_BULD_DIR}"; }
{ rm -rf ${PKG_INST_DIR}; mkdir -p "${PKG_INST_DIR}"; }
fi

pushd -- "${PKG_BULD_DIR}"
CONFIGURE_COMMAND=$(cat <<- EOF
${SUBPROJ_SRC}/configure \
--prefix='${PKG_INST_DIR}' \
Expand Down Expand Up @@ -81,8 +82,8 @@ case ${PKG_PLATFORM} in
"linux")
if [ "${CROSS_BUILD_ENABLED}" == "1" ]; then
CONFIGURE_COMMAND="${CONFIGURE_COMMAND} \
--enable-cross-compile --target-os=linux --arch=${PKG_ARCH} \
--host-cc='${HOSTCC}' --nm='${NM}' --ar='${AR}' --ranlib='${RANLIB}' --strip='${STRIP}'"
--enable-cross-compile --target-os=linux --arch=${PKG_ARCH} --host-cc='${HOSTCC}' \
--extra-ldflags='${CROSS_LDFLAGS}' --nm='${NM}' --ar='${AR}' --ranlib='${RANLIB}' --strip='${STRIP}'"
fi
;;
"win-mingw")
Expand All @@ -94,11 +95,10 @@ case ${PKG_PLATFORM} in
;;
esac

printf "\e[1m\e[36m%s\e[0m\n" "${CONFIGURE_COMMAND}"; eval ${CONFIGURE_COMMAND}
popd
printf "\e[1m\e[36m%s\e[0m\n" "${CONFIGURE_COMMAND}"
pushd -- "${PKG_BULD_DIR}"; eval ${CONFIGURE_COMMAND}; popd

# build & install
pushd -- "${PKG_BULD_DIR}"
MAKE_COMMAND="make -j ${PARALLEL_JOBS}"
if [ "${PKG_PLATFORM}" == "iphoneos" ] || \
[ "${PKG_PLATFORM}" == "iphonesimulator" ]; then
Expand All @@ -113,17 +113,9 @@ fi
if command -v bear >/dev/null 2>&1 ; then
MAKE_COMMAND="bear -- ${MAKE_COMMAND}"
fi
printf "\e[1m\e[36m%s\e[0m\n" "${MAKE_COMMAND}"; eval ${MAKE_COMMAND}
popd
printf "\e[1m\e[36m%s\e[0m\n" "${MAKE_COMMAND}"
pushd -- "${PKG_BULD_DIR}"; eval ${MAKE_COMMAND}; popd

if [ "${PKG_PLATFORM}" == "macosx" ]; then
xattr -dr com.apple.quarantine ${PKG_INST_DIR}/bin/*
fi

if command -v tree >/dev/null 2>&1 ; then
tree -L 3 ${PKG_INST_DIR}
else
ls -alh -- ${PKG_INST_DIR}
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ%:z')
printf "\e[1m\e[35m%s\e[0m\n" "${SUBPROJ_SRC} - Build Done @${BUILD_DATE}"
8 changes: 0 additions & 8 deletions scripts/llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,3 @@ printf "\e[1m\e[36m%s\e[0m\n" "${CMAKE_COMMAND}"; eval ${CMAKE_COMMAND}
# build & install
cmake --build "${PKG_BULD_DIR}"
cmake --install "${PKG_BULD_DIR}" ${PKG_INST_STRIP}

if command -v tree >/dev/null 2>&1 ; then
tree -L 3 ${PKG_INST_DIR}
else
ls -alh -- ${PKG_INST_DIR}
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ%:z')
printf "\e[1m\e[35m%s\e[0m\n" "${SUBPROJ_SRC} - Build Done @${BUILD_DATE}"
8 changes: 0 additions & 8 deletions scripts/mbedtls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,3 @@ Version:
Libs: -L\${libdir} ${PKG_LIBRARY_DEPS}
Cflags: -I\${includedir}
EOF

if command -v tree >/dev/null 2>&1 ; then
tree -L 3 ${PKG_INST_DIR}
else
ls -alh -- ${PKG_INST_DIR}
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ%:z')
printf "\e[1m\e[35m%s\e[0m\n" "${SUBPROJ_SRC} - Build Done @${BUILD_DATE}"
8 changes: 0 additions & 8 deletions scripts/sdl2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,3 @@ printf "\e[1m\e[36m%s\e[0m\n" "${CMAKE_COMMAND}"; eval ${CMAKE_COMMAND}
# build & install
cmake --build "${PKG_BULD_DIR}" -j ${PARALLEL_JOBS}
cmake --install "${PKG_BULD_DIR}" ${PKG_INST_STRIP}

if command -v tree >/dev/null 2>&1 ; then
tree -L 3 ${PKG_INST_DIR}
else
ls -alh -- ${PKG_INST_DIR}
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ%:z')
printf "\e[1m\e[35m%s\e[0m\n" "${SUBPROJ_SRC} - Build Done @${BUILD_DATE}"

0 comments on commit f56d961

Please sign in to comment.