2
0

xmake.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. add_rules("mode.debug", "mode.release")
  2. rule("autogen")
  3. set_extensions(".in")
  4. before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
  5. local sourcefile_cx = path.join(target:autogendir(), "rules", "autogen", path.basename(sourcefile) .. ".cpp")
  6. local objectfile = target:objectfile(sourcefile_cx)
  7. table.insert(target:objectfiles(), objectfile)
  8. batchcmds:show_progress(opt.progress, "${color.build.object}compiling.autogen %s", sourcefile)
  9. batchcmds:mkdir(path.directory(sourcefile_cx))
  10. batchcmds:vrunv(target:dep("autogen"):targetfile(), {sourcefile, sourcefile_cx})
  11. batchcmds:compile(sourcefile_cx, objectfile)
  12. batchcmds:add_depfiles(sourcefile, target:dep("autogen"):targetfile())
  13. batchcmds:set_depmtime(os.mtime(objectfile))
  14. batchcmds:set_depcache(target:dependfile(objectfile))
  15. end)
  16. target("autogen")
  17. set_default(false)
  18. set_kind("binary")
  19. set_plat(os.host()) -- generate for host platform
  20. set_arch(os.arch())
  21. add_files("src/autogen.cpp")
  22. set_languages("c++11")
  23. set_policy("build.fence", true) -- disable parallel build for source files
  24. target("test")
  25. set_kind("binary")
  26. add_deps("autogen")
  27. add_rules("autogen")
  28. add_files("src/main.cpp")
  29. add_files("src/*.in")