Browse Source

Auto-update libremidi to v5.1.0 (#6629)

* Update libremidi to v5.1.0

* fix windows syslinks

* remove werror

---------

Co-authored-by: star9029 <[email protected]>
ruki 5 tháng trước cách đây
mục cha
commit
0521e894dd
1 tập tin đã thay đổi với 55 bổ sung22 xóa
  1. 55 22
      packages/l/libremidi/xmake.lua

+ 55 - 22
packages/l/libremidi/xmake.lua

@@ -6,17 +6,20 @@ package("libremidi")
     add_urls("https://github.com/jcelerier/libremidi/archive/refs/tags/$(version).tar.gz",
              "https://github.com/jcelerier/libremidi.git")
 
+    add_versions("v5.1.0", "bd5f2f81fbed58c9d926741f5df5ec5b714854004492d1cf30609f650e199338")
     add_versions("v4.5.0", "2e884a4c826dd87157ee4fab8cd8c7b9dbbc1ddb804cb10ef0852094200724db")
     add_versions("v3.0", "133b40396ca72e35d94cb0950199c9d123352951e4705971a9cd7606f905328a")
 
     add_configs("header_only", {description = "Use header only version.", default = false, type = "boolean"})
     add_configs("boost", {description = "Use boost::small_vector to pass midi bytes instead of std::vector to reduce allocations.", default = false, type = "boolean"})
-    add_configs("jack", {description = "Enable JACK back-end", default = false, type = "boolean"})
     add_configs("slim_message", {description = "Use a fixed-size message format", default = "0", type = "string"})
 
-    if is_plat("windows", "mingw") then
-        add_syslinks("winmm")
-    elseif is_plat("macosx") then
+    add_configs("win_mm", {description = "Enable WinMM back-end", default = is_plat("windows", "mingw"), type = "boolean"})
+    add_configs("win_uwp", {description = "Enable UWP back-end", default = false, type = "boolean"})
+    add_configs("win_midi", {description = "Enable WinMIDI back-end", default = false, type = "boolean"})
+    add_configs("jack", {description = "Enable JACK back-end", default = false, type = "boolean"})
+
+    if is_plat("macosx") then
         add_frameworks("CoreFoundation", "CoreMIDI", "CoreAudio")
     elseif is_plat("iphoneos") then
         add_frameworks("CoreMIDI")
@@ -29,32 +32,49 @@ package("libremidi")
     on_load(function (package)
         if package:config("header_only") then
             package:set("kind", "library", {headeronly = true})
-            package:add("defines", "LIBREMIDI_HEADER_ONLY=1")
-            if package:config("jack") then
-                package:add("defines", "LIBREMIDI_JACK=1")
-            end
-
-            if package:is_plat("windows") then
-                package:add("defines", "LIBREMIDI_WINMM=1")
-                -- TODO: support UWP
-                -- package:add("defines", "LIBREMIDI_WINUWP=1")
-            elseif package:is_plat("linux") then
-                package:add("defines", "LIBREMIDI_ALSA=1")
-            elseif package:is_plat("wasm") then
-                package:add("defines", "LIBREMIDI_EMSCRIPTEN=1")
-            end
+            package:add("defines", "LIBREMIDI_HEADER_ONLY")
+        end
+        if package:config("shared") then
+            package:add("defines", "LIBREMIDI_EXPORTS")
+        end
+
+        if package:config("jack") then
+            package:add("defines", "LIBREMIDI_JACK")
+        end
+
+        if package:config("win_mm") then
+            package:add("defines", "LIBREMIDI_WINMM")
+            package:add("syslinks", "winmm")
+        end
+        if package:config("win_uwp") then
+            package:add("defines", "LIBREMIDI_WINUWP")
+            package:add("syslinks", "RuntimeObject")
+        end
+        if package:config("win_midi") then
+            -- TODO: libremidi.winmidi.cmake will donwload winmidi-headers, package it or add_resources?
+            package:add("defines", "LIBREMIDI_WINMIDI")
+            package:add("syslinks", "RuntimeObject")
+        end
+
+        if package:is_plat("linux") then
+            package:add("defines", "LIBREMIDI_ALSA")
+        elseif package:is_plat("wasm") then
+            package:add("defines", "LIBREMIDI_EMSCRIPTEN")
         end
+
         if package:config("boost") then
             package:add("deps", "boost")
         end
     end)
 
     on_install(function (package)
-        local configs = {"-DLIBREMIDI_EXAMPLES=OFF", "-DLIBREMIDI_TESTS=OFF"}
+        io.replace("CMakeLists.txt", "          ARCHIVE DESTINATION lib/static", "          ARCHIVE DESTINATION lib", {plain = true})
+
+        local configs = {"-DLIBREMIDI_EXAMPLES=OFF", "-DLIBREMIDI_TESTS=OFF", "-DLIBREMIDI_NO_WARNINGS=ON"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        table.insert(configs, "-DLIBREMIDI_NO_EXPORTS=" .. (package:config("shared") and "OFF" or "ON"))
         table.insert(configs, "-DLIBREMIDI_HEADER_ONLY=" .. (package:config("header_only") and "ON" or "OFF"))
-        table.insert(configs, "-DLIBREMIDI_NO_JACK=" .. (package:config("jack") and "OFF" or "ON"))
         table.insert(configs, "-DLIBREMIDI_SLIM_MESSAGE=" .. package:config("slim_message"))
         if package:config("boost") then
             table.insert(configs, "-DLIBREMIDI_NO_BOOST=OFF")
@@ -62,13 +82,26 @@ package("libremidi")
         else
             table.insert(configs, "-DLIBREMIDI_NO_BOOST=ON")
         end
-        io.replace("CMakeLists.txt", "          ARCHIVE DESTINATION lib/static", "          ARCHIVE DESTINATION lib", {plain = true})
+
+        table.insert(configs, "-DLIBREMIDI_NO_JACK=" .. (package:config("jack") and "OFF" or "ON"))
+        table.insert(configs, "-DLIBREMIDI_NO_WINMM=" .. (package:config("win_mm") and "OFF" or "ON"))
+        table.insert(configs, "-DLIBREMIDI_NO_WINUWP=" .. (package:config("win_uwp") and "OFF" or "ON"))
+        table.insert(configs, "-DLIBREMIDI_NO_WINMIDI=" .. (package:config("win_midi") and "OFF" or "ON"))
+
         import("package.tools.cmake").install(package, configs)
+
+        if package:is_plat("windows") and package:config("shared") then
+            local src = "#define LIBREMIDI_EXPORT __declspec(dllexport)"
+            local dst = "#define LIBREMIDI_EXPORT __declspec(dllimport)"
+            local include = package:installdir("include/libremidi")
+            io.replace(path.join(include, "config.hpp"), src, dst, {plain = true})
+            io.replace(path.join(include, "libremidi-c.h"), src, dst, {plain = true})
+        end
     end)
 
     on_test(function (package)
         local code
-        if package:version():lt("4.0.0") then
+        if package:version() and package:version():lt("4.0.0") then
             code = [[
                 void test() {
                     libremidi::midi_in midi;