ソースを参照

criterion: Add new package (#6732)

* Test criterion

* Try fix

* Try to prepend

* Cleaning

* try fix

* fixup

* try

* typo

* try fix fedora build

* Update xmake.lua

* fixup

* Try to rely over fixed EXPORT surface for static MinGW builds

* try bsd

* Testing fedora

* fixup

* fixup fedora

* try fix

* Try to make add_deps readable

* cl

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* test

* fixup

* fixup

* checks

* fixup

* Update xmake.lua

* Testing

* cl

* try cure

* Remove on_check, and winhttp syslink

* check for opt.packagedeps = {"llhttp", "openssl3", "pcre2"}

* try fix bsd

* rm fedora openssl1

* turn off `USE_GSSAPI`

* try help to macosx

* last try for macosx

* last try for fedora

* check fedora

* Test

* fixup

* clean

* Update xmake.lua

* fixup

---------

Co-authored-by: star9029 <[email protected]>
Saikari 5 ヶ月 前
コミット
b5b8095204

+ 29 - 0
packages/c/criterion/patch.lua

@@ -0,0 +1,29 @@
+function main(package)
+    io.replace("src/meson.build", [[libcriterion = both_libraries]], [[libcriterion = library]], {plain = true})
+    io.replace("meson.build", "git = find_program('git', required: false)", "", {plain = true})
+    io.replace("meson.build", "if git.found() and is_git_repo", "if false", {plain = true})
+    -- Swap from cmake to pkg-config
+    io.replace("meson.build",
+        [[nanopb = dependency('nanopb', required: get_option('wrap_mode') == 'nofallback', method: 'cmake',]],
+        [[nanopb = dependency('nanopb', method: 'pkg-config')]], {plain = true})
+    io.replace("meson.build", "modules: ['nanopb::protobuf-nanopb-static'])", "", {plain = true})
+    io.replace("meson.build",
+        [[libgit2 = dependency('libgit2', required: get_option('wrap_mode') == 'nofallback')]],
+        [[libgit2 = dependency('libgit2', method: 'pkg-config')]], {plain = true})
+    if package:is_plat("windows", "mingw") then
+        io.replace("src/compat/path.c", "defined (HAVE_GETCWD)", "0", {plain = true})
+        io.replace("src/compat/path.c", "defined (HAVE_GETCURRENTDIRECTORY)", "1", {plain = true})
+        if not package:config("shared") then
+            if package:is_plat("windows") then
+                io.replace("include/criterion/internal/common.h", "__declspec(dllimport)", "", {plain = true})
+            elseif package:is_plat("mingw") then
+                io.replace("include/criterion/internal/common.h", "CR_ATTRIBUTE(dllimport)", [[__attribute__((visibility("default")))]], {plain = true})
+            end
+        end
+        io.replace("src/entry/params.c", "#ifdef HAVE_ISATTY", "#if 0", {plain = true})
+        io.replace("src/entry/params.c", "opts[]", "opts[28]", {plain = true})
+    else
+        io.replace("src/compat/path.c", "defined (HAVE_GETCWD)", "1", {plain = true})
+        io.replace("src/compat/path.c", "defined (HAVE_GETCURRENTDIRECTORY)", "0", {plain = true})
+    end
+end

+ 61 - 0
packages/c/criterion/xmake.lua

@@ -0,0 +1,61 @@
+package("criterion")
+    set_homepage("https://github.com/Snaipe/Criterion")
+    set_description("A cross-platform C and C++ unit testing framework for the 21st century")
+    set_license("MIT")
+
+    add_urls("https://github.com/Snaipe/Criterion/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/Snaipe/Criterion.git")
+
+    add_versions("v2.4.2", "83e1a39c8c519fbef0d64057dc61c8100b3a5741595788c9f094bba2eeeef0df")
+
+    add_configs("i18n", {description = "Enable i18n", default = false, type = "boolean"})
+
+    if is_plat("windows", "mingw") then
+        add_syslinks("ws2_32", "mswsock")
+    elseif is_plat("linux", "bsd") then
+        add_syslinks("m", "pthread", "rt")
+    end
+
+    add_deps("meson", "ninja")
+    if is_subhost("windows") then
+        add_deps("pkgconf", "wingetopt")
+    else
+        add_deps("pkg-config")
+    end
+    add_deps("debugbreak", "klib", "libffi", "nanopb", "nanomsg", "libgit2")
+
+    on_load(function (package)
+        if package:is_plat("bsd") and package:config("shared") then
+            package:add("deps", "boxfort", {configs = {shared = true}})
+        else
+            package:add("deps", "boxfort")
+        end
+    end)
+
+    on_install("windows|!arm*", "linux", "macosx", "cross", "mingw@windows,msys", "bsd", "msys", function (package)
+        os.rm("subprojects")
+        import("patch")(package)
+        local opt = {}
+        --    Gather protoc-gen-nanopb from python3 pip
+        local python = package:is_plat("windows") and "python" or "python3"
+        os.vrun(python .. " -m pip install protobuf==5.29.3 nanopb==0.4.9.1")
+        if package:is_plat("bsd") then
+            opt.cflags = {"-Wno-error=incompatible-function-pointer-types"}
+            opt.packagedeps = {"llhttp", "openssl3", "pcre2"}
+        elseif package:is_plat("windows", "mingw") then
+            opt.packagedeps = {"wingetopt", "nanomsg", "pcre2", "libgit2"}
+            if package:has_tool("cxx", "cl") then
+                opt.cxflags = {"/utf-8"}
+            end
+        else
+            opt.packagedeps = {"libgit2"}
+        end
+        local configs = {"-Dtests=false", "-Dsamples=false", "-Dc_std=c11"}
+        table.insert(configs, "-Di18n=" .. (package:config("i18n") and "enabled" or "disabled"))
+        table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
+        import("package.tools.meson").install(package, configs, opt)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("criterion_handle_args", {includes = "criterion/criterion.h"}))
+    end)

+ 7 - 7
packages/l/libgit2/xmake.lua

@@ -119,24 +119,24 @@ package("libgit2")
             "-DBUILD_FUZZERS=OFF",
             "-DREGEX_BACKEND=pcre2",
             "-DUSE_HTTP_PARSER=llhttp",
+            "-DUSE_GSSAPI=OFF"
         }
         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, "-DUSE_SSH=" .. (package:config("ssh") and "ON" or "OFF"))
         table.insert(configs, "-DBUILD_CLI=" .. (package:config("tools") and "ON" or "OFF"))
