2
0
Эх сурвалжийг харах

add imgui-sfml (#769)

* Create xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* update sfml

* update sfml

* update sfml

* update sfml

* update sfml

* add mirror url

* fix udev

* fix links

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua
ruki 3 жил өмнө
parent
commit
d6261ced9f

+ 1 - 1
packages/a/automake/xmake.lua

@@ -5,7 +5,7 @@ package("automake")
     set_description("A tool for automatically generating Makefile.in files compliant with the GNU Coding Standards.")
     set_description("A tool for automatically generating Makefile.in files compliant with the GNU Coding Standards.")
 
 
     add_urls("https://ftp.gnu.org/gnu/automake/automake-$(version).tar.gz",
     add_urls("https://ftp.gnu.org/gnu/automake/automake-$(version).tar.gz",
-                "https://mirrors.ustc.edu.cn/gnu/automake/automake-$(version).tar.gz")
+             "https://mirrors.ustc.edu.cn/gnu/automake/automake-$(version).tar.gz")
     add_versions("1.16.4", "8a0f0be7aaae2efa3a68482af28e5872d8830b9813a6a932a2571eac63ca1794")
     add_versions("1.16.4", "8a0f0be7aaae2efa3a68482af28e5872d8830b9813a6a932a2571eac63ca1794")
     add_versions("1.16.1", "608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8")
     add_versions("1.16.1", "608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8")
     add_versions("1.15.1", "988e32527abe052307d21c8ca000aa238b914df363a617e38f4fb89f5abf6260")
     add_versions("1.15.1", "988e32527abe052307d21c8ca000aa238b914df363a617e38f4fb89f5abf6260")

+ 68 - 0
packages/i/imgui-sfml/xmake.lua

@@ -0,0 +1,68 @@
+package("imgui-sfml")
+
+    set_homepage("https://github.com/eliasdaler/imgui-sfml")
+    set_description("Dear ImGui binding for use with SFML")
+
+    add_urls("https://github.com/eliasdaler/imgui-sfml/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/eliasdaler/imgui-sfml.git")
+
+    add_versions("v2.5", "3775c9303f656297f2392e91ffae2021e874ee319b4139c60076d6f757ede109")
+
+    add_deps("cmake")
+    add_deps("imgui", {system = false, private = true})
+    add_deps("opengl", {optional = true})
+
+    on_load(function(package)
+        if package:is_plat("linux") and package:config("shared") then
+            package:add("deps", "sfml", {configs = {shared = true}})
+        else
+            package:add("deps", "sfml")
+        end
+    end)
+
+    on_install("macosx", "linux", "windows", "mingw", function (package)
+        local configs = {"-DIMGUI_SFML_FIND_SFML=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        local imgui_sourcedir = package:dep("imgui"):cachedir()
+        if imgui_sourcedir then
+            local imguidir = import("lib.detect.find_path")("imgui.h", path.join(imgui_sourcedir, "source", "*"))
+            if imguidir then
+                table.insert(configs, "-DIMGUI_DIR=" .. imguidir)
+            end
+        end
+        -- fix sfml links
+        if package:is_plat("windows", "linux") then
+            local sfml = package:dep("sfml"):fetch()
+            if sfml.links then
+                for _, name in ipairs({"sfml-graphics", "sfml-system", "sfml-window"}) do
+                    for _, link in ipairs(sfml.links) do
+                        if link:find(name, 1, true) then
+                            io.replace("CMakeLists.txt", name, link, {plain = true})
+                            break
+                        end
+                    end
+                end
+            end
+        end
+        if package:is_plat("mingw") then
+            io.replace("cmake/FindImGui.cmake", "NO_DEFAULT_PATH", "NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH")
+        end
+        import("package.tools.cmake").install(package, configs, {packagedeps = "sfml"})
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include "imgui.h"
+            #include "imgui-SFML.h"
+            #include <SFML/Graphics/CircleShape.hpp>
+            #include <SFML/Graphics/RenderWindow.hpp>
+            #include <SFML/System/Clock.hpp>
+            #include <SFML/Window/Event.hpp>
+            void test() {
+                sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
+                window.setFramerateLimit(60);
+                ImGui::SFML::Init(window);
+            }
+        ]]}, {configs = {languages = "c++11"}}))
+    end)

+ 2 - 1
packages/m/m4/xmake.lua

@@ -5,7 +5,8 @@ package("m4")
     set_description("Macro processing language")
     set_description("Macro processing language")
 
 
     add_urls("https://ftp.gnu.org/gnu/m4/m4-$(version).tar.xz",
     add_urls("https://ftp.gnu.org/gnu/m4/m4-$(version).tar.xz",
-             "https://ftpmirror.gnu.org/m4/m4-$(version).tar.xz")
+             "https://ftpmirror.gnu.org/m4/m4-$(version).tar.xz",
+             "https://mirrors.ustc.edu.cn/gnu/m4/m4-$(version).tar.xz")
     add_versions("1.4.18", "f2c1e86ca0a404ff281631bdc8377638992744b175afb806e25871a24a934e07")
     add_versions("1.4.18", "f2c1e86ca0a404ff281631bdc8377638992744b175afb806e25871a24a934e07")
     add_versions("1.4.19", "63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96")
     add_versions("1.4.19", "63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96")
 
 

