Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

头文件的修改没有检测到,是我的用法不对吗? #786

Closed
asasdwtj opened this issue May 14, 2020 · 5 comments
Closed

头文件的修改没有检测到,是我的用法不对吗? #786

asasdwtj opened this issue May 14, 2020 · 5 comments
Labels
Milestone

Comments

@asasdwtj
Copy link

描述问题

工程结构:

src/
  bug.cpp
  bug.hpp
  main.cpp
xmake.lua

文件内容:
src/main.cpp

#include "bug.hpp"

int main()
{
	bug_func();
}

src/bug.hpp

#pragma once
void bug_func();

src/bug.cpp

#include <iostream>
#include "bug.hpp"

void bug_func()
{
	std::cout << "bug" << std::endl;
}

xmake.lua

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

target("bug_test")
    set_languages("c++17")

    set_kind("binary")

    -- 源文件
    add_includedirs("src")
    add_files("src/**.cpp")

期待的结果

先执行xmake命令,build成功,然后把bug.hpp的内容全部删除,再执行xmake

期待的结果是build失败

相关环境

configure
{
    arch = x64
    ccache = true
    ld = link.exe
    mode = release
    plat = windows
    host = windows
    ndk_stdcxx = true
    kind = static
    buildir = build
    vs = 2017
    cxx = cl.exe
}
@x1244
Copy link
Contributor

x1244 commented May 14, 2020

我理解,第一次编译成功后,会有缓存,如果只是简单删除bug.hpp,因为缓存的存在,不会报错。
运行如下命令

xmake build --rebuild

因为要重新编译,肯定会报错,可以试试。
如果删除了build文件夹,再xmake也会报错的,因为没有缓存了。
其实好多时候,如果修改了一些文件,还是编译不过,可以试试xmake build --rebuild
如果你不是删除bug.hpp,而是注释//void bug_func();后保存,也会报错的,因为头文件的时间戳变了,会自动检测到,并重新编译的。

@waruqi
Copy link
Member

waruqi commented May 14, 2020

我修复了,win可以 从 https://ci.appveyor.com/api/buildjobs/kos8mst19pn3e6sy/artifacts/xmake-installer.exe 这个包重装下 dev版本试试

linux/mac下 请执行 xmake update dev 更新

@waruqi waruqi added the bug label May 14, 2020
@waruqi waruqi added this to the v2.3.4 milestone May 14, 2020
@asasdwtj
Copy link
Author

用了新下的包,bug还是存在,但是我在另一台机器上,用2.3.3 release版本也没有这个bug。
这两台机器只是vs的版本不同

@waruqi
Copy link
Member

waruqi commented May 18, 2020

我这边测试 完全按照你的方式操作,linux/win/mac下都测试正常,请确认是否真的更新到了最新dev包

@waruqi
Copy link
Member

waruqi commented Jun 1, 2020

目前我这边测试都正常,如果你这还是有问题,可以尝试自己调试下:https://github.com/xmake-io/xmake/blob/master/xmake/modules/core/project/depend.lua

@waruqi waruqi closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants