Browse Source

Improve ntkernel-error-category (#1652)

* Add ntkernel-error-category

* Remove empty lines

* Convert ntkernel-error-category to XMake

ned14 cmake is horrible :D
Arthur Laurent 2 years ago
parent
commit
66a30c4c7c

+ 23 - 0
packages/n/ntkernel-error-category/port/xmake.lua

@@ -0,0 +1,23 @@
+if is_plat("windows", "mingw") then
+    target("generate-table")
+        set_kind("binary")
+        set_languages("c++17")
+        add_files("src/generate-table.cpp")
+        add_defines("_UNICODE", "UNICODE")
+end
+
+target("ntkernel-error-category")
+    set_kind("$(kind)")
+    set_languages("c++17")
+    add_headerfiles("include/(ntkernel-error-category/*.hpp)")
+    add_includedirs("include")
+
+    if not is_kind("headeronly") then
+        add_files("src/ntkernel_category.cpp")
+        if is_kind("static") then
+            add_defines("NTKERNEL_ERROR_CATEGORY_STATIC", { public = true })
+        end
+    else
+        add_defines("NTKERNEL_ERROR_CATEGORY_INLINE", { public = true })
+        add_headerfiles("include/(ntkernel-error-category/detail/*.ipp)")
+    end

+ 9 - 10
packages/n/ntkernel-error-category/xmake.lua

@@ -7,19 +7,18 @@ package("ntkernel-error-category")
              "https://github.com/ned14/ntkernel-error-category.git")
     add_versions("v1.0.0", "481b60ac0b1d2c179120b3e6589884217508b6b5025a25dd6bf47399aa5d2cc5")
 
-    add_configs("header_only", {description = "Use header only version. (not supported atm)", default = false, type = "boolean", readonly = true})
+    add_configs("headeronly", {description = "Use header only version.", default = true, type = "boolean"})
 
-    add_deps("cmake")
     on_install(function (package)
-        local configs = {"-DPROJECT_IS_DEPENDENCY=ON", "-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON"}
-        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
-        local target = "ntkernel-error-category_"
-        if package:config("header_only") then
-            target = target .. "hl" 
-        else 
-            target = target .. (package:config("shared") and "_dl" or "_sl")
+        local configs = {}
+        if package:config("headeronly") then
+            configs.kind = "headeronly"
+            package:add("defines", "NTKERNEL_ERROR_CATEGORY_INLINE")
+        elseif not package:config("configs.shared") then
+            package:add("defines", "NTKERNEL_ERROR_CATEGORY_STATIC")
         end
-        import("package.tools.cmake").install(package, configs, { target = target })
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package, configs)
     end)
 
     on_test(function (package)