xmake.lua 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. add_rules("mode.debug", "mode.release")
  2. add_moduledirs("modules")
  3. rule("autogen")
  4. set_extensions(".in")
  5. before_build_file(function (target, sourcefile, opt)
  6. import("utils.progress")
  7. import("core.project.depend")
  8. import("core.tool.compiler")
  9. import("autogen.foo", {always_build = true})
  10. local sourcefile_cx = path.join(target:autogendir(), "rules", "autogen", path.basename(sourcefile) .. ".cpp")
  11. local objectfile = target:objectfile(sourcefile_cx)
  12. table.insert(target:objectfiles(), objectfile)
  13. depend.on_changed(function ()
  14. progress.show(opt.progress, "${color.build.object}compiling.autogen %s", sourcefile)
  15. os.mkdir(path.directory(sourcefile_cx))
  16. foo.generate(sourcefile, sourcefile_cx)
  17. compiler.compile(sourcefile_cx, objectfile, {target = target})
  18. end, {dependfile = target:dependfile(objectfile),
  19. files = sourcefile,
  20. changed = target:is_rebuilt()})
  21. end)
  22. target("test")
  23. set_kind("binary")
  24. add_rules("autogen")
  25. add_files("src/main.cpp")
  26. add_files("src/*.in")