xmake.lua 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. -- ref: https://github.com/microsoft/vcpkg/blob/master/ports/breakpad/CMakeLists.txt
  2. add_rules("mode.debug", "mode.release")
  3. set_languages("c++17")
  4. add_requires("libdisasm")
  5. target("breakpad")
  6. set_kind("$(kind)")
  7. add_includedirs("src")
  8. add_headerfiles("src/(google_breakpad/**.h)")
  9. add_packages("libdisasm")
  10. if is_plat("android") then
  11. add_files("android/google_breakpad/Android.mk")
  12. else
  13. add_files("src/processor/*.cc")
  14. remove_files("src/processor/*test*.cc",
  15. "src/processor/microdump_stackwalk.cc",
  16. "src/processor/synth_minidump.cc",
  17. "src/processor/minidump_dump.cc",
  18. "src/processor/minidump_stackwalk.cc")
  19. add_headerfiles("src/(processor/*.h)")
  20. remove_headerfiles("src/processor/*test*.h", "src/processor/synth_minidump.h")
  21. add_files("src/common/*.cc", "src/client/*.cc")
  22. remove_files("src/common/*test*.cc", "src/client/*test*.cc")
  23. add_headerfiles("src/(common/*.h)", "src/(client/*.h)")
  24. remove_headerfiles("src/common/*test*.h", "src/client/*test*.h")
  25. if is_plat("windows") then
  26. add_defines("UNICODE",
  27. "WIN32_LEAN_AND_MEAN",
  28. "_CRT_SECURE_NO_WARNINGS",
  29. "_CRT_SECURE_NO_DEPRECATE",
  30. "_CRT_NONSTDC_NO_DEPRECATE")
  31. add_files("src/common/windows/*.cc",
  32. "src/client/windows/crash_generation/*.cc",
  33. "src/client/windows/handler/*.cc")
  34. remove_files("src/common/windows/*test*.cc",
  35. "src/processor/disassembler_objdump.cc",
  36. "src/common/language.cc",
  37. "src/common/path_helper.cc",
  38. "src/common/stabs_to_module.cc",
  39. "src/common/stabs_reader.cc",
  40. "src/common/dwarf*.cc",
  41. "src/client/minidump_file_writer.cc")
  42. add_headerfiles("src/(common/windows/*.h)",
  43. "src/(client/windows/common/*.h)",
  44. "src/(client/windows/crash_generation/*.h)",
  45. "src/(client/windows/handler/*.h)")
  46. remove_headerfiles("src/common/windows/*test*.h",
  47. "src/processor/disassembler_objdump.h",
  48. "src/common/language.h",
  49. "src/common/path_helper.h",
  50. "src/common/stabs_to_module.h",
  51. "src/common/stabs_reader.h",
  52. "src/common/dwarf*.h",
  53. "src/client/minidump_file_writer.h")
  54. add_syslinks("wininet", "dbghelp", "imagehlp")
  55. if is_kind("shared") then
  56. add_rules("utils.symbols.export_all", {export_classes = true})
  57. end
  58. else
  59. add_files("src/common/dwarf/*.cc")
  60. remove_files("src/common/dwarf/*test*.cc")
  61. add_headerfiles("src/(common/dwarf/*.h)")
  62. remove_headerfiles("src/common/dwarf/*test*.h")
  63. if is_plat("macosx") then
  64. add_defines("HAVE_MACH_O_NLIST_H")
  65. add_files("src/common/mac/MachIPC.mm",
  66. "src/common/mac/*.cc",
  67. "src/client/mac/crash_generation/*.cc",
  68. "src/client/mac/handler/*.cc")
  69. remove_files("src/common/mac/*test*.cc")
  70. add_headerfiles("src/(common/mac/*.h)",
  71. "src/(client/mac/crash_generation/*.h)",
  72. "src/(client/mac/handler/*.h)")
  73. add_frameworks("CoreFoundation")
  74. else
  75. add_defines("HAVE_A_OUT_H")
  76. add_files("src/client/linux/**.cc", "src/common/linux/**.cc")
  77. remove_files("src/client/linux/sender/*test*.cc",
  78. "src/client/linux/handler/*test*.cc",
  79. "src/client/linux/microdump_writer/*test*.cc",
  80. "src/client/linux/minidump_writer/*test*.cc")
  81. add_headerfiles("src/(client/linux/**.h)", "src/(common/linux/**.h)")
  82. add_syslinks("pthread")
  83. end
  84. end
  85. end
  86. on_config(function (target)
  87. if target:is_plat("windows") then
  88. local msvc = target:toolchain("msvc")
  89. if msvc then
  90. local envs = msvc:runenvs()
  91. local VSInstallDir = envs and envs.VSInstallDir
  92. if VSInstallDir then
  93. local dir = path.join(VSInstallDir, "DIA SDK")
  94. target:add("includedirs", path.join(dir, "include"))
  95. target:add("syslinks", "diaguids")
  96. if os.isdir(dir) then
  97. if target:is_arch("x86") then
  98. target:add("runenvs", path.join(dir, "bin"))
  99. target:add("linkdirs", path.join(dir, "lib"))
  100. else
  101. local arch
  102. if target:is_arch("x64") then
  103. arch = "amd64"
  104. elseif target:is_arch("arm") then
  105. arch = "arm"
  106. elseif target:is_arch("arm64") then
  107. arch = "arm64"
  108. else
  109. raise("Unsupported arch")
  110. end
  111. target:add("runenvs", path.join(dir, "bin", arch))
  112. target:add("linkdirs", path.join(dir, "lib", arch))
  113. end
  114. end
  115. end
  116. end
  117. elseif not target:is_plat("macosx") then
  118. if target:has_cfuncs("getcontext", {includes = "ucontext.h"}) then
  119. target:add("defines", "HAVE_GETCONTEXT=1")
  120. else
  121. target:add("files", path.join(os.projectdir(), "src/common/linux/breakpad_getcontext.S"))
  122. end
  123. end
  124. end)