Skip to content

Commit

Permalink
update scripts (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
valord577 authored Dec 10, 2024
1 parent 871055d commit aed3e00
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 88 deletions.
15 changes: 11 additions & 4 deletions .github/matrix_container.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@
"arch": "amd64",
"pkg_type": "static",
"lib_impl": "gnu",
"image": "valord577/linux-cross:6a5d9b8db8c21b39d1655aa536d7566f5512e967"
"image": "valord577/linux-cross:d62159e85069a9c141b90f1429600183908c0f90"
},
{
"platform": "linux",
"arch": "arm64",
"pkg_type": "static",
"lib_impl": "gnu",
"image": "valord577/linux-cross:6a5d9b8db8c21b39d1655aa536d7566f5512e967"
"image": "valord577/linux-cross:d62159e85069a9c141b90f1429600183908c0f90"
},
{
"platform": "linux",
"arch": "armv7",
"pkg_type": "static",
"lib_impl": "gnueabihf",
"image": "valord577/linux-cross:d62159e85069a9c141b90f1429600183908c0f90"
},
{
"platform": "linux",
"arch": "amd64",
"pkg_type": "static",
"lib_impl": "musl",
"image": "valord577/linux-cross:6a5d9b8db8c21b39d1655aa536d7566f5512e967"
"image": "valord577/linux-cross:d62159e85069a9c141b90f1429600183908c0f90"
},
{
"platform": "linux",
"arch": "arm64",
"pkg_type": "static",
"lib_impl": "musl",
"image": "valord577/linux-cross:6a5d9b8db8c21b39d1655aa536d7566f5512e967"
"image": "valord577/linux-cross:d62159e85069a9c141b90f1429600183908c0f90"
}
]
6 changes: 6 additions & 0 deletions .github/workflows/_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
default: false
required: false
type: boolean
allow_failure:
default: false
required: false
type: boolean

env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -71,6 +75,7 @@ jobs:
strategy:
matrix: ${{ fromJson(needs._preset.outputs.matrix) }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ inputs.allow_failure }}
defaults:
run:
shell: ${{ startsWith(matrix.os, 'windows') && 'pwsh' || 'bash' }}
Expand Down Expand Up @@ -122,6 +127,7 @@ jobs:
strategy:
matrix: ${{ fromJson(needs._preset.outputs.matrix-container) }}
runs-on: ubuntu-latest
continue-on-error: ${{ inputs.allow_failure }}
container:
image: ${{ matrix.image }}
defaults:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ jobs:
secrets: inherit
uses: ./.github/workflows/_matrix.yml
with:
allow_failure: true
disable_upload: true
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
1 change: 1 addition & 0 deletions crossbuild_linux_gnueabihf_armv7.sh
2 changes: 1 addition & 1 deletion deps/sdl2
Submodule sdl2 updated 119 files
14 changes: 7 additions & 7 deletions env-apple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ export PARALLEL_JOBS="$(sysctl -n hw.ncpu)"
if command -v ccache >/dev/null 2>&1 ; then
export CCACHE_SRC="$(command -v ccache)"

export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_OBJC_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_OBJCXX_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_OBJC_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_OBJCXX_COMPILER_LAUNCHER=ccache"
fi

export CMAKE_EXTRA_ARGS=$(cat <<- EOF
export CMAKE_EXTRA=$(cat <<- EOF
-D CMAKE_OSX_ARCHITECTURES=${TARGET_ARCH} \
-D CMAKE_OSX_SYSROOT=${TARGET_PLATFORM} \
-D CMAKE_OSX_DEPLOYMENT_TARGET=${TARGET_DEPLOYMENT} \
-D CMAKE_MACOSX_BUNDLE:BOOL=0 ${CMAKE_EXTRA_ARGS}
-D CMAKE_MACOSX_BUNDLE:BOOL=0 ${CMAKE_EXTRA}
EOF
)
if [ "${TARGET_PLATFORM}" == "iphoneos" ] || \
[ "${TARGET_PLATFORM}" == "iphonesimulator" ]; then
export CMAKE_EXTRA_ARGS="-D CMAKE_SYSTEM_NAME=iOS ${CMAKE_EXTRA_ARGS}"
export CMAKE_EXTRA="-D CMAKE_SYSTEM_NAME=iOS ${CMAKE_EXTRA}"
fi
15 changes: 13 additions & 2 deletions env-linux-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ if [ -z "${CROSS_TOOLCHAIN_ROOT}" ]; then
printf "\e[1m\e[31m%s\e[0m\n" "Blank CROSS_TOOLCHAIN_ROOT: '${CROSS_TOOLCHAIN_ROOT}'."
exit 1
fi
export SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}/sysroot"
export SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}"

# cmake toolchain file
if [ -z "${CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE}" ]; then
CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE="${CROSS_TOOLCHAIN_ROOT}/toolchain-cmake-template"
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 READELF="$(command -v llvm-readelf)";

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=${SYSROOT}/usr --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}";
21 changes: 19 additions & 2 deletions env-linux-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,29 @@ 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)"

export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi

