From 042362f4c3f1dab8b6b5a32fcbbae20e66e224de Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 26 Jan 2024 23:11:48 +0800 Subject: fix preprocessor output --- xmake/modules/private/cache/build_cache.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index 91bdb20e5..5c5f9d0a6 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -292,6 +292,8 @@ function build(program, argv, opt) _g.cache_hit_total_time = (_g.cache_hit_total_time or 0) + (os.mclock() - cache_hit_start_time) else -- do compile + local preprocess_outdata = cppinfo.outdata + local preprocess_errdata = cppinfo.errdata local compile_start_time = os.mclock() local compile_fallback = opt.compile_fallback if compile_fallback then @@ -307,6 +309,13 @@ function build(program, argv, opt) else compile(program, cppinfo, opt) end + -- if no compiler output, we need use preprocessor output, because it maybe contains warning output + if not cppinfo.outdata or #cppinfo.outdata == 0 then + cppinfo.outdata = preprocess_outdata + end + if not cppinfo.errdata or #cppinfo.errdata == 0 then + cppinfo.errdata = preprocess_errdata + end _g.compile_total_time = (_g.compile_total_time or 0) + (os.mclock() - compile_start_time) if cachekey then local extrainfo -- cgit v1.3.1