xmake.lua 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/common/language.cc",
  36. "src/common/path_helper.cc",
  37. "src/common/stabs_to_module.cc",
  38. "src/common/stabs_reader.cc",
  39. "src/common/dwarf*.cc",
  40. "src/client/minidump_file_writer.cc")
  41. add_headerfiles("src/(common/windows/*.h)",
  42. "src/(client/windows/common/*.h)",
  43. "src/(client/windows/crash_generation/*.h)",
  44. "src/(client/windows/handler/*.h)")
  45. remove_headerfiles("src/common/windows/*test*.h",
  46. "src/common/language.h",
  47. "src/common/path_helper.h",
  48. "src/common/stabs_to_module.h",
  49. "src/common/stabs_reader.h",
  50. "src/common/dwarf*.h",
  51. "src/client/minidump_file_writer.h")
  52. add_syslinks("wininet", "dbghelp", "imagehlp")
  53. if is_kind("shared") then
  54. add_rules("utils.symbols.export_all", {export_classes = true})
  55. end
  56. else
  57. add_files("src/common/dwarf/*.cc")
  58. remove_files("src/common/dwarf/*test*.cc")
  59. add_headerfiles("src/(common/dwarf/*.h)")
  60. remove_headerfiles("src/common/dwarf/*test*.h")
  61. if is_plat("macosx") then
  62. add_defines("HAVE_MACH_O_NLIST_H")
  63. add_files("src/common/mac/MachIPC.mm",
  64. "src/common/mac/*.cc",
  65. "src/client/mac/crash_generation/*.cc",
  66. "src/client/mac/handler/*.cc")
  67. remove_files("src/common/mac/*test*.cc")
  68. add_headerfiles("src/(common/mac/*.h)",
  69. "src/(client/mac/crash_generation/*.h)",
  70. "src/(client/mac/handler/*.h)")
  71. add_frameworks("CoreFoundation")
  72. else
  73. add_defines("HAVE_A_OUT_H")
  74. add_files("src/client/linux/**.cc", "src/common/linux/**.cc")
  75. remove_files("src/client/linux/sender/*test*.cc",
  76. "src/client/linux/handler/*test*.cc",
  77. "src/client/linux/microdump_writer/*test*.cc",
  78. "src/client/linux/minidump_writer/*test*.cc")
  79. add_headerfiles("src/(client/linux/**.h)", "src/(common/linux/**.h)")
  80. add_syslinks("pthread")
  81. end
  82. end
  83. end
  84. on_config(function (target)
  85. if target:is_plat("windows") then
  86. local msvc = target:toolchain("msvc")
  87. if msvc then
  88. local envs = msvc:runenvs()
  89. local VSInstallDir = envs and envs.VSInstallDir
  90. if VSInstallDir then
  91. local dir = path.join(VSInstallDir, "DIA SDK")
  92. target:add("includedirs", path.join(dir, "include"))
  93. target:add("syslinks", "diaguids")
  94. if os.isdir(dir) then
  95. if target:is_arch("x86") then
  96. target:add("runenvs", path.join(dir, "bin"))
  97. target:add("linkdirs", path.join(dir, "lib"))
  98. else
  99. local arch
  100. if target:is_arch("x64") then
  101. arch = "amd64"
  102. elseif target:is_arch("arm") then
  103. arch = "arm"
  104. elseif target:is_arch("arm64") then
  105. arch = "arm64"
  106. else
  107. raise("Unsupported arch")
  108. end
  109. target:add("runenvs", path.join(dir, "bin", arch))
  110. target:add("linkdirs", path.join(dir, "lib", arch))
  111. end
  112. end
  113. end
  114. end
  115. elseif not target:is_plat("macosx") then
  116. if target:has_cfuncs("getcontext", {includes = "ucontext.h"}) then
  117. target:add("defines", "HAVE_GETCONTEXT=1")
  118. else
  119. target:add("files", path.join(os.projectdir(), "src/common/linux/breakpad_getcontext.S"))
  120. end
  121. end
  122. end)