pseudo-double: add package (#3294)
* pseudo-double: add package * pseudo-double: add license * pseudo-double: only cxx11 * pseudo-double: add configs and include stdbool * pseudo-double: fix pd_error_check description * pseudo-double: add brackets * pseudo-double: remove c99 * pseudo-double: define __int128 if not defined * pseudo-double: remove define __int128 * pseudo-double: remove empty configs * pseudo-double: test add_cxxflags for Mac * pseudo-double: add <string> to PseudoDouble * pseudo-double: add 'clang::,' * pseudo-double: use cxx14 for mac * pseudo-double: add limits * pseudo-double: add on_config * pseudo-double: add fix_build patch * pseudo-double: comment * pseudo-double: test add `-std=c++1y` for mac * pseudo-double: use `-std=c++11` * pseudo-double: use cxxflags * pseudo-double: use `no-error=reserved-user-defined-literal` * pseudo-double: use c++11 * pseudo-double: update patch * pseudo-double: add limits * pseudo-double: linux shared off * pseudo-double: separate into 2 packages * pseudo-double: fix package names * pseudo-double-c: remove add_patches * pseudo-double-cpp: add limits * pseudo-double: update limits * pseudo-double-c: add wasm * pseudo-double-cpp: remove unneeded code * pseudo-double-cpp: remove unneeded on_config * Update xmake.lua * pseudo-double-cpp: use port for add_requires * pseudo-double-cpp: use `get_config("kind")` * pseudo-double-cpp: change shared to kind --------- Co-authored-by: ruki <waruqi@gmail.com>pull/3299/head
parent
0f239d0ba8
commit
94e606e613
3 changed files with 100 additions and 0 deletions
@ -0,0 +1,49 @@ |
||||
package("pseudo-double-c") |
||||
set_homepage("https://github.com/royward/pseudo-double") |
||||
set_description("A relatively fast C and C++ 64 bit floating point library written using only integer operations for cross platform consistency. Tested with gcc/clang/Visual Studio, on x86-64/ARMv8 (64 bit)") |
||||
set_license("BSD-3-Clause") |
||||
|
||||
add_urls("https://github.com/royward/pseudo-double.git") |
||||
|
||||
add_versions("2024.01.17", "275b244eee40b987a209927d7942d4bf83d91c95") |
||||
|
||||
add_configs("pseudo_double_exp_bits", {description = "This sets the number of bits in the exponent, defaulting to 16 if not set.", default = "16", type = "string", values = {"8", "16", "32"}}) |
||||
add_configs("pd_error_check", {description = "This enables error checking in the library, defaulting to true if not set.", default = true, type = "boolean"}) |
||||
|
||||
on_install("windows|x64", "linux|x86_64", "macosx", "bsd", "android|arm64*", "wasm", function (package) |
||||
local configs = {} |
||||
io.replace("pseudo_double.h", "#include <stdint.h>", "#include <stdint.h>\n#include <stdbool.h>", {plain = true}) |
||||
io.writefile("xmake.lua", [[ |
||||
add_rules("mode.release", "mode.debug") |
||||
target("pseudo-double-c") |
||||
set_kind("$(kind)") |
||||
set_languages("c99") |
||||
|
||||
if is_plat("windows") then |
||||
add_defines("_MSC_VER") |
||||
end |
||||
|
||||
add_files("pseudo_double.c") |
||||
add_headerfiles("(pseudo_double.h)") |
||||
|
||||
on_config(function (target) |
||||
if target:has_tool("gcc", "gxx") then |
||||
target:add("defines", "__GNUC__") |
||||
elseif target:has_tool("cc", "cxx", "clang", "clangxx") then |
||||
target:add("defines", "__clang__") |
||||
end |
||||
end) |
||||
]]) |
||||
package:add("defines", "PSEUDO_DOUBLE_EXP_BITS=" .. package:config("pseudo_double_exp_bits")) |
||||
package:add("defines", "PD_ERROR_CHECK=" .. (package:config("pd_error_check") and "1" or "0")) |
||||
import("package.tools.xmake").install(package) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
#include <pseudo_double.h> |
||||
void test() { |
||||
pseudo_double a_1 = int64fixed10_to_pd(3, -1); |
||||
} |
||||
]]})) |
||||
end) |
@ -0,0 +1,18 @@ |
||||
add_rules("mode.debug", "mode.release") |
||||
|
||||
option("pseudo_double_exp_bits", {default = "16", showmenu = true, description = "This sets the number of bits in the exponent, defaulting to 16 if not set."}) |
||||
option("pd_error_check", {default = true, showmenu = true, description = "This enables error checking in the library, defaulting to true if not set."}) |
||||
|
||||
add_requires("pseudo-double-c", {configs = {kind = get_config("kind"), pseudo_double_exp_bits = get_config("pseudo_double_exp_bits"), pd_error_check = get_config("pd_error_check")}}) |
||||
|
||||
target("pseudo-double-cpp") |
||||
set_kind("$(kind)") |
||||
set_languages("c++11") |
||||
add_packages("pseudo-double-c") |
||||
|
||||
if is_plat("windows") then |
||||
add_defines("_MSC_VER") |
||||
end |
||||
|
||||
add_files("pseudo_double.cpp") |
||||
add_headerfiles("(PseudoDouble.h)") |
@ -0,0 +1,33 @@ |
||||
package("pseudo-double-cpp") |
||||
set_homepage("https://github.com/royward/pseudo-double") |
||||
set_description("A relatively fast C and C++ 64 bit floating point library written using only integer operations for cross platform consistency. Tested with gcc/clang/Visual Studio, on x86-64/ARMv8 (64 bit)") |
||||
set_license("BSD-3-Clause") |
||||
|
||||
add_urls("https://github.com/royward/pseudo-double.git") |
||||
|
||||
add_versions("2024.01.17", "275b244eee40b987a209927d7942d4bf83d91c95") |
||||
|
||||
add_configs("pseudo_double_exp_bits", {description = "This sets the number of bits in the exponent, defaulting to 16 if not set.", default = "16", type = "string", values = {"8", "16", "32"}}) |
||||
add_configs("pd_error_check", {description = "This enables error checking in the library, defaulting to true if not set.", default = true, type = "boolean"}) |
||||
|
||||
on_load(function (package) |
||||
package:add("deps", "pseudo-double-c", {configs = {shared = package:config("shared"), pseudo_double_exp_bits = package:config("pseudo_double_exp_bits"), pd_error_check = package:config("pd_error_check")}}) |
||||
end) |
||||
|
||||
on_install("windows|x64", "linux|x86_64", "bsd", "android|arm64*", function (package) |
||||
io.replace("PseudoDouble.h", "#include <stdexcept>", "#include <stdexcept>\n#include <string>", {plain = true}) |
||||
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||
local configs = {} |
||||
configs.pseudo_double_exp_bits = package:config("pseudo_double_exp_bits") |
||||
configs.pd_error_check = package:config("pd_error_check") |
||||
import("package.tools.xmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
#include <PseudoDouble.h> |
||||
void test() { |
||||
PseudoDouble a_2 = PD_create_fixed10(3,-1); |
||||
} |
||||
]]})) |
||||
end) |
Loading…
Reference in new issue