From b694c92ef96aa2892a0703d7d212703786c6d111 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 16 Sep 2020 00:12:46 +0800 Subject: [PATCH] improve bin2c --- packages/b/bin2c/xmake.lua | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/b/bin2c/xmake.lua b/packages/b/bin2c/xmake.lua index 4a24e5c4a..b24b0bbbb 100644 --- a/packages/b/bin2c/xmake.lua +++ b/packages/b/bin2c/xmake.lua @@ -9,23 +9,25 @@ package("bin2c") add_versions("0.0.1", "598395c23508bd4a2c916bfdab8c04a101abc62e") add_patches("0.0.1", path.join(os.scriptdir(), "patches", "0.0.1", "bin2c-test.patch"), "e3c8b80948dba824d8ffa0c3294f9b32ca3001c77a80b45f02a46a1e8586a7e1") - on_install(function (package) - if is_host("linux", "macosx") then - os.vrun("make bin2c") - os.cp("bin2c", package:installdir("bin")) - elseif is_host("windows") then - import("lib.detect.find_tool") - if is_plat("windows") then - import("core.tool.toolchain") - local runenvs = toolchain.load("msvc"):runenvs() - local compiler = find_tool("cl", {envs = runenvs}) - os.vrunv(compiler.program, {"bin2c.c"}, {envs = runenvs}) - elseif is_plat("mingw") then - local compiler = find_tool("gcc") - os.vrunv(compiler.program, {"-obin2c.exe", "bin2c.c"}) - end - os.cp("bin2c.exe", package:installdir("bin")) - end + on_install("@linux", "@macosx", function (package) + os.vrun("make bin2c") + os.cp("bin2c", package:installdir("bin")) + end) + + on_install("@windows", function (package) + import("lib.detect.find_tool") + import("core.tool.toolchain") + local runenvs = toolchain.load("msvc"):runenvs() + local compiler = find_tool("cl", {envs = runenvs}) + os.vrunv(compiler.program, {"bin2c.c"}, {envs = runenvs}) + os.cp("bin2c.exe", package:installdir("bin")) + end) + + on_install("mingw@windows", function (package) + import("lib.detect.find_tool") + local compiler = find_tool("gcc") + os.vrunv(compiler.program, {"-obin2c.exe", "bin2c.c"}) + os.cp("bin2c.exe", package:installdir("bin")) end) on_test(function (package)