xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.19k stars 788 forks source link

rc文件依赖的头文件更新后不会重新编译rc #4342

Open RimuruChan opened 1 year ago

RimuruChan commented 1 year ago

Xmake 版本

xmake v2.8.3+HEAD.2b61611fb

操作系统版本和架构

Windows 11 22h2

描述问题

有一个RC文件

// Microsoft Visual C++ generated resource script.
//
#include "Resource.h"

#define APSTUDIO_READONLY_SYMBOLS
#include "ll/core/Version.h"
#include "winres.h"

#pragma code_page(65001)

VS_VERSION_INFO VERSIONINFO
FILEVERSION LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH
PRODUCTVERSION LL_VERSION_MAJOR, LL_VERSION_MINOR,LL_VERSION_PATCH
FILEFLAGSMASK 0x3fL
FILEFLAGS LL_FILE_VERSION_FLAG
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo" BEGIN
        BLOCK "080404b0" BEGIN
            VALUE "CompanyName", "LiteLDev"
            VALUE "FileDescription", "A light-weight plugin loader for Bedrock Dedicated Server"
            VALUE "FileVersion", LL_FILE_VERSION_STRING
            VALUE "InternalName", "LeviLamina.dll"
            VALUE "LegalCopyright", "Copyright (c) 2021-present LiteLDev. Distributed under LGPL-3.0."
            VALUE "OriginalFilename", "LeviLamina.dll"
            VALUE "ProductName", "LeviLamina for BDS"
            VALUE "ProductVersion", LL_FILE_VERSION_STRING
        END
    END
    BLOCK "VarFileInfo" BEGIN
        VALUE "Translation", 0x804, 1200
    END
END

里面导入了 Version.h,但是Version.h更新后,rc文件没有重新编译,而是继续使用缓存。

期待的结果

rc文件应当重新编译

工程配置

add_rules("mode.debug", "mode.release")

if not has_config("vs_runtime") then
    set_runtimes("MD")
end

target("LeviLamina")
    set_license("LGPL-3")
    set_kind("shared")
    set_languages("c++20")
    set_symbols("debug")
    set_exceptions("none")
    set_pcxxheader("src/ll/api/base/Global.h")
    set_configdir("$(buildir)/config")
    add_configfiles("src/(**.in)")
    set_configvar("LL_WORKSPACE_FOLDER", "$(projectdir)")
    add_headerfiles("src/(**.h)")
    add_includedirs("./src", "$(buildir)/config")
    add_files("src/**.cpp","src/**.rc")

    on_load(function (target)
        local tag = os.iorun("git describe --tags --abbrev=0 --always")
        local major, minor, patch, suffix = tag:match("v(%d+)%.(%d+)%.(%d+)(.*)")
        if not major then
            print("Failed to parse version tag, using 0.0.0")
            major, minor, patch = 0, 0, 0
        end
        if suffix then
            prerelease = suffix:match("-(.*)")
            if prerelease then
                prerelease = prerelease:gsub("\n", "")
            end
            if prerelease then
                target:set("configvar", "LL_VERSION_PRERELEASE", prerelease)
            end
        end
        target:set("configvar", "LL_VERSION_MAJOR", major)
        target:set("configvar", "LL_VERSION_MINOR", minor)
        target:set("configvar", "LL_VERSION_PATCH", patch)
    end)

附加信息和错误日志

Issues-translate-bot commented 1 year ago

Bot detected the issue body's language is not English, translate it automatically.


Title: The header files that the rc file depends on will not be recompiled after updating.

waruqi commented 1 year ago

rc.exe 本身不提供头文件依赖解析支持,目前只有通过 cl.exe 的预处理器变相支持,不一定 100% 精准,你可以自己调下下面的 逻辑,看下头文件路径是否正常提取到

https://github.com/xmake-io/xmake/blob/867565453df03c966ecb8fd07a71be47e3fdd7f3/xmake/modules/core/tools/rc.lua#L127-L157

RimuruChan commented 1 year ago

一会有空看看

Issues-translate-bot commented 1 year ago

Bot detected the issue body's language is not English, translate it automatically.


I'll take a look when I have time