+ 12 - 11
packages/s/sfml/xmake.lua

@@ -3,15 +3,10 @@ package("sfml")
     set_homepage("https://www.sfml-dev.org")
     set_homepage("https://www.sfml-dev.org")
     set_description("Simple and Fast Multimedia Library")
     set_description("Simple and Fast Multimedia Library")
 
 
-    if is_plat("windows") then
+    if is_plat("windows", "linux") then
         set_urls("https://www.sfml-dev.org/files/SFML-$(version)-sources.zip")
         set_urls("https://www.sfml-dev.org/files/SFML-$(version)-sources.zip")
         add_urls("https://github.com/SFML/SFML/releases/download/$(version)/SFML-$(version)-sources.zip")
         add_urls("https://github.com/SFML/SFML/releases/download/$(version)/SFML-$(version)-sources.zip")
         add_versions("2.5.1", "bf1e0643acb92369b24572b703473af60bac82caf5af61e77c063b779471bb7f")
         add_versions("2.5.1", "bf1e0643acb92369b24572b703473af60bac82caf5af61e77c063b779471bb7f")
-    elseif is_plat("linux") then
-        if is_arch("x64", "x86_64") then
-            set_urls("https://www.sfml-dev.org/files/SFML-$(version)-linux-gcc-64-bit.tar.gz")
-            add_versions("2.5.1", "34ad106e4592d2ec03245db5e8ad8fbf85c256d6ef9e337e8cf5c4345dc583dd")
-        end
     elseif is_plat("macosx") then
     elseif is_plat("macosx") then
         if is_arch("x64", "x86_64") then
         if is_arch("x64", "x86_64") then
             set_urls("https://www.sfml-dev.org/files/SFML-$(version)-macOS-clang.tar.gz")
             set_urls("https://www.sfml-dev.org/files/SFML-$(version)-macOS-clang.tar.gz")
@@ -37,7 +32,7 @@ package("sfml")
         if package:is_plat("windows") then
         if package:is_plat("windows") then
             package:add("deps", "cmake")
             package:add("deps", "cmake")
         end
         end
-        
+
         if not package:config("shared") then
         if not package:config("shared") then
             package:add("defines", "SFML_STATIC")
             package:add("defines", "SFML_STATIC")
         end
         end
@@ -70,11 +65,17 @@ package("sfml")
             if package:is_plat("windows", "mingw") then
             if package:is_plat("windows", "mingw") then
                 package:add("syslinks", "opengl32", "gdi32", "user32", "advapi32")
                 package:add("syslinks", "opengl32", "gdi32", "user32", "advapi32")
             end
             end
+            if package:is_plat("linux") then
+                package:add("deps", "libx11", "libxrandr", "freetype", "eudev")
+                package:add("deps", "opengl", "glx", {optional = true})
+            end
         end
         end
         if package:config("audio") then
         if package:config("audio") then
             if package:is_plat("mingw") then
             if package:is_plat("mingw") then
                 package:add("links", a .. "audio" .. e)
                 package:add("links", a .. "audio" .. e)
                 package:add("links", "openal32", "flac", "vorbisenc", "vorbisfile", "vorbis", "ogg")
                 package:add("links", "openal32", "flac", "vorbisenc", "vorbisfile", "vorbis", "ogg")
+            elseif package:is_plat("linux") then
+                package:add("deps", "libogg", "libflac", "libvorbis", "openal-soft")
             end
             end
         end
         end
         if package:config("network") then
         if package:config("network") then
@@ -94,14 +95,14 @@ package("sfml")
         end
         end
     end)
     end)
 
 
-    on_install("windows", function (package)
+    on_install("windows", "linux", function (package)
         local configs = {"-DSFML_BUILD_DOC=OFF", "-DSFML_BUILD_EXAMPLES=OFF"}
         local configs = {"-DSFML_BUILD_DOC=OFF", "-DSFML_BUILD_EXAMPLES=OFF"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         if package:config("shared") then
         if package:config("shared") then
             table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
             table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
         else
         else
             table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
             table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
-            if package:config("vs_runtime"):startswith("MT") then
+            if package:is_plat("windows") and package:config("vs_runtime"):startswith("MT") then
                 table.insert(configs, "-DSFML_USE_STATIC_STD_LIBS=ON")
                 table.insert(configs, "-DSFML_USE_STATIC_STD_LIBS=ON")
             end
             end
         end
         end
@@ -112,7 +113,7 @@ package("sfml")
         import("package.tools.cmake").install(package, configs)
         import("package.tools.cmake").install(package, configs)
     end)
     end)
 
 
-    on_install("linux", "macosx", "mingw", function (package)
+    on_install("macosx", "mingw", function (package)
         os.cp("lib", package:installdir())
         os.cp("lib", package:installdir())
         os.cp("include", package:installdir())
         os.cp("include", package:installdir())
         if package:is_plat("mingw") then
         if package:is_plat("mingw") then
@@ -127,4 +128,4 @@ package("sfml")
                 c.restart();
                 c.restart();
             }
             }
         ]]}, {includes = "SFML/System.hpp"}))
         ]]}, {includes = "SFML/System.hpp"}))
-    end)
+    end)