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

临时文件路径和日期相关导致每天必然会重新编译 #3321

Closed
q962 opened this issue Jan 30, 2023 · 2 comments
Closed

临时文件路径和日期相关导致每天必然会重新编译 #3321

q962 opened this issue Jan 30, 2023 · 2 comments
Labels
Milestone

Comments

@q962
Copy link

q962 commented Jan 30, 2023

Xmake 版本

2.7.6

操作系统版本和架构

Linux fedora 6.1.6-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jan 14 16:55:06 UTC 2023 x86_64 GNU/Linux

描述问题

$ cat /home/demo/project/demo/xmake_build_test/a/.xmake/linux/x86_64/tmp/230206/_E2BB99FB47614
29EB2F157B92513DE30                                                                           
{                                                                                             
    files = {                                                                                 
        "src/config.h.in"                                                                     
    }                                                                                         
}%                                                                                            

记录了依赖文件,但是修改时间后(过了一天)

dependfile: /home/demo/project/demo/xmake_build_test/a/.xmake/linux/x86_64/tmp/230207/_E2BB99F
B4761429EB2F157B92513DE30                                                                     
dependinfo { }                                                                                

可见,将要读取的临时文件并不存在,因为路径拼接根据时间而发生了变化。

tmpdir = path.join(tmpdir_root, os.date("%y%m%d"))

return path.join(project.tmpdir(opt), "_" .. (hash.uuid4(key):gsub("-", "")))

dependinfo 会被传递到这里

if not is_changed(dependinfo, {lastmtime = opt.lastmtime or os.mtime(dependfile), values = opt.values, files = opt.files}) then
return
end
-- do callback if changed and maybe files and values will be updated
dependinfo = callback() or {}

local files = table.wrap(dependinfo.files)
local values = table.wrap(dependinfo.values)
if #files == 0 and #values == 0 then
return true
end

期待的结果

移除日期?

工程配置

No response

附加信息和错误日志

No response

@q962 q962 added the bug label Jan 30, 2023
@q962 q962 changed the title 临时文件路径和时间相关导致每天必然会重新编译 临时文件路径和日期相关导致每天必然会重新编译 Jan 30, 2023
waruqi added a commit that referenced this issue Jan 30, 2023
@waruqi
Copy link
Member

waruqi commented Jan 30, 2023

日期是不能移的,tmpdir 设置按天分离,便于定期清理,每天首次运行 后台进程会清理一次前天的临时文件,避免磁盘空间越占越多。。

根本问题是 depend.on_changed 在 configfiles 生成里面,我没加 dependfile 设置,所以默认用了 tmpfile 作为 dependfile

dependfile = project.tmpfile(table.concat(table.wrap(opt.files), ""))

只要外面设置上固定 dependfile 路径,避免走到 tmpfile 就行了。。

我改进了下,再试试,xmake update -s dev

@waruqi waruqi added this to the v2.7.7 milestone Jan 30, 2023
@q962
Copy link
Author

q962 commented Jan 30, 2023

使用修改时间的方式验证,已经没有重新编译的问题了。

@q962 q962 closed this as completed Jan 30, 2023
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

2 participants