function chk_compiler() {
Expand Down
6 changes: 3 additions & 3 deletions env-mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fi
export SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${__TARGET_TRIPLE__}"

export PARALLEL_JOBS="$(nproc)"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_TOOLCHAIN_FILE=${CROSS_TOOLCHAIN_FILE_CMAKE}"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_TOOLCHAIN_FILE=${CROSS_TOOLCHAIN_FILE_CMAKE}"

# for cross-compiling, cmake sets compiler vars by toolchain file, so keep CC/CXX.
export CC="${CROSS_TOOLCHAIN_ROOT}/bin/${__TARGET_TRIPLE__}-clang"
Expand All @@ -46,6 +46,6 @@ export STRIP="${CROSS_TOOLCHAIN_ROOT}/bin/${__TARGET_TRIPLE__}-strip"
if command -v ccache >/dev/null 2>&1 ; then
export CCACHE_SRC="$(command -v ccache)"

export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
4 changes: 2 additions & 2 deletions env-msvc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if ($ccache -ne $null) {
${env:CCACHE_SRC} = "$($ccache.Source)"

# https://github.com/ccache/ccache/discussions/978
${env:CMAKE_EXTRA_ARGS} = "${env:CMAKE_EXTRA_ARGS} -D CMAKE_C_COMPILER_LAUNCHER=`"${env:CCACHE_SRC}`""
${env:CMAKE_EXTRA_ARGS} = "${env:CMAKE_EXTRA_ARGS} -D CMAKE_CXX_COMPILER_LAUNCHER=`"${env:CCACHE_SRC}`""
${env:CMAKE_EXTRA} = "${env:CMAKE_EXTRA} -D CMAKE_C_COMPILER_LAUNCHER=`"${env:CCACHE_SRC}`""
${env:CMAKE_EXTRA} = "${env:CMAKE_EXTRA} -D CMAKE_CXX_COMPILER_LAUNCHER=`"${env:CCACHE_SRC}`""
}

# >>> VS DevShell >>>
Expand Down
12 changes: 0 additions & 12 deletions patches/mbedtls/01_fix_cross_shared_build.patch

This file was deleted.

27 changes: 21 additions & 6 deletions pkg-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ if [ -n "${CROSS_TOOLCHAIN_PKGCONF}" ]; then
export PKG_CONFIG_EXEC="${CROSS_TOOLCHAIN_PKGCONF}"
fi

if [ -z "${PROJ_ROOT}" ]; then
PROJ_ROOT=$(cd "$(dirname ${BASH_SOURCE[0]})"; pwd)
fi
dep_libs_dir="${PROJ_ROOT}/lib"
if [ ! -e "${dep_libs_dir}" ]; then { mkdir -p "${dep_libs_dir}"; } fi

Expand Down Expand Up @@ -43,8 +40,26 @@ 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
_pkg_type_=$(echo ${3} | tr "[:lower:]" "[:upper:]") # fixed: run on macos zsh
eval export "PKG_DEPS_${_pkg_type_}=\"\${PKG_DEPS_${_pkg_type_}} ${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}"
2 changes: 1 addition & 1 deletion scripts/llvm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cmake -G Ninja ``
-D CMAKE_INSTALL_LIBDIR:PATH=lib ``
${PKG_BULD_TYPE} ``
${PKG_TYPE_FLAG} ``
${env:CMAKE_EXTRA_ARGS} ``
${env:CMAKE_EXTRA} ``
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb" ``
-D CLANG_PLUGIN_SUPPORT:BOOL=0 ``
-D LLVM_APPEND_VC_REV:BOOL=0 ``
Expand Down
10 changes: 1 addition & 9 deletions scripts/llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cmake -G Ninja \
-D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
-D CMAKE_INSTALL_PREFIX="${PKG_INST_DIR}" \
-D CMAKE_INSTALL_LIBDIR:PATH=lib \
${PKG_BULD_TYPE} ${PKG_TYPE_FLAG} ${CMAKE_EXTRA_ARGS} \
${PKG_BULD_TYPE} ${PKG_TYPE_FLAG} ${CMAKE_EXTRA} \
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb" \
-D CLANG_PLUGIN_SUPPORT:BOOL=0 \
-D LLVM_APPEND_VC_REV:BOOL=0 \
Expand All @@ -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}"
10 changes: 1 addition & 9 deletions scripts/mbedtls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cmake -S "${SUBPROJ_SRC}" -B "${PKG_BULD_DIR}" \
-D CMAKE_INSTALL_PREFIX="${PKG_INST_DIR}" \
-D CMAKE_INSTALL_LIBDIR:PATH=lib \
${PKG_BULD_TYPE} ${PKG_TYPE_FLAG} \
-D MBEDTLS_AS_SUBPROJECT:BOOL=1 ${CMAKE_EXTRA_ARGS} \
-D MBEDTLS_AS_SUBPROJECT:BOOL=1 ${CMAKE_EXTRA} \
-D ENABLE_PROGRAMS:BOOL=0 -D ENABLE_TESTING:BOOL=0
EOF
)
Expand All @@ -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}"
Loading

0 comments on commit aed3e00

Please sign in to comment.