Bladeren bron

ocilib: add package (#2899)

* ocilib: add package

* fix test

* fix cpp error
star9029 1 jaar geleden
bovenliggende
commit
01518b31ed
2 gewijzigde bestanden met toevoegingen van 62 en 0 verwijderingen
  1. 27 0
      packages/o/ocilib/port/xmake.lua
  2. 35 0
      packages/o/ocilib/xmake.lua

+ 27 - 0
packages/o/ocilib/port/xmake.lua

@@ -0,0 +1,27 @@
+add_rules("mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel")
+
+option("unicode", {showmenu = true,  default = true})
+
+target("ocilib")
+    set_kind("$(kind)")
+    add_files("src/*.c")
+    add_includedirs("src")
+    add_includedirs("include", {public = true})
+    add_headerfiles("include/(**.h)", "include/(**.hpp)")
+
+    if is_kind("static") then
+        add_defines("OCI_LIB_LOCAL_COMPILE", {public = true})
+    end
+
+    if is_plat("windows") and is_kind("shared") then
+        add_files("proj/dll/main.rc")
+        add_defines("OCI_EXPORT")
+    end
+
+    if has_config("unicode") then
+        add_defines("OCI_CHARSET_WIDE")
+    else
+        add_defines("OCI_CHARSET_ANSI")
+    end
+
+    add_defines("OCI_IMPORT_RUNTIME")

+ 35 - 0
packages/o/ocilib/xmake.lua

@@ -0,0 +1,35 @@
+package("ocilib")
+    set_homepage("http://www.ocilib.net")
+    set_description("OCILIB (C and C++ Drivers for Oracle) - Open source C and C++ library for accessing Oracle databases")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/vrogier/ocilib/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/vrogier/ocilib.git")
+
+    add_versions("v4.7.6", "43f5093cac645518ad5bc8d6f48f5b77e12372ef84dc87ddb3a54c40e425bd26")
+
+    add_configs("unicode", {description = "Enable Unicode", default = true, type = "boolean"})
+
+    on_install(function (package)
+        local configs = {
+            unicode = package:config("unicode")
+        }
+        if not package:config("shared") then
+            package:add("defines", "OCI_LIB_LOCAL_COMPILE")
+        end
+        io.replace("include/ocilibcpp/detail/core/SmartHandle.hpp",
+            ".Set<SmartHandle*>",
+            ".template Set<SmartHandle*>", {plain = true})
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("OCI_Initialize", {includes = "ocilib.h"}))
+        assert(package:check_cxxsnippets({test = [[
+            #include <ocilib.hpp>
+            void test() {
+                ocilib::Environment::Initialize();
+            }
+        ]]}, {configs = {languages = "c++11"}}))
+    end)