Browse Source

add icu4c and boost

ruki 6 years ago
parent
commit
3baa963a54
2 changed files with 106 additions and 0 deletions
  1. 82 0
      packages/b/boost/xmake.lua
  2. 24 0
      packages/i/icu4c/xmake.lua

+ 82 - 0
packages/b/boost/xmake.lua

@@ -0,0 +1,82 @@
+package("boost")
+
+    set_homepage("https://www.boost.org/")
+    set_description("Collection of portable C++ source libraries.")
+
+    add_urls("https://dl.bintray.com/boostorg/release/$(version).tar.bz2", {version = function (version) 
+            return version .. "/source/boost_" .. (version:gsub("%.", "_"))
+        end})
+    add_versions("1.70.0", "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778")
+
+    if is_plat("linux") then
+        add_deps("bzip2", "zlib")
+    elseif is_plat("macosx") then
+        add_deps("icu4c")
+    end
+
+    add_configs("multi", { description = "Enable multi-thread support.", default = true, type = "boolean"})
+
+    on_install("macosx", "linux", function (package)
+    
+        -- force boost to compile with the desired compiler
+        local file = io.open("user-config.jam", "a")
+        if file then
+            if is_plat("macosx") then
+                file:print("using darwin : : %s ;", package:build_getenv("cxx"))
+            else
+                file:print("using gcc : : %s ;", package:build_getenv("cxx"))
+            end
+            file:close()
+        end
+
+        local bootstrap_argv = 
+        {
+            "--prefix=" .. package:installdir(), 
+            "--libdir=" .. package:installdir("lib"), 
+            "--without-libraries=python,mpi,log"
+        }
+        local icu4c = package:dep("icu4c")
+        if icu4c then
+            table.insert(bootstrap_argv, "--with-icu=" .. icu4c:installdir())
+        else
+            table.insert(bootstrap_argv, "--without-icu")
+        end
+        local argv =
+        {
+            "--prefix=" .. package:installdir(), 
+            "--libdir=" .. package:installdir("lib"), 
+            "-d2",
+            "-j4",
+            "--layout=tagged-1.66",
+            "--user-config=user-config.jam",
+            "--no-cmake-config",
+            "-sNO_LZMA=1",
+            "-sNO_ZSTD=1",
+            "install",
+            "threading=" .. (package:config("multi") and "multi" or "single"),
+            "link=static",
+            "cxxflags=-std=c++14"
+        }
+        os.vrunv("./bootstrap.sh", bootstrap_argv)
+        os.vrun("./b2 headers")
+        os.vrunv("./b2", argv)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <boost/algorithm/string.hpp>
+            #include <string>
+            #include <vector>
+            #include <assert.h>
+            using namespace boost::algorithm;
+            using namespace std;
+            static void test() {
+                string str("a,b");
+                vector<string> strVec;
+                split(strVec, str, is_any_of(","));
+                assert(strVec.size()==2);
+                assert(strVec[0]=="a");
+                assert(strVec[1]=="b");
+            }
+        ]]}, {configs = {languages = "c++14"}}))
+    end)

+ 24 - 0
packages/i/icu4c/xmake.lua

@@ -0,0 +1,24 @@
+package("icu4c")
+
+    set_homepage("https://ssl.icu-project.org/")
+    set_description("C/C++ and Java libraries for Unicode and globalization.")
+
+    add_urls("https://ssl.icu-project.org/files/icu4c/$(version)-src.tgz", {version = function (version)
+            return version .. "/icu4c-" .. (version:gsub("%.", "_"))
+        end})
+    add_urls("https://github.com/unicode-org/icu/releases/download/release-$(version)-src.tgz", {version = function (version)
+            return (version:gsub("%.", "-")) .. "/icu4c-" .. (version:gsub("%.", "_"))
+        end})
+
+    add_versions("64.2", "627d5d8478e6d96fc8c90fed4851239079a561a6a8b9e48b0892f24e82d31d6c")
+
+    add_links("icuuc", "icutu", "icui18n", "icuio", "icudata")
+
+    on_install("macosx", "linux", function (package)
+        os.cd("source")
+        import("package.tools.autoconf").install(package, {"--disable-samples", "--disable-tests", "--enable-static", "--disable-shared"})
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("ucnv_convert", {includes = "unicode/ucnv.h"}))
+    end)