diff --git a/.github/scripts/ci_2404_shim.sh b/.github/scripts/ci_2404_shim.sh new file mode 100755 index 0000000000..62f6ca5c11 --- /dev/null +++ b/.github/scripts/ci_2404_shim.sh @@ -0,0 +1,408 @@ +#!/usr/bin/env bash +# Ubuntu 24.04 构建适配(只由 build_linux.yml 的 24.04 job 调用) +# +# 原则: +# 1) 不改仓库里的任何 .cs 文件(Target.cs 为 Windows/macOS/20.04 共用,须其他系统验证后才可改), +# /wd4103 这类 MSVC 专用参数在 clang 包装脚本里丢弃; +# 2) 工具链统一用 UE4 自带的 clang / clang++ / ld.lld,不依赖系统编译器; +# 3) mono 优先用依赖库,其次引擎自带,最后才回落系统。 +# +# 对仓库文件的修改全部发生在 CI 工作区,不会提交。 + +set -euo pipefail + +ROOT="${GITHUB_WORKSPACE:-$(pwd)}" +UE4_ROOT="${UE4_ROOT:?请先导出 UE4_ROOT}" +UE4_SDK="$UE4_ROOT/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu" +UE4_BIN="$UE4_SDK/bin" +UE4_LIBCXX_INC="$UE4_ROOT/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1" +UE4_LIBCXX_LIB="$UE4_ROOT/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu" + +[ -x "$UE4_BIN/clang++" ] || { echo "找不到引擎 clang++: $UE4_BIN"; exit 1; } +cd "$ROOT" + +set_env() { + if [ -n "${GITHUB_ENV:-}" ]; then + echo "$1=$2" >> "$GITHUB_ENV" + else + export "$1=$2" + fi +} + +# AirSim 由 setup.sh 克隆,首次执行 shim 时还不存在;单独暴露函数,供 setup 之后补跑 +patch_airsim_buildcs() { + p="Unreal/CarlaUE4/Plugins/AirSim/Source/AirSim.Build.cs" + if [ ! -f "$p" ]; then + echo "[skip] AirSim 尚未 checkout(setup.sh 会克隆),稍后用 --after-setup 补跑" + return 0 + fi + python3 - "$p" <<'PY' +import io, sys +p = sys.argv[1] +s = io.open(p, encoding='utf-8').read() +if 'hutb-ci] rpclib' in s: + print('rpclib 去重补丁已存在,跳过') +else: + old = (' LoadAirSimDependency(Target, "rpclib", "rpc");\n' + ' break;\n\n case CompileMode.CppCompileNoRpc:') + new = (' // [hutb-ci] rpclib 由 CarlaDependencies 提供(libc++ 版),避免两份 librpc.a 重复符号\n' + ' // LoadAirSimDependency(Target, "rpclib", "rpc");\n' + ' break;\n\n case CompileMode.CppCompileNoRpc:') + if old in s: + io.open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1)) + print('rpclib 去重补丁已写入') + else: + print('警告:AirSim.Build.cs 锚点未命中') +PY +} + +if [ "${1:-}" = "--after-setup" ]; then + echo "== 仅补 AirSim(setup 克隆之后)==" + patch_airsim_buildcs + exit 0 +fi + +# --------------------------------------------------------------------------- +echo "== 1/9 Mono:依赖库 > 引擎自带 > 系统 ==" +ENGINE_MONO="$UE4_ROOT/Engine/Binaries/ThirdParty/Mono/Linux" +MONO_SRC="" +for cand in "$ROOT/Build/dependencies/prerequisites/mono" "${MONO_HOME:-/nonexistent}" "$HOME/ci-assets/mono"; do + if [ -x "$cand/bin/mono" ]; then MONO_SRC="$cand"; break; fi +done +if [ -n "$MONO_SRC" ]; then + echo "[mono] 使用依赖库 mono: $MONO_SRC" + mkdir -p "$ENGINE_MONO" + for d in bin etc lib x86_64-unknown-linux-gnu; do + [ -d "$MONO_SRC/$d" ] || continue + mkdir -p "$ENGINE_MONO/$d" + cp -a "$MONO_SRC/$d/." "$ENGINE_MONO/$d/" + done + chmod +x "$ENGINE_MONO"/bin/* 2>/dev/null || true + set_env UE_USE_SYSTEM_MONO 0 +elif [ -x "$ENGINE_MONO/bin/mono" ]; then + echo "[mono] 使用引擎自带 mono" + set_env UE_USE_SYSTEM_MONO 0 +else + echo "::warning::依赖库与引擎都没有可用 mono,暂时回落系统 mono(待 dependencies_u 收录)" + set_env UE_USE_SYSTEM_MONO 1 +fi + +# --------------------------------------------------------------------------- +echo "== 2/9 编译器包装:顶替引擎 clang/clang++ ==" +make_wrapper() { + name="$1" + real="$UE4_BIN/${name}.real" + if [ ! -f "$real" ]; then + cp -f "$(readlink -f "$UE4_BIN/$name")" "$real" + chmod +x "$real" + fi + cat > "$UE4_BIN/$name" < "\$g" + args+=("@\$g") + else + args+=("\$a") + fi ;; + *) args+=("\$a") ;; + esac +done +link=1 +for a in "\${args[@]}"; do + case "\$a" in + -c|-E|-S|-M|-MM|-MMD|-MD) link=0 ;; + esac +done +[ "\$link" = 1 ] && args+=("-fuse-ld=lld") +exec -a "$name" "$real" "\${args[@]}" +EOF + chmod +x "$UE4_BIN/$name" +} +for c in clang clang++; do + if grep -q 'hutb-ci wrapper v3' "$UE4_BIN/$c" 2>/dev/null; then + echo "[wrap] $c 已是 CI 包装,跳过" + else + make_wrapper "$c" + echo "[wrap] $c 已替换为包装" + fi +done +"$UE4_BIN/clang++" --version | head -1 + +# --------------------------------------------------------------------------- +echo "== 3/9 Setup.sh:libc++ / sysroot 指向 UE4 自带版本 ==" +python3 - Util/BuildTools/Setup.sh <<'PY' +import io +p = 'Util/BuildTools/Setup.sh' +s = io.open(p, encoding='utf-8').read() +anchor = 'export LDFLAGS="-stdlib=libc++"' +inc = (anchor + '\n' + '# [hutb-ci] libc++/sysroot 指向 UE4 自带版本(本版本没有 unset,只能显式补)\n' + 'export LLVM_INCLUDE="${UE4_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1"\n' + 'export LLVM_LIBPATH="${UE4_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu"\n' + 'export UNREAL_HOSTED_CFLAGS="--sysroot=${UE4_ROOT}/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu"\n' + '# [hutb-ci] 全局 CXXFLAGS/LDFLAGS 补上 libc++ 头与 sysroot;否则 patchelf 等 autotools 构建会退到系统 libc++18\n' + '# 注意:LDFLAGS 不能带 --sysroot,否则 libpng 之类 C 库找不到系统的 zlib\n' + 'export CXXFLAGS="${CXXFLAGS} -isystem ${LLVM_INCLUDE} -L${LLVM_LIBPATH} ${UNREAL_HOSTED_CFLAGS}"\n' + 'export LDFLAGS="${LDFLAGS} -L${LLVM_LIBPATH} -lpthread"') +if '[hutb-ci] libc++/sysroot' in s: + print('libc++/sysroot 已就绪,跳过') +elif anchor in s: + io.open(p, 'w', encoding='utf-8').write(s.replace(anchor, inc, 1)) + print('Setup.sh 已注入 LLVM_INCLUDE / LLVM_LIBPATH / sysroot') +else: + print('警告:Setup.sh 的 LDFLAGS 锚点未命中') +PY + +# Recast 的 cmake 行写死了 -stdlib=libc++ 但没给头文件/sysroot; +# 24.04 系统 libc++ 是 18 版,clang10 编不过,必须显式指向 UE4 自带的 libc++10 +python3 - Util/BuildTools/Setup.sh <<'PY' +import io +p = 'Util/BuildTools/Setup.sh' +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] recast' in s: + print('Recast libc++ 参数已存在,跳过') +else: + old = '-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -fPIC"' + new = ('-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -fPIC ' # [hutb-ci] recast + '-isystem %s/include/c++/v1 ' + '-L%s/lib/Linux/x86_64-unknown-linux-gnu ' + '--sysroot=%s/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/' + 'v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu -lpthread"' + % ('${UE4_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx', + '${UE4_ROOT}/Engine/Source/ThirdParty/Linux/LibCxx', + '${UE4_ROOT}')) + if old in s: + io.open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1)) + print('Recast libc++/sysroot 参数已写入') + else: + print('警告:Recast cmake 锚点未命中') +PY + +# xerces 的 server 变体单独写死了 libc++ 参数、没有带 LLVM_INCLUDE,24.04 上会退到系统 libc++18 +python3 - Util/BuildTools/Setup.sh <<'PY' +import io +p = 'Util/BuildTools/Setup.sh' +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] xerces-server' in s: + print('xerces server libc++ 参数已存在,跳过') +else: + old = '-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -fPIC -w"' + new = ('-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -fPIC -w ' # [hutb-ci] xerces-server + '-I${LLVM_INCLUDE} -L${LLVM_LIBPATH} ${UNREAL_HOSTED_CFLAGS} -lpthread"') + old_ld = '-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++ -lc++abi"' + new_ld = ('-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++ -lc++abi -L${LLVM_LIBPATH} ' + '${UNREAL_HOSTED_CFLAGS} -lpthread"') + if old in s: + s = s.replace(old, new, 1) + s = s.replace(old_ld, new_ld, 1) + io.open(p, 'w', encoding='utf-8').write(s) + print('xerces server libc++ 参数已写入') + else: + print('警告:xerces server cmake 锚点未命中') +PY + +# proj 7.2.1 的源码没有显式 include ,20.04 上靠 libstdc++ 的间接包含能过; +# 24.04 的 libstdc++13 不再间接带出 std::int64_t,clang10 直接报 "no type named int64_t" +python3 - Util/BuildTools/Setup.sh <<'PY' +import io +p = 'Util/BuildTools/Setup.sh' +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] proj' in s: + print('proj cstdint 参数已存在,跳过') +else: + old_client = ('-DCMAKE_CXX_FLAGS="-std=c++14 -fPIC" \\\n' + ' -DSQLITE3_INCLUDE_DIR') + new_client = ('-DCMAKE_CXX_FLAGS="-std=c++14 -fPIC -include cstdint" \\\n' # [hutb-ci] proj + ' -DSQLITE3_INCLUDE_DIR') + old_server = '-DCMAKE_CXX_FLAGS="-std=c++14 -fPIC -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH}"' + new_server = ('-DCMAKE_CXX_FLAGS="-std=c++14 -fPIC -stdlib=libc++ -I${LLVM_INCLUDE} ' + '-L${LLVM_LIBPATH} ${UNREAL_HOSTED_CFLAGS} -lpthread -include cstdint"') + ok = False + if old_client in s: + s = s.replace(old_client, new_client, 1) + ok = True + if old_server in s: + s = s.replace(old_server, new_server, 1) + ok = True + if ok: + io.open(p, 'w', encoding='utf-8').write(s) + print('proj 编译参数已写入') + else: + print('警告:proj cmake 锚点未命中') +PY + +# --------------------------------------------------------------------------- +echo "== 4/9 BuildPythonAPI.sh:CC/CXX 指向引擎 clang ==" +API_SH=Util/BuildTools/BuildPythonAPI.sh +grep -q "$UE4_BIN/clang" "$API_SH" || \ + sed -i "s|^export CC=.*|export CC=\"$UE4_BIN/clang\"|; s|^export CXX=.*|export CXX=\"$UE4_BIN/clang++\"|" "$API_SH" +grep -n 'export CC=\|export CXX=' "$API_SH" | head -2 + +# --------------------------------------------------------------------------- +echo "== 5/9 BuildUE4Plugins.sh:Content 守卫 / MavLinkTest / AirSim 工具链 ==" +python3 - Util/BuildTools/BuildUE4Plugins.sh <<'PY' +import io +p = 'Util/BuildTools/BuildUE4Plugins.sh' +lines = io.open(p, encoding='utf-8').read().split('\n') +if any('已存在但无 .git' in l for l in lines): + print('Content 保护已存在,跳过') +else: + out, i, patched = [], 0, False + while i < len(lines): + out.append(lines[i]) + if 'Content directory already exists' in lines[i]: + j, block = i + 1, [] + while j < len(lines) and lines[j].strip() and ( + lines[j].strip().startswith('cd ') or + lines[j].strip().startswith('git ')): + block.append(lines[j]); j += 1 + if block: + out.append(' if [ "${HUTB_CONTENT_CACHE:-0}" = "1" ]; then') + out.append(' echo " [hutb-ci] 使用 Content 缓存,跳过 git pull"') + out.append(' elif [ -d "$CONTENT_PATH/.git" ]; then') + out.extend(block) + out.append(' else') + out.append(' echo " [hutb-ci] Content 已存在但无 .git,跳过 git 拉取"') + out.append(' fi') + patched = True + i = j + continue + i += 1 + io.open(p, 'w', encoding='utf-8').write('\n'.join(out)) + print('Content 保护插入成功' if patched else '警告:未找到 Content 分支,未打补丁') +PY + +python3 - Util/BuildTools/BuildUE4Plugins.sh <<'PY' +import io +p = 'Util/BuildTools/BuildUE4Plugins.sh' +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] MavLinkTest' in s: + print('MavLinkTest 禁用已存在,跳过') +else: + inject = ('sed -i \'s|^add_subdirectory("MavLinkTest")|# [hutb-ci] MavLinkTest 已禁用|\' ' + '"$AIR_BUILD_PATH/cmake/MavLinkCom/CMakeLists.txt" || true\n ./build.sh') + if './build.sh' in s: + io.open(p, 'w', encoding='utf-8').write(s.replace('./build.sh', inject, 1)) + print('MavLinkTest 禁用已注入') + else: + print('警告:未找到 ./build.sh 锚点') +PY + +python3 - Util/BuildTools/BuildUE4Plugins.sh <<'PY' +import io, os +p = 'Util/BuildTools/BuildUE4Plugins.sh' +ue4 = os.environ['UE4_ROOT'] +sdk = ue4 + '/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu' +lines = io.open(p, encoding='utf-8').read().split('\n') +if any('hutb-ci airsim toolchain' in l for l in lines): + print('AirSim 工具链补丁已存在,跳过') +else: + idx = next((i for i, l in enumerate(lines) + if 'HTTP_PROXY' in l and './setup.sh' in l), None) + if idx is None: + print('警告:未找到 setup.sh 调用行') + else: + block = [ + ' # [hutb-ci airsim toolchain] AirSim 默认用 g++/libstdc++,与 UE4 插件 libc++ 的 ABI 不兼容', + ' UE4_BIN=%s/bin' % sdk, + ' UE4_INC=%s/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1' % ue4, + ' UE4_LIB=%s/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu' % ue4, + ' UE4_SDK=%s' % sdk, + ' sed -i -e "s|^export CC=.*|export CC=\\"$UE4_BIN/clang\\"|" -e "s|^export CXX=.*|export CXX=\\"$UE4_BIN/clang++\\"|" setup.sh', + ' sed -i "s|export CC=.*|export CC=\\"$UE4_BIN/clang\\"|g; s|export CXX=.*|export CXX=\\"$UE4_BIN/clang++\\"|g" build.sh', + ' export CFLAGS="-stdlib=libc++ -isystem $UE4_INC --sysroot=$UE4_SDK"', + ' export CXXFLAGS="-stdlib=libc++ -isystem $UE4_INC --sysroot=$UE4_SDK"', + ' export LDFLAGS="-stdlib=libc++ -L$UE4_LIB --sysroot=$UE4_SDK"', + ] + lines[idx:idx] = block + io.open(p, 'w', encoding='utf-8').write('\n'.join(lines)) + print('AirSim 工具链补丁已注入(第 %d 行前)' % (idx + 1)) +PY + +# --------------------------------------------------------------------------- +echo "== 6/9 LibCarla:CI 不需要单测(预编译 gtest 依赖新版 glibc) ==" +sed -i 's/-DLIBCARLA_BUILD_TEST=ON/-DLIBCARLA_BUILD_TEST=OFF/' Util/BuildTools/BuildLibCarla.sh || true +sed -i 's/^if ((LIBCARLA_BUILD_TEST)/if (FALSE AND (LIBCARLA_BUILD_TEST)/' LibCarla/cmake/CMakeLists.txt || true + +# --------------------------------------------------------------------------- +echo "== 7/9 osm2odr:改用 UE4 clang + libc++ + sysroot ==" +python3 - Util/BuildTools/BuildOSM2ODR.sh <<'PY' +import io, os +p = 'Util/BuildTools/BuildOSM2ODR.sh' +ue4 = os.environ['UE4_ROOT'] +bin_ = ue4 + '/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin' +sdk = ue4 + '/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu' +inc = ue4 + '/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1' +lib = ue4 + '/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu' +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] osm2odr' in s: + print('osm2odr 补丁已存在,跳过') +else: + s = s.replace('export CC=/usr/bin/clang', 'export CC=%s/clang' % bin_) + s = s.replace('export CXX=/usr/bin/clang++', 'export CXX=%s/clang++' % bin_) + s = s.replace('export PATH=/usr/bin:/bin:$PATH', 'export PATH=%s:/usr/bin:/bin:$PATH' % bin_) + s = s.replace('-DCMAKE_C_COMPILER=/usr/bin/clang', '-DCMAKE_C_COMPILER=%s/clang' % bin_) + s = s.replace('-DCMAKE_CXX_COMPILER=/usr/bin/clang++', '-DCMAKE_CXX_COMPILER=%s/clang++' % bin_) + s = s.replace('unset LLVM_INCLUDE', 'export LLVM_INCLUDE=%s' % inc) + s = s.replace('unset LLVM_LIBPATH', 'export LLVM_LIBPATH=%s' % lib) + s = s.replace('export CXXFLAGS="-std=c++11 -stdlib=libstdc++"', + 'export CXXFLAGS="-std=c++11 -stdlib=libc++ -isystem %s --sysroot=%s" # [hutb-ci] osm2odr' % (inc, sdk)) + s = s.replace('export LDFLAGS="-stdlib=libstdc++"', + 'export LDFLAGS="-stdlib=libc++ -L%s --sysroot=%s"' % (lib, sdk)) + s = s.replace('-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++"', + '-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -isystem %s --sysroot=%s"' % (inc, sdk)) + io.open(p, 'w', encoding='utf-8').write(s) + print('osm2odr 补丁已写入') +PY + +# --------------------------------------------------------------------------- +echo "== 8/9 AirSim.Build.cs:去掉重复的 librpc.a ==" +patch_airsim_buildcs + +# --------------------------------------------------------------------------- +echo "== 9/9 Check.sh:无头环境用 -opengl + 等待 RPC 就绪 ==" +if [ -f Util/BuildTools/Check.sh ] && ! grep -q -- '-RenderOffscreen -opengl' Util/BuildTools/Check.sh; then + sed -i 's|-RenderOffscreen --carla-rpc-port=3654|-RenderOffscreen -opengl --carla-rpc-port=3654|g' Util/BuildTools/Check.sh +fi +python3 - Util/BuildTools/Check.sh <<'PY' +import io, sys +p = sys.argv[1] +s = io.open(p, encoding='utf-8').read() +if '[hutb-ci] 等待 RPC' in s: + print('端口等待已存在,跳过') +else: + out, injected = [], False + for line in s.split('\n'): + out.append(line) + if (line.strip().startswith('nohup') + and 'carla-rpc-port=3654' in line): + out += [ + ' # [hutb-ci] 等待 RPC 端口就绪,避免第一个用例抢跑超时', + ' for _i in $(seq 1 90); do', + ' (echo >/dev/tcp/127.0.0.1/3654) 2>/dev/null && break', + ' sleep 2', + ' done', + ] + injected = True + if injected: + io.open(p, 'w', encoding='utf-8').write('\n'.join(out)) + print('端口等待已注入') + else: + print('警告:未找到模拟器启动行') +PY + +echo "[shim] 完成" diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 6b1acc8d1c..0e3721e831 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -1,8 +1,21 @@ name: hubt Linux CI/CD on: + push: + branches: [hutb] pull_request: workflow_dispatch: + inputs: + mode: + description: "fast=复用依赖增量构建;full=清空依赖与构建产物后重建(仅 24.04 job 使用)" + type: choice + options: [fast, full] + default: fast + upload: + description: "全部 check 通过后,是否上传发行包到腾讯工蜂大文件仓库" + type: choice + options: ["false", "true"] + default: "false" jobs: @@ -99,4 +112,166 @@ jobs: make check.upload shell: bash + # ---------------------------------------------------------------------- + linux-dev-2404: + name: Linux CI/CD (Ubuntu 24.04) + timeout-minutes: 1440 + runs-on: [self-hosted, ubuntu-hutb-2404] + env: + UE4_ROOT: /home/yxkj/UnrealEngine_4.26 + MODE: ${{ inputs.mode || 'fast' }} + UPLOAD: ${{ inputs.upload || 'false' }} + PY_VER: "3.10" + # wheel 链接用 UE4 自带 clang++ + ld.lld(旧 ld 读不了新版 glibc 的 .relr.dyn) + LDSHARED: "/home/yxkj/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++ -shared -fuse-ld=lld" + LDCXXSHARED: "/home/yxkj/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++ -shared -fuse-ld=lld" + LIBCARLA_INSTALL_SERVER_FOLDER: ${{ github.workspace }}/Unreal/CarlaUE4/Plugins/Carla/CarlaDependencies + LIBCARLA_INSTALL_CLIENT_FOLDER: ${{ github.workspace }}/PythonAPI/carla/dependencies + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Show files + run: | + pwd + uname -a + nproc; free -g | head -2; df -h "$GITHUB_WORKSPACE" | tail -1 + ls -al + + - name: 24.04 工具链适配 + run: bash .github/scripts/ci_2404_shim.sh + shell: bash + + - name: 依赖与资源(full 时清空重建) + run: | + set -e + if [ "$MODE" = "full" ]; then + echo "[full] 清空依赖与构建产物" + rm -rf Build/dependencies Build/AirSim Build/LibCarla Build/UE4Carla + rm -rf Build/*-source Build/*-src + rm -rf Unreal/CarlaUE4/Intermediate + rm -rf "$UE4_ROOT/Engine/Intermediate/Build/Linux/B4D820EA" + else + echo "[fast] 复用已有依赖与构建产物" + rm -rf Build/*-source Build/*-src 2>/dev/null || true + fi + # 如果这台 runner 上已经有共享 Content 缓存,直接复用,避免匿名拉腾讯私有仓库 404 + CI_CONTENT=/home/yxkj/ci-assets/Content + if [ -d "$CI_CONTENT/.git" ] && [ "$(readlink -f Unreal/CarlaUE4/Content 2>/dev/null)" != "$CI_CONTENT" ]; then + rm -rf Unreal/CarlaUE4/Content + ln -sfn "$CI_CONTENT" Unreal/CarlaUE4/Content + echo "Content -> $CI_CONTENT" + fi + shell: bash + + - name: setup + run: | + set -o pipefail + # 24.04 上不 source setEnv64.sh:里面写死了 /home/ubuntu 的 UE4_ROOT, + # 路径统一由 workflow env 提供 + git update-index --skip-worktree Unreal/CarlaUE4/CarlaUE4.uproject || true + ./setup.sh 2>&1 | tee /tmp/ci_setup_sh.log + make setup ARGS="--chrono" 2>&1 | tee /tmp/ci_setup.log + shell: bash + + # AirSim 由 setup.sh 克隆,此时目录才存在,补上 AirSim.Build.cs 的去重补丁 + - name: AirSim 适配(setup 之后) + run: bash .github/scripts/ci_2404_shim.sh --after-setup + shell: bash + + # make plugins 不执行:仓库里的 Plugins.sh 未 source Environment.sh,log 未定义必然失败; + # 其功能已由 make setup 的 downloadplugins 覆盖 + - name: retrieve content + run: | + set -o pipefail + if [ -x Update.sh ]; then ./Update.sh 2>&1 | tee /tmp/ci_update.log; else echo "无 Update.sh,跳过"; fi + shell: bash + + # 与 20.04 的 "Fix Windows Compiler Flags and Clean Cache" 对应: + # /wd4103 由 shim 里的 clang 包装丢弃,这里只清引擎中间缓存。 + # 不删除 UnrealBuildTool.exe:这台引擎上 GenerateProjectFiles 的产物只落在 obj/ 下, + # 不会回填 Binaries/DotNET,删除后 UBT 直接不可用。 + - name: 清理引擎中间缓存 + run: | + set -e + rm -rf "$UE4_ROOT/Engine/Intermediate/Build/Linux/B4D820EA" + rm -rf "$GITHUB_WORKSPACE/Unreal/CarlaUE4/Intermediate" + if [ ! -f "$UE4_ROOT/Engine/Binaries/DotNET/UnrealBuildTool.exe" ]; then + UBT_OBJ="$UE4_ROOT/Engine/Source/Programs/UnrealBuildTool/obj/Development/UnrealBuildTool.exe" + [ -f "$UBT_OBJ" ] && cp -f "$UBT_OBJ" "$UE4_ROOT/Engine/Binaries/DotNET/" + fi + df -h "$GITHUB_WORKSPACE" | tail -1 + shell: bash + + - name: CarlaUE4Editor + run: | + set -o pipefail + # osm2odr 需要 zlib 头;用了 UE4 sysroot 后系统 /usr/include 不可见,单独拷一份用 CPATH 注入 + mkdir -p Build/zlib-include + cp -f /usr/include/zlib.h /usr/include/zconf.h Build/zlib-include/ 2>/dev/null || true + export CPATH="$PWD/Build/zlib-include${CPATH:+:$CPATH}" + rm -rf Build/LibCarla Build/LibCppToolChain.cmake + make CarlaUE4Editor ARGS="--chrono" 2>&1 | tee /tmp/ci_editor.log + shell: bash + + - name: 构建 PythonAPI wheel + run: | + set -o pipefail + make PythonAPI.wheel ARGS="--python-version=${PY_VER}" 2>&1 | tee /tmp/ci_wheel.log + ls -lh PythonAPI/carla/dist/ + shell: bash + + - name: package + run: | + set -o pipefail + # Shipping 编译拆 Unity 后很吃内存,限 6 核防 OOM;只有要上传时才生成压缩包 + if [ "$UPLOAD" = "true" ]; then + taskset -c 0-5 make package ARGS="--chrono" 2>&1 | tee /tmp/ci_package.log + else + taskset -c 0-5 bash Util/BuildTools/Package.sh --no-zip 2>&1 | tee /tmp/ci_package.log + fi + shell: bash + + - name: check + run: | + set -o pipefail + cleanup_sim() { + pkill -f "CarlaUE4-Linux-Shipping" 2>/dev/null || true + sleep 2 + fuser -k 2000/tcp 3654/tcp 2>/dev/null || true + sleep 1 + } + cleanup_sim + make check.PythonAPI ARGS="--python-version=${PY_VER}" 2>&1 | tee /tmp/ci_check_pythonapi.log + cleanup_sim + make check.smoke ARGS="--python-version=${PY_VER}" 2>&1 | tee /tmp/ci_check_smoke.log + cleanup_sim + make check.vr ARGS="--python-version=${PY_VER}" 2>&1 | tee /tmp/ci_check_vr.log + cleanup_sim + make check.air ARGS="--python-version=${PY_VER}" 2>&1 | tee /tmp/ci_check_air.log + shell: bash + + # 上传默认关闭;打开时也只推 release_u(脚本暂不支持指定测试分支,见 PR 说明) + - name: upload + if: env.UPLOAD == 'true' + run: | + set -o pipefail + ls -lh Build/UE4Carla/*.tar.gz Build/UE4Carla/*.zip 2>/dev/null || { + echo "Build/UE4Carla 下没有压缩包,UPLOAD=true 时打包必须带压缩"; exit 1; } + python3 -c "import git" 2>/dev/null || python3 -m pip install -q gitpython + ( cd Util && python3 ./download_from_git.py -u release ) 2>&1 | tee /tmp/ci_upload.log + shell: bash + + - name: 汇总产物 + if: always() + run: | + echo "==== 产物目录 ====" + ls -lh Build/UE4Carla/ | tail -5 || true + echo "==== wheel ====" + ls -lh PythonAPI/carla/dist/ || true + echo "==== 日志 ====" + ls -lh /tmp/ci_*.log 2>/dev/null || true + df -h "$GITHUB_WORKSPACE" | tail -1 + shell: bash