-
+        local opt = {}
+        opt.packagedeps = {"pcre2"}
         if package:is_plat("mingw") then
             local mingw = import("detect.sdks.find_mingw")()
             local dlltool = assert(os.files(path.join(mingw.bindir, "*dlltool*"))[1], "dlltool not found!")
             table.insert(configs, "-DDLLTOOL=" .. dlltool)
         end
-
-        local opt = {}
-        local pcre2 = package:dep("pcre2")
-        if not pcre2:config("shared") then
-            opt.cxflags = "-DPCRE2_STATIC"
-        end
         import("package.tools.cmake").install(package, configs, opt)
+        if package:is_plat("linux") and linuxos.name() == "fedora" then
+            io.replace(path.join(package:installdir("lib/pkgconfig"), "libgit2.pc"), 
+                "Requires.private: openssl ", "Requires.private: openssl3 ", {plain = true})
+        end
     end)
 
     on_test(function (package)

+ 2 - 0
packages/n/nanopb/xmake.lua

@@ -10,6 +10,8 @@ package("nanopb")
 
     add_configs("generator", {description = "Build the protoc plugin for code generation", default = false, type = "boolean"})
 
+    add_includedirs("include", "include/nanopb")
+
     add_deps("cmake", "protoc")
 
     on_load(function (package)