Explorar o código

uvwasi: fix and update (#8218)

* fix: v0.0.12 install, this commit is meant to trigger ci for v0.0.12

* fix: v0.0.12 win shared

* add versions and update
Willaaaaaaa hai 2 meses
pai
achega
d19e82657a
Modificáronse 2 ficheiros con 60 adicións e 8 borrados
  1. 37 0
      packages/u/uvwasi/patches/0.0.23/cmake.patch
  2. 23 8
      packages/u/uvwasi/xmake.lua

+ 37 - 0
packages/u/uvwasi/patches/0.0.23/cmake.patch

@@ -0,0 +1,37 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8d79820..7ae6021 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -99,20 +99,11 @@ if(ASAN AND CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang")
+     set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
+ endif()
+ 
+-## Static library target.
+-add_library(uvwasi_a STATIC ${uvwasi_sources})
+-set_target_properties(uvwasi_a PROPERTIES OUTPUT_NAME "uvwasi")
+-target_compile_definitions(uvwasi_a PRIVATE ${uvwasi_defines})
+-target_compile_options(uvwasi_a PRIVATE ${uvwasi_cflags})
+-target_include_directories(uvwasi_a PRIVATE ${PROJECT_SOURCE_DIR}/include)
+-if(CODE_COVERAGE)
+-    target_link_libraries(uvwasi_a PUBLIC ${LIBUV_LIBRARIES} coverage_config)
++if(BUILD_SHARED_LIBS)
++    add_library(uvwasi SHARED ${uvwasi_sources})
+ else()
+-    target_link_libraries(uvwasi_a PRIVATE ${LIBUV_LIBRARIES})
++    add_library(uvwasi STATIC ${uvwasi_sources})
+ endif()
+-
+-## Shared library target.
+-add_library(uvwasi SHARED ${uvwasi_sources})
+ target_compile_definitions(uvwasi PRIVATE ${uvwasi_defines})
+ target_compile_options(uvwasi PRIVATE ${uvwasi_cflags})
+ target_include_directories(uvwasi PRIVATE ${PROJECT_SOURCE_DIR}/include)
+@@ -162,7 +153,7 @@ if(INSTALL_UVWASI AND NOT CODE_COVERAGE)
+     configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in ${config_file} INSTALL_DESTINATION ${cmake_files_install_dir})
+ 
+     install(
+-        TARGETS uvwasi_a uvwasi
++        TARGETS uvwasi
+         EXPORT ${target_export_name}
+         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

+ 23 - 8
packages/u/uvwasi/xmake.lua

@@ -6,10 +6,12 @@ package("uvwasi")
     add_urls("https://github.com/nodejs/uvwasi/archive/refs/tags/$(version).tar.gz",
              "https://github.com/nodejs/uvwasi.git")
 
+    add_versions("v0.0.23", "cdb148aac298883b51da887657deca910c7c02f35435e24f125cef536fe8d5e1")
     add_versions("v0.0.21", "5cf32f166c493f41c0de7f3fd578d0be1b692c81c54f0c68889e62240fe9ab60")
     add_versions("v0.0.20", "417e5ecc40005d9c8008bad2b6a2034e109b2a0a1ebd108b231cb419cfbb980a")
     add_versions("v0.0.12", "f310a628d2657b9ed523a19284f58e4a407466f2e17efb2250d2e58524d02c53")
 
+    add_patches("v0.0.23", path.join(os.scriptdir(), "patches", "0.0.23", "cmake.patch"), "7c572636693a9ade904ca746a3f365299d312d794fe7b4438b7cfb8dbedc7698")
     add_patches("v0.0.20", path.join(os.scriptdir(), "patches", "0.0.20", "cmake.patch"), "50d70983aa498e63e02e66d71e3c7c78ed1c802c61063d1b085e8a12abbcf751")
 
     add_includedirs("include", "include/uvwasi")
@@ -17,7 +19,8 @@ package("uvwasi")
     add_deps("cmake", "libuv")
 
     on_install("linux", "windows", "macosx", function (package)
-        local configs = {"-DUVWASI_BUILD_TESTS=OFF"}
+        local test_config = package:version():ge("0.0.22") and "-DBUILD_TESTING=OFF" or "-DUVWASI_BUILD_TESTS=OFF"
+        local configs = {test_config}
         if package:version():ge("0.0.20") then
             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"))
@@ -32,19 +35,31 @@ package("uvwasi")
             if package:config("shared") then
                 io.replace("CMakeLists.txt", "-fvisibility=hidden", "", {plain = true})
             end
-            import("package.tools.cmake").install(package, configs, {packagedeps = "libuv"})
+            import("package.tools.cmake").build(package, configs, {packagedeps = "libuv"})
             os.cp("include", package:installdir())
+            local dir = package.builddir and package:builddir() or package:buildir()
             if package:config("shared") then
-                os.trycp("build/*.dll", package:installdir("bin"))
-                os.trycp("build/*.so", package:installdir("lib"))
-                os.trycp("build/*.dylib", package:installdir("lib"))
+                os.trycp(path.join(dir, "**.dll"), package:installdir("bin"))
+                os.trycp(path.join(dir, "*.lib"), package:installdir("lib"))
+                os.trycp(path.join(dir, "*.so"), package:installdir("lib"))
+                os.trycp(path.join(dir, "*.dylib"), package:installdir("lib"))
             else
-                os.trycp("build/*.a", package:installdir("lib"))
-                os.trycp("build/*.lib", package:installdir("lib"))
+                os.trycp(path.join(dir, "*.a"), package:installdir("lib"))
+                os.trycp(path.join(dir, "*.lib"), package:installdir("lib"))
+            end
+            if package:is_plat("windows") then
+                package:add("linkdirs", "lib")
+                package:add("links", "uvwasi_a")
             end
         end
     end)
 
     on_test(function (package)
-        assert(package:has_cfuncs("uvwasi_init", {includes = "uvwasi.h"}))
+        assert(package:check_csnippets({test = [[
+            void test() {
+                uvwasi_t uvwasi;
+                uvwasi_options_t options = {0};
+                uvwasi_init(&uvwasi, &options);
+            }
+        ]]}, {includes = "uvwasi.h"}))
     end)