Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,21 @@ jobs:
printf 'package "main"\nfunction init() return 0 end\nfunction fini() return 0 end\n' > test.lua
./bin/flua test.lua --once
cd "$GITHUB_WORKSPACE"
# Only this repo's sources. Uploading Boost/CPM/usr headers makes Codecov
# drop file-level reports because paths cannot be matched to GitHub.
# Host sources + optional GCC JIT temps. --no-external drops /usr and CPM.
# Fl* runtime arcs are #line-mapped onto src/compile/c_runtime_cov.h
# (checked-in view header); extract src/* covers that. build/jit_cov/*
# kept as a safety net for any residual temp-.c hits (preamble).
# #line→.lua remaps stay excluded. inconsistent: Lua #line end-line
# checks + some host TU gcov noise.
lcov --directory build --capture --output-file coverage.info \
--base-directory "$GITHUB_WORKSPACE" --no-external \
--ignore-errors source,mismatch
--ignore-errors source,mismatch,inconsistent
lcov --extract coverage.info \
"$GITHUB_WORKSPACE/src/*" \
"$GITHUB_WORKSPACE/include/*" \
--output-file coverage.info
"$GITHUB_WORKSPACE/build/jit_cov/*" \
--output-file coverage.info \
--ignore-errors unused,inconsistent
ls -l coverage.info
lcov --list coverage.info

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cd ..
cd ..
cppcheck --version
FILES=`find src/ cmd/ -type f -name "*.cpp" -o -name "*.h"|grep -v parser|grep -v scanner|grep -v third_party`
FILES=`find src/ cmd/ -type f -name "*.cpp" -o -name "*.h"|grep -v parser|grep -v scanner|grep -v third_party|grep -v c_runtime_cov.h`
cppcheck --language=c++ --check-level=exhaustive --max-ctu-depth=64 -j8 $FILES 2> err.txt
cat err.txt
if [[ -s err.txt ]]
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ if (WIN32)
target_link_options(fakelua PRIVATE "-Wl,--export-all-symbols" "-Wl,--exclude-libs,ALL")
endif ()

# When USE_COV is on, expose it to C++ so the GCC JIT path can instrument emitted C
# (host CXXFLAGS alone do not affect the forked `gcc` argv for temp .c → .so).
# FAKELUA_JIT_COV_DIR places JIT temps + .gcno/.gcda under the build tree for lcov.
if (USE_COV)
target_compile_definitions(fakelua PRIVATE USE_COV=1)
target_compile_definitions(fakelua PRIVATE "FAKELUA_JIT_COV_DIR=\"${CMAKE_BINARY_DIR}/jit_cov\"")
endif ()

find_package(Threads REQUIRED)

if (WIN32)
Expand Down
10 changes: 10 additions & 0 deletions src/compile/c_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,17 @@ void CGen::GenerateHeader() {

// C 运行时类型定义、宏 and 函数(从 c_runtime_header.h 提取,便于独立维护)
Out() << "static const char * const fl_lua_file = \"" << EscapeCStringLiteral(file_name_) << "\";\n";

// Attribute the pasted Fl* runtime to the checked-in view header so USE_COV
// gcov → lcov → Codecov can display hits on a real repo path (not
// build/jit_cov/fakelua_jit_*.c). Preamble above (_S, heaps, fl_lua_file)
// stays on the temp .c. kCRuntimeHeader begins with '\n', so do not write a
// newline after #line — logical line 1 becomes "#include <math.h>", matching
// src/compile/c_runtime_cov.h. Reset afterward so per-TU spec boilerplate is
// not falsely mapped onto that header; Lua body #line directives still apply.
Out() << "#line 1 \"" << kCRuntimeCovPath << "\"";
Out() << kCRuntimeHeader;
Out() << "#line 1 \"<fakelua-generated>\"\n";

// 前置发射所有 spec 类型的 typedef + 特化 get/set 函数(读取 TypeInferencer 预计算的
// ir.spec_type_metadata)。CGen 不再在 CompileTableconstructor 里懒发射这些样板代码。
Expand Down
Loading
Loading