xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. add_requires("python 3.x", {kind = "binary"})
  2. add_rules("mode.debug", "mode.release")
  3. set_languages("c++11")
  4. target("elf++")
  5. set_kind("$(kind)")
  6. add_files("elf/*.cc")
  7. add_headerfiles("elf/elf++.hh", "elf/data.hh", "elf/common.hh", {prefixdir = "libelfin/elf"})
  8. on_load(function (target)
  9. local filename = "elf/to_string.cc"
  10. local file = io.open(filename, "w")
  11. file:print("// Automatically generated by xmake at " .. os.date("%y-%m-%d"))
  12. file:print("// DO NOT EDIT")
  13. file:print("")
  14. file:print([[#include "data.hh"]])
  15. file:print([[#include "to_hex.hh"]])
  16. file:print("")
  17. file:print("ELFPP_BEGIN_NAMESPACE")
  18. file:print("")
  19. local python = assert(import("lib.detect.find_tool")("python3"), "python not found!")
  20. local result = try { function()
  21. return os.iorunv(python.program,
  22. {"elf/enum-print.py", "-u", "--hex", "--no-type", "--mask", "shf", "--mask", "pf", "-x", "loos", "-x", "hios", "-x", "loproc", "-x", "hiproc"},
  23. {stdin = "elf/data.hh"})
  24. end }
  25. if result then
  26. file:print(result)
  27. end
  28. file:print("ELFPP_END_NAMESPACE")
  29. file:close()
  30. target:add("files", path.join(os.projectdir(), filename))
  31. end)
  32. target("dwarf++")
  33. set_kind("$(kind)")
  34. add_files("dwarf/*.cc")
  35. add_headerfiles("dwarf/dwarf++.hh", "dwarf/data.hh", "dwarf/small_vector.hh", {prefixdir = "libelfin/dwarf"})
  36. on_load(function (target)
  37. local filename = "dwarf/to_string.cc"
  38. local file = io.open(filename, "w")
  39. file:print("// Automatically generated by xmake at " .. os.date("%y-%m-%d"))
  40. file:print("// DO NOT EDIT")
  41. file:print("")
  42. file:print([[#include "internal.hh"]])
  43. file:print("")
  44. file:print("DWARFPP_BEGIN_NAMESPACE")
  45. file:print("")
  46. local python = assert(import("lib.detect.find_tool")("python3"), "python not found!")
  47. local result = try { function() return os.iorunv(python.program, {"elf/enum-print.py"}, {stdin = "dwarf/dwarf++.hh"}) end}
  48. if result then
  49. file:print(result)
  50. end
  51. result = try { function()
  52. return os.iorunv(python.program,
  53. {"elf/enum-print.py", "-s", "_", "-u", "--hex", "-x", "hi_user", "-x", "lo_user"},
  54. {stdin = "dwarf/data.hh"})
  55. end }
  56. if result then
  57. file:print(result)
  58. end
  59. file:print("DWARFPP_END_NAMESPACE")
  60. file:close()
  61. target:add("files", path.join(os.projectdir(), filename))
  62. end)