premake5.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. newoption
  2. {
  3. trigger = "graphics",
  4. value = "OPENGL_VERSION",
  5. description = "version of OpenGL to build raylib against",
  6. allowed = {
  7. { "opengl11", "OpenGL 1.1"},
  8. { "opengl21", "OpenGL 2.1"},
  9. { "opengl33", "OpenGL 3.3"},
  10. { "opengl43", "OpenGL 4.3"}
  11. },
  12. default = "opengl33"
  13. }
  14. function define_C()
  15. language "C"
  16. end
  17. function define_Cpp()
  18. language "C++"
  19. end
  20. function string.starts(String,Start)
  21. return string.sub(String,1,string.len(Start))==Start
  22. end
  23. function link_to(lib)
  24. links (lib)
  25. includedirs ("../"..lib.."/include", "../"..lib.."/" )
  26. end
  27. function download_progress(total, current)
  28. local ratio = current / total;
  29. ratio = math.min(math.max(ratio, 0), 1);
  30. local percent = math.floor(ratio * 100);
  31. print("Download progress (" .. percent .. "%/100%)")
  32. end
  33. function check_raylib()
  34. if(os.isdir("raylib") == false and os.isdir("raylib-master") == false) then
  35. if(not os.isfile("raylib-master.zip")) then
  36. print("Raylib not found, downloading from github")
  37. local result_str, response_code = http.download("https://github.com/raysan5/raylib/archive/refs/heads/master.zip", "raylib-master.zip", {
  38. progress = download_progress,
  39. headers = { "From: Premake", "Referer: Premake" }
  40. })
  41. end
  42. print("Unzipping to " .. os.getcwd())
  43. zip.extract("raylib-master.zip", os.getcwd())
  44. os.remove("raylib-master.zip")
  45. end
  46. end
  47. function check_imgui()
  48. if(os.isdir("imgui") == false and os.isdir("imgui-master") == false) then
  49. if(not os.isfile("imgui-master.zip")) then
  50. print("imgui not found, downloading from github")
  51. local result_str, response_code = http.download("https://github.com/ocornut/imgui/archive/refs/heads/master.zip", "imgui-master.zip", {
  52. progress = download_progress,
  53. headers = { "From: Premake", "Referer: Premake" }
  54. })
  55. end
  56. print("Unzipping to " .. os.getcwd())
  57. zip.extract("imgui-master.zip", os.getcwd())
  58. os.remove("imgui-master.zip")
  59. end
  60. end
  61. workspace "rlImGui"
  62. configurations { "Debug", "Release" }
  63. platforms { "x64"}
  64. defaultplatform "x64"
  65. filter "configurations:Debug"
  66. defines { "DEBUG" }
  67. symbols "On"
  68. filter "configurations:Release"
  69. defines { "NDEBUG" }
  70. optimize "On"
  71. filter { "platforms:x64" }
  72. architecture "x86_64"
  73. targetdir "bin/%{cfg.buildcfg}/"
  74. cdialect "C99"
  75. cppdialect "C++11"
  76. check_raylib()
  77. check_imgui()
  78. include ("raylib_premake5.lua")
  79. project "rlImGui"
  80. kind "StaticLib"
  81. location "_build"
  82. targetdir "_bin/%{cfg.buildcfg}"
  83. language "C++"
  84. include_raylib()
  85. includedirs { "rlImGui", "imgui", "imgui-master"}
  86. vpaths
  87. {
  88. ["Header Files"] = { "*.h"},
  89. ["Source Files"] = {"*.cpp"},
  90. ["ImGui Files"] = { "imgui/*.h","imgui/*.cpp", "imgui-master/*.h","imgui-master/*.cpp" },
  91. }
  92. files {"imgui-master/*.h", "imgui-master/*.cpp", "imgui/*.h", "imgui/*.cpp", "*.cpp", "*.h", "extras/**.h"}
  93. defines {"IMGUI_DISABLE_OBSOLETE_FUNCTIONS","IMGUI_DISABLE_OBSOLETE_KEYIO"}
  94. group "Examples"
  95. project "simple"
  96. kind "ConsoleApp"
  97. language "C++"
  98. location "_build"
  99. targetdir "_bin/%{cfg.buildcfg}"
  100. vpaths
  101. {
  102. ["Header Files"] = { "examples/**.h"},
  103. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  104. }
  105. files {"examples/simple.cpp"}
  106. link_raylib()
  107. links {"rlImGui"}
  108. includedirs {"./", "imgui", "imgui-master" }
  109. filter "action:vs*"
  110. debugdir "$(SolutionDir)"
  111. project "editor"
  112. kind "ConsoleApp"
  113. language "C++"
  114. location "_build"
  115. targetdir "_bin/%{cfg.buildcfg}"
  116. vpaths
  117. {
  118. ["Header Files"] = { "examples/**.h"},
  119. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  120. }
  121. files {"examples/editor.cpp"}
  122. link_raylib()
  123. links {"rlImGui"}
  124. includedirs {"./", "imgui", "imgui-master" }
  125. filter "action:vs*"
  126. debugdir "$(SolutionDir)"
  127. project "imgui_style_example"
  128. kind "ConsoleApp"
  129. language "C++"
  130. location "_build"
  131. targetdir "_bin/%{cfg.buildcfg}"
  132. vpaths
  133. {
  134. ["Header Files"] = { "examples/**.h"},
  135. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  136. }
  137. files {"examples/imgui_style_example.cpp"}
  138. link_raylib()
  139. links {"rlImGui"}
  140. includedirs {"./", "imgui", "imgui-master" }
  141. filter "action:vs*"
  142. debugdir "$(SolutionDir)"