github: fix broken header check (#9800)

- Move header check from postsubmit to presubmit
 - Install third_party/getop if needed
 - Modify check-headers test to use system getopt when it's available.
This commit is contained in:
Powei Feng
2026-03-16 10:26:59 -07:00
committed by GitHub
parent 749b03ed2a
commit 2d1e4b8ce2
4 changed files with 54 additions and 32 deletions

View File

@@ -77,9 +77,6 @@ jobs:
with:
name: filament-mac
path: out/filament-release-darwin.tgz
- name: Check public headers
run: |
test/check-headers/test.sh out/release/filament/include
build-web:
name: build-web

View File

@@ -64,9 +64,15 @@ jobs:
- name: Run build script
run: |
cd build/mac && printf "y" | ./build.sh presubmit-with-test
- name: Test material parser
- name: Test - material parser
run: |
out/cmake-release/filament/test/test_material_parser
- name: Test - public headers
run: |
# out/cmake-release should have the artifacts ready for installation. Here we install it
# to test the public headers
ninja -C out/cmake-release install
test/check-headers/test.sh out/release/filament/include
build-desktop-linux:
name: build-linux

View File

@@ -53,6 +53,12 @@ for f in $(find . -name '*.h'); do
done
popd >/dev/null
# Check if the system has getopt
HAS_SYSTEM_GETOPT=0
if echo "#include <getopt.h>" | clang -x c++ -std=c++17 -E - > /dev/null 2>&1; then
HAS_SYSTEM_GETOPT=1
fi
rm -rf out/check-headers
mkdir -p out/check-headers
@@ -61,10 +67,17 @@ echo "Checking that public headers compile independently..."
for include in "${includes[@]}"; do
rm -f ${TMP_FILE}
echo "Checking ${include}"
if [[ "${include}" == "utils/Systrace.h" ]]; then
# A necessary define before we can include utils/Systrace.h
echo "#define SYSTRACE_TAG SYSTRACE_TAG_DISABLED" >> ${TMP_FILE}
fi
case "${include}" in
"utils/Systrace.h")
# A necessary define before we can include utils/Systrace.h
echo "#define SYSTRACE_TAG SYSTRACE_TAG_DISABLED" >> ${TMP_FILE}
;;
"utils/getopt.h")
if [[ $HAS_SYSTEM_GETOPT -eq 1 ]]; then
echo "#define HAS_SYSTEM_GETOPT 1" >> ${TMP_FILE}
fi
;;
esac
echo "#include <${include}>" >> ${TMP_FILE}
# Filament is built internally with C++20, but we maintain C++17 compatibility (for the time
# being) in our public headers to support projects on older toolchains.

View File

@@ -1,24 +1,30 @@
cmake_minimum_required(VERSION 3.10)
project(getopt)
set(TARGET getopt)
set(PUBLIC_HDR_DIR include)
# ==================================================================================================
# Sources and headers
# ==================================================================================================
set(PUBLIC_HDRS include/getopt/getopt.h)
set(PRIVATE_HDRS include/getopt/getopt.h)
set(SRCS
src/getopt.c
src/getopt_long.c)
# ==================================================================================================
# Include and target definitions
# ==================================================================================================
include_directories(${PUBLIC_HDR_DIR})
add_library(${TARGET} STATIC ${PRIVATE_HDRS} ${PUBLIC_HDRS} ${SRCS})
target_include_directories (${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
set_target_properties(${TARGET} PROPERTIES FOLDER ThirdParty)
cmake_minimum_required(VERSION 3.10)
project(getopt)
set(TARGET getopt)
set(PUBLIC_HDR_DIR include)
# ==================================================================================================
# Sources and headers
# ==================================================================================================
set(PUBLIC_HDRS include/getopt/getopt.h)
set(PRIVATE_HDRS include/getopt/getopt.h)
set(SRCS
src/getopt.c
src/getopt_long.c)
# ==================================================================================================
# Include and target definitions
# ==================================================================================================
include_directories(${PUBLIC_HDR_DIR})
add_library(${TARGET} STATIC ${PRIVATE_HDRS} ${PUBLIC_HDRS} ${SRCS})
target_include_directories (${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
set_target_properties(${TARGET} PROPERTIES FOLDER ThirdParty)
# ==================================================================================================
# Installation
# ==================================================================================================
install(TARGETS ${TARGET} ARCHIVE DESTINATION lib/${DIST_DIR})
install(DIRECTORY ${PUBLIC_HDR_DIR}/getopt DESTINATION include)