From cc943158a9e195490c1584722ebd9c5b461221c8 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 23 Jul 2019 22:39:42 +0800 Subject: [PATCH] improve boost --- packages/b/boost/xmake.lua | 109 ++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/packages/b/boost/xmake.lua b/packages/b/boost/xmake.lua index 11c910ab8..76c829c69 100644 --- a/packages/b/boost/xmake.lua +++ b/packages/b/boost/xmake.lua @@ -15,25 +15,47 @@ package("boost") add_deps("bzip2", "zlib") end - add_configs("multi", { description = "Enable multi-thread support.", default = true, type = "boolean"}) - add_configs("filesystem", { description = "Enable filesystem library.", default = true, type = "boolean"}) - add_configs("fiber", { description = "Enable fiber library.", default = false, type = "boolean"}) - add_configs("coroutine", { description = "Enable coroutine library.", default = false, type = "boolean"}) - add_configs("context", { description = "Enable context library.", default = false, type = "boolean"}) - add_configs("thread", { description = "Enable thread library.", default = false, type = "boolean"}) - add_configs("regex", { description = "Enable regex library.", default = false, type = "boolean"}) - add_configs("system", { description = "Enable system library.", default = false, type = "boolean"}) - add_configs("container", { description = "Enable container library.", default = false, type = "boolean"}) - add_configs("exception", { description = "Enable exception library.", default = false, type = "boolean"}) - add_configs("timer", { description = "Enable timer library.", default = false, type = "boolean"}) - add_configs("atomic", { description = "Enable atomic library.", default = false, type = "boolean"}) - add_configs("graph", { description = "Enable graph library.", default = false, type = "boolean"}) - add_configs("serialization", { description = "Enable serialization library.", default = false, type = "boolean"}) - add_configs("random", { description = "Enable random library.", default = false, type = "boolean"}) - add_configs("wave", { description = "Enable wave library.", default = false, type = "boolean"}) - add_configs("date_time", { description = "Enable date time library.", default = false, type = "boolean"}) - add_configs("locale", { description = "Enable locale library.", default = false, type = "boolean"}) - add_configs("iostreams", { description = "Enable iostreams library.", default = false, type = "boolean"}) + local libnames = {"filesystem", + "fiber", + "coroutine", + "context", + "thread", + "regex", + "system", + "container", + "exception", + "timer", + "atomic", + "graph", + "serialization", + "random", + "wave", + "date_time", + "locale", + "iostreams"} + + add_configs("multi", { description = "Enable multi-thread support.", default = true, type = "boolean"}) + for _, libname in ipairs(libnames) do + add_configs(libname, { description = "Enable " .. libname .. " library.", default = (libname == "filesystem"), type = "boolean"}) + end + + on_load("windows", function (package) + local vs_runtime = package:config("vs_runtime") + for _, libname in ipairs(libnames) do + local linkname = "libboost_" .. libname + if package:config("multi") then + linkname = linkname .. "-mt" + end + if vs_runtime == "MT" then + linkname = linkname .. "-s" + elseif vs_runtime == "MTd" then + linkname = linkname .. "-sgd" + elseif vs_runtime == "MDd" then + linkname = linkname .. "-gd" + end + package:add("links", linkname) + end + end) on_install("macosx", "linux", "windows", function (package) @@ -56,45 +78,20 @@ package("boost") "--libdir=" .. package:installdir("lib"), "--without-icu" } - local libs_enabled = {} - local libs_disabled = {} - local libnames = {"filesystem", - "fiber", - "coroutine", - "context", - "thread", - "regex", - "system", - "container", - "exception", - "timer", - "atomic", - "graph", - "serialization", - "random", - "wave", - "date_time", - "locale", - "iostreams"} - for _, libname in ipairs(libnames) do - if package:config(libname) then - table.insert(libs_enabled, libname) - else - table.insert(libs_disabled, libname) - end - end - if #libs_enabled > 0 then - table.insert(bootstrap_argv, "--with-libraries=" .. table.concat(libs_enabled, ",")) - end - if #libs_disabled > 0 then - table.insert(bootstrap_argv, "--without-libraries=" .. table.concat(libs_disabled, ",")) + if is_host("windows") then + os.vrunv("bootstrap.bat", bootstrap_argv) + else + os.vrunv("./bootstrap.sh", bootstrap_argv) end + os.vrun("./b2 headers") + local argv = { "--prefix=" .. package:installdir(), "--libdir=" .. package:installdir("lib"), "-d2", "-j4", + "--hash", "--layout=tagged-1.66", "--user-config=user-config.jam", "--no-cmake-config", @@ -118,15 +115,15 @@ package("boost") else table.insert(argv, "runtime-link=shared") end + table.insert(argv, "cxxflags=-std:c++14") else table.insert(argv, "cxxflags=-std=c++14") end - if is_host("windows") then - os.vrunv("bootstrap.bat", bootstrap_argv) - else - os.vrunv("./bootstrap.sh", bootstrap_argv) + for _, libname in ipairs(libnames) do + if package:config(libname) then + table.insert(argv, "--with-" .. libname) + end end - os.vrun("./b2 headers") os.vrunv("./b2", argv) end)