Giter VIP home page Giter VIP logo

Comments (2)

waruqi avatar waruqi commented on July 24, 2024

像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脚本,像printos.cp的路径,等都是支持 内建变量的。。例如:

`os.cp("$(buildir)/xxx", "$(tmpdir)/xxx")

并且此作用域,为了简化脚本,采用异常中断的方式,简化脚本代码,使得更加可读,大部分api操作,调用后,不需要考虑是否返回失败,去判断失败逻辑,执行失败后,直接回抛异常中断xmake,显示error信息。。

from xmake.

baisai avatar baisai commented on July 24, 2024

好的,谢谢

from xmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.