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

xmake watch命令无法递归检测子目录中文件变动 #5645

Closed
Sunrisepeak opened this issue Sep 22, 2024 · 6 comments
Closed

xmake watch命令无法递归检测子目录中文件变动 #5645

Sunrisepeak opened this issue Sep 22, 2024 · 6 comments
Labels
Milestone

Comments

@Sunrisepeak
Copy link

Xmake 版本

2.9.5

操作系统版本和架构

Ubuntu24.01

描述问题

无法递归检测所有子目录中文件变动

speak@speak-pc:~/test$ vim watch_test/dir1/dir2/t.text
speak@speak-pc:~/test$ mv watch_test/dir1/dir2/t.text  watch_test/dir1/dir2/t.txt
speak@speak-pc:~/test$ code watch_test/dir1/dir2/t.txt 
speak@speak-pc:~/test$ xmake watch -d  "watch_test"
watching watch_test/** ..
^C
speak@speak-pc:~/test$ tree watch_test/
watch_test/
└── dir1
    └── dir2
        └── t.txt

3 directories, 1 file

期待的结果

递归监听所有子目录中文件变动

工程配置

复现示例

speak@speak-pc:~/test$ tree watch_test/
watch_test/
└── dir1
    └── dir2
        └── t.txt

3 directories, 1 file

附加信息和错误日志

speak@speak-pc:~/test$ xmake watch -d "watch_test"
watching watch_test/** ..
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified

@Issues-translate-bot
Copy link

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


Title: xmake watch command cannot recursively detect file changes in subdirectories

Xmake version

2.9.5

Operating system version and architecture

Ubuntu24.01

Describe the problem

Unable to recursively detect file changes in all subdirectories

speak@speak-pc:~/test$ vim watch_test/dir1/dir2/t.text
speak@speak-pc:~/test$ mv watch_test/dir1/dir2/t.text watch_test/dir1/dir2/t.txt
speak@speak-pc:~/test$ code watch_test/dir1/dir2/t.txt
speak@speak-pc:~/test$ xmake watch -d "watch_test"
watching watch_test/** ..
^C
speak@speak-pc:~/test$ tree watch_test/
watch_test/
└── dir1
    └── dir2
        └── t.txt

3 directories, 1 file

Expected results

Recursively monitor file changes in all subdirectories

Project configuration

Reproduction example

speak@speak-pc:~/test$ tree watch_test/
watch_test/
└── dir1
    └── dir2
        └── t.txt

3 directories, 1 file

Additional information and error logs

speak@speak-pc:~/test$ xmake watch -d "watch_test"
watching watch_test/** ..
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified
watch_test/dir1/t.text modified

@Sunrisepeak
Copy link
Author

Sunrisepeak commented Sep 22, 2024

看了一下可能和依赖库tbox中的tb_fwatcher_add接口实现有关

  • 在xmake中 recursion 是 bool 类型标识
  • tbox中
    • tb_fwatcher_add 的recursion 是 bool 类型标识
    • tb_directory_walk 中是用recursion 用long来标识深度

可能的解决方法

    1. 简单的设置一个 默认的最大递归深度 5 or x
    1. 修改tb_fwatcher_add接口recursion 和 tb_directory_walk 对齐, 但属于API破坏式更新

不知道有没有支持递归多层子目录的想法, 如果比较忙这个工作我可以做

xmake-fwatcher

function sandbox_core_base_fwatcher.add(watchdir, opt)

function _instance:add(watchdir, opt)

// get recursion
tb_bool_t recursion = lua_toboolean(lua, 3);
// add watchdir
tb_bool_t ok = tb_fwatcher_add(fwatcher, watchdir, recursion);

tbox-fwatcher

image

tb_void_t tb_directory_walk(tb_char_t const* path, tb_long_t recursion, tb_bool_t prefix, tb_directory_walk_func_t func, tb_cpointer_t priv)

@Sunrisepeak
Copy link
Author

设置默认值的方式

tboox/tbox#266

@Issues-translate-bot
Copy link

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


How to set default values

tboox/tbox#266

@waruqi
Copy link
Member

waruqi commented Sep 22, 2024

更新了,再试试

@Issues-translate-bot
Copy link

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


Updated, try again

@waruqi waruqi added this to the v2.9.6 milestone Sep 22, 2024
@waruqi waruqi closed this as completed Sep 23, 2024
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