xmake-io / xmake

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

添加includes从环境变量包含路径的功能 #5664

Closed Zmmfly closed 2 days ago

Zmmfly commented 3 days ago

你在什么场景下需要该功能?

使用 xmake 制作 SDK,需要将SDK与工程分离,并且需要避免使用git submodule的场景

描述可能的解决方案

目录结构:

C:.
├─app
│      main.c
│      xmake.lua
│
└─foo
        foo.c
        foo.h
        xmake.lua

app/xmake.lua 内容:

includes("@env:SDK_PATH")

target("app")
    set_kind("binary")
    add_files("main.c")
    add_deps("foo")

描述你认为的候选方案

includes("@env:SDK_PATH")

fork中已实现 https://github.com/Zmmfly/xmake/blob/f04be61e0ce31a83a3646f8a510e9dd0c2e2f60d/xmake/core/base/interpreter.lua#L1713-L1730

其他信息

No response

Issues-translate-bot commented 3 days ago

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


Title: Add includes functionality to include paths from environment variables

star-hengxing commented 3 days ago

有些工具链需要些一堆 xmake.lua ,而作为远程包又无法去 includes 这些。感觉这个接口还有扩展空间。 比如工程初始化前可以先执行 setup.lua 调用 xrepo install 安装工具链,然后 includes package:installdir

Issues-translate-bot commented 3 days ago

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


Some tool chains require a bunch of xmake.lua, but as a remote package, you cannot include these. It feels like this interface still has room for expansion. For example, before initializing the project, you can first execute setup.lua to call xrepo install to install the tool chain, and then include package:installdir

waruqi commented 3 days ago

原本就支持,用 os.getenv

includes(os.getenv("SDK_PATH"))
Issues-translate-bot commented 3 days ago

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


Originally supported, use os.getenv

includes(os.getenv("SDK_PATH"))
Zmmfly commented 2 days ago

原本就支持,用 os.getenv

includes(os.getenv("SDK_PATH"))

没想到这一点,看了内置变量后思维停留在 $(env SDK_PATH) 这种方法上,然后学着@builtin就变成了@env:SDK_PATH

Issues-translate-bot commented 2 days ago

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


Originally supported, use os.getenv

``lua includes(os.getenv("SDK_PATH"))

I didn't expect this. After looking at the built-in variables, my mind stayed on the method $(env SDK_PATH), and then I learned @builtin and became @env:SDK_PATH