xmake-io / xmake

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

xmake require -f 执行后没有强制重新拉取package #5428

Closed poemdistance closed 3 months ago

poemdistance commented 3 months ago

Xmake 版本

v2.9.4+20240729

操作系统版本和架构

Linux 6.10.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 27 Jul 2024 16:49:55 +0000 x86_64 GNU/Linux

描述问题

xmake更新后使用xmake require -f不会重新拉取最新package

期待的结果

重新拉取package

工程配置

package("season")
    set_urls("git@github.com:poemdistance/season.git")
    -- 测试阶段,依赖仓库经常根据需求添加修改代码,故暂时不指定版本
    on_install("macosx", "linux", function (package)
        os.cd("src")
        import("package.tools.xmake").install(package)
    end)
package_end()

附加信息和错误日志

checking for gcc ... /usr/bin/gcc
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
finding season from xmake ..
checking for xmake::season ... season @default
finding searoute from xmake ..
checking for xmake::searoute ... searoute @default
Issues-translate-bot commented 3 months ago

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


Title: xmake require -f does not force the package to be re-pulled after execution.

waruqi commented 3 months ago

因为你没配置版本,判断不了是否有更新

建议配置下版本,切到最新 commit

或者配置 package.always_install 的 policy 然后 on_install 里面自己 os.exec git pull 每次重拉下。

Issues-translate-bot commented 3 months ago

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


Because you haven’t configured the version, you can’t tell whether there is an update.

It is recommended to configure the next version and switch to the latest commit

Or configure the policy of package.always_install and then os.exec git pull in on_install and re-pull it every time.

poemdistance commented 3 months ago

因为你没配置版本,判断不了是否有更新

建议配置下版本,切到最新 commit

或者配置 package.always_install 的 policy 然后 on_install 里面自己 os.exec git pull 每次重拉下。

尝试了没有问题。

set_policy("package.install_always", true) 
on_install("macosx", "linux", function (package)
    os.exec("git pull")
    os.cd("src")
    import("package.tools.xmake").install(package)
end)

能不能做个命令行参数,能够自己手动控制什么时候重新拉取package,像之前xmake require -f就可以,新版xmake好像改逻辑了。 上面推荐的写法会导致每次都重新拉取一遍,拖慢了编译速度。

Issues-translate-bot commented 3 months ago

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


Because you have not configured the version, you cannot determine whether there is an update.

It is recommended to configure the next version and switch to the latest commit

Or configure the policy of package.always_install and then os.exec git pull in on_install and re-pull it every time.

Tried it with no problem.

set_policy("package.install_always", true)
on_install("macosx", "linux", function (package)
    os.exec("git pull")
    os.cd("src")
    import("package.tools.xmake").install(package)
end)

Can you make a command line parameter so that you can manually control when to pull the package again? Just like the previous xmake require -f, the new version of xmake seems to have changed the logic. The recommended writing method above will cause it to be pulled again every time, which slows down the compilation speed.

waruqi commented 3 months ago

能不能做个命令行参数,能够自己手动控制什么时候重新拉取package,像之前xmake require -f就可以,新版xmake好像改逻辑了。

set_policy("package.install_always", true) 等价于 xmake require -f ,不就已经有命令参数了么。它们都会强制触发重装,走 on_install 逻辑,但不会强制触发重新下载,git clone / git pull ,因为你没配置版本,版本没变化,即使走了重装,还是装的之前已经缓存的源码版本。。

xmake require -f 的语义仅仅只是强制重装,不会强制走 git pull,版本更新你得自己 add_version 配,要么自己 on_install 里面自己强拉

上面推荐的写法会导致每次都重新拉取一遍,拖慢了编译速度。

你去掉,set_policy("package.install_always", true) ,只在 on_install 里面保留 git pull 不就好了么。。不是可以的么

$ xmake require -f
note: install or modify (m) these packages (pass -y to skip confirm)?
  -> zlib v1.3.1 
please input: y (y/n/m)

on_install + git pull
on_install(function()
    print("on_install + git.pull")
    os.exec("git pull")
end)
poemdistance commented 3 months ago

在测试阶段经常修改代码,不太好加add_version。

你去掉,set_policy("package.install_always", true) ,只在 on_install 里面保留 git pull 不就好了么

这个试了,不行,依旧没有更新,xmake.lua内容及xmake require -f执行情况如下:

$ cat xmake.lua| head -n 15
-- xmake f --includedirs=`pkg-config --cflags gtk+-3.0 |sed 's/\-I//g' |tr ' ' ':'` -m debug --toolchain=gcc --ld=gcc

package("season")
    set_urls("git@github.com:poemdistance/season.git")

    -- add_versions("1.0", "bd6a110b1a062cbb02f453c2fe2992c0e8da5d75")
    -- set_policy("package.install_always", true)
    on_install("macosx", "linux", "windows", "mingw", function (package)
        os.exec("git pull")
        os.cd("src")
        import("package.tools.xmake").install(package)
    end)

package_end()

$ xmake require -fvD
checking for gcc ... /usr/bin/gcc
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
finding season from xmake ..
checking for xmake::season ... season @default
finding searoute from xmake ..
checking for xmake::searoute ... searoute @default
waruqi commented 3 months ago

不是可以的么。。得 xmake f -c 先清下缓存。。


$ xmake f -c; xmake require -f
checking for platform ... macosx
checking for architecture ... x86_64
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... Apple Development: waruqi@gmail.com (T3NA4MRVPU)
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.0
note: install or modify (m) these packages (pass -y to skip confirm)?
  -> zlib @default
please input: y (y/n/m)

  => clone https://github.com/madler/zlib.git @default .. ok
  => installing zlib .. (1/git) ⠦remote: Enumerating objects: 6249, done.
remote: Counting objects: 100% (6243/6243), done.
remote: Compressing objects: 100% (1574/1574), done.
remote: Total 6021 (delta 4617), reused 5771 (delta 4367), pack-reused 0
Receiving objects: 100% (6021/6021), 2.33 MiB | 3.88 MiB/s, done.
Resolving deltas: 100% (4617/4617), completed with 181 local objects.
From https://github.com/madler/zlib
 * branch            master     -> FETCH_HEAD
 * ```
poemdistance commented 3 months ago

确实是缓存导致的,问题解决了,非常感谢~

Issues-translate-bot commented 3 months ago

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


It is indeed caused by cache. The problem is solved. Thank you very much ~