Comments (2)
像print这种在外层仅仅只是为了个人调试,用来打印提示信息,请在自定义脚本中(这个里面是支持内建变量的)使用。。。
xmake.lua 描述文件为了使平常用户更加方便简洁的编写工程文件,将其分成两种模式:
- 外层描述作用域
- 内层自定义脚本作用域
外层描述作用域
仅通过 set_xxx
, add_xxx
这类简单的api进行工程描述,让xmake尽量看上去不依赖某种语言和语法,仅仅像是在修改配置。。
例如:
-- 外层作用域
target("xxx")
set_kind("static")
所以在外层描述作用域上,对很多lua的特性和接口都做了限制,灵活性上稍有欠缺,目的是为了大部分的工程描述,保持尽量的简洁可读。。
此作用域主要以描述为主,开放的其他api很有限(都是些readonly api,例如:print, os.getenv(), string, table ..),也仅仅只是为了控制描述逻辑,像print这种仅仅作为个人调试的辅助工具,尽量不要用来做为除调试以外的其他用途。。
内层自定义脚本作用域
此作用,就是在在定义脚本代码 function () end
中的作用域,例如:
-- 外层作用域
target("zzz")
-- 外层作用域
after_build(function ()
-- 内层作用域,支持内建变量
print("$(projectdir)")
end)
task("hello")
on_run(function()
-- 内层作用域
print("$(projectdir)")
end)
在内层作用域,也就是自定义脚本中,主要针对一些高端用户,需要更加复杂的描述工程逻辑需求,在这个作用域里面,可以使用各种内建模块、扩展模块(需要import导入),以及插件调用。。
基本上就是在写lua脚本,像print
, os.cp
的路径,等都是支持 内建变量的。。例如:
`os.cp("$(buildir)/xxx", "$(tmpdir)/xxx")
并且此作用域,为了简化脚本,采用异常中断的方式,简化脚本代码,使得更加可读,大部分api操作,调用后,不需要考虑是否返回失败,去判断失败逻辑,执行失败后,直接回抛异常中断xmake,显示error信息。。
from xmake.
好的,谢谢
from xmake.
Related Issues (20)
- windows安装远程包SuiteSparse失败 HOT 8
- windows环境wasm目标,package.tools.cmake模块有bug HOT 2
- Add on_source to set urls/versions in packages dynamically HOT 3
- xmake project -k cmake生成的cmakelists.txt中漏掉了/utf-8参数 HOT 5
- Xrepo command not work in conda environment
- 交叉编译Rust项目时,cargo的编译期依赖没有被正确安装 HOT 43
- xmake pack打包失败 c++modules HOT 23
- The option:set_default interface is inconsistent with the documentation description in xmake.io HOT 1
- 编译了过时的代码,但xmake clean && xmake清除后再构建则符合预期 HOT 12
- Linux kernel cannot be built in NixOS HOT 1
- Support TI-CGT compiler like cmake and meson HOT 3
- rk3588s安装出错 HOT 3
- 总会出现关于runtimes的警告信息 HOT 4
- remote build blocked & distcc does not work HOT 7
- 更好的第三方插件集成 HOT 6
- Add links and package with set_sourcedir HOT 6
- GCC cannot find lua headers on Ubuntu HOT 2
- v2.9.2 单测运行失败问题 HOT 8
- add_files("*.c*") wildcard does not work anymore HOT 11
- add net.http.download timeout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmake.