diff options
| author | star-hengxing <[email protected]> | 2022-11-04 15:16:23 +0800 |
|---|---|---|
| committer | star-hengxing <[email protected]> | 2022-11-04 15:16:23 +0800 |
| commit | de83803cdb0c2ab94fbcd203f831602c7d418fe1 (patch) | |
| tree | 0b9555fd961a724d1ebdd55c7a889f9421160319 | |
| parent | f3e2f3cda0372e4d64c2aa83b1fd5c101e349417 (diff) | |
improve utils.ispc
| -rw-r--r-- | tests/projects/other/ispc/xmake.lua | 14 | ||||
| -rw-r--r-- | xmake/rules/utils/ispc/ispc.lua | 41 |
2 files changed, 22 insertions, 33 deletions
diff --git a/tests/projects/other/ispc/xmake.lua b/tests/projects/other/ispc/xmake.lua index a7311abec..577c6798b 100644 --- a/tests/projects/other/ispc/xmake.lua +++ b/tests/projects/other/ispc/xmake.lua @@ -1,16 +1,8 @@ add_rules("mode.debug", "mode.release") -includes("ispc.lua") - -target("test_ispc") - set_kind("object") - add_rules("utils.ispc", {header_extension = "_ispc.h"}) - add_files("src/*.ispc") - set_values("ispc.flags", "--target=host") - set_policy("build.across_targets_in_parallel", false) - target("test") set_kind("binary") - add_deps("test_ispc") + add_rules("utils.ispc", {header_extension = "_ispc.h"}) + set_values("ispc.flags", "--target=host") + add_files("src/*.ispc") add_files("src/*.cpp") - diff --git a/xmake/rules/utils/ispc/ispc.lua b/xmake/rules/utils/ispc/ispc.lua index 9a65e5d94..d5a4660d2 100644 --- a/xmake/rules/utils/ispc/ispc.lua +++ b/xmake/rules/utils/ispc/ispc.lua @@ -1,18 +1,14 @@ rule("utils.ispc") set_extensions(".ispc") - add_deps("utils.inherit.links") on_load(function (target) local header_outputdir = path.join(target:autogendir(), "ispc_headers") - local obj_outputdir = path.join(target:autogendir(), "ispc_objs") - os.mkdir(target:autogendir()) os.mkdir(header_outputdir) - os.mkdir(obj_outputdir) target:add("includedirs", header_outputdir, {public = true}) end) before_buildcmd_file(function (target, batchcmds, sourcefile_ispc, opt) import("lib.detect.find_tool") - ispc = find_tool("ispc") + local ispc = find_tool("ispc") assert(ispc, "ispc not found!") local flags = {} @@ -49,29 +45,30 @@ rule("utils.ispc") obj_extension = ".obj" end - local header_outputdir = path.join(target:autogendir(), "ispc_headers") - local obj_outputdir = path.join(target:autogendir(), "ispc_objs") - local obj_file = path.join(obj_outputdir, path.filename(sourcefile_ispc) .. obj_extension) + local headersdir = path.join(target:autogendir(), "ispc_headers") + local objectdir = path.join(target:autogendir(), "ispc_objs") + local objectfile = path.join(objectdir, path.filename(sourcefile_ispc) .. obj_extension) + batchcmds:mkdir(objectdir) - local header_file + local headersfile local header_extension = target:extraconf("rules", "utils.ispc", "header_extension") if header_extension then - header_file = path.join(header_outputdir, path.basename(sourcefile_ispc) .. header_extension) + headersfile = path.join(headersdir, path.basename(sourcefile_ispc) .. header_extension) else - header_file = path.join(header_outputdir, path.filename(sourcefile_ispc) .. ".h") + headersfile = path.join(headersdir, path.filename(sourcefile_ispc) .. ".h") end - batchcmds:show_progress(opt.progress, "${color.build.object}cache compiling %s", sourcefile_ispc) - batchcmds:vrunv(ispc.program, table.join2(flags, - {"-o", obj_file, - "-h", header_file, - path.join(os.projectdir(), sourcefile_ispc)})) + table.insert(flags, "-o") + table.insert(flags, path(objectfile)) + table.insert(flags, "-h") + table.insert(flags, path(headersfile)) + table.insert(flags, path(sourcefile_ispc)) + batchcmds:show_progress(opt.progress, "${color.build.object}compiling %s", sourcefile_ispc) + batchcmds:vrunv(ispc.program, flags) - table.insert(target:objectfiles(), obj_file) + table.insert(target:objectfiles(), objectfile) - batchcmds:add_depfiles(sourcefile_ispc) - batchcmds:set_depmtime(os.mtime(obj_file)) - batchcmds:set_depcache(target:dependfile(obj_file)) - batchcmds:set_depmtime(os.mtime(header_file)) - batchcmds:set_depcache(target:dependfile(header_file)) + batchcmds:add_depfiles(sourcefile_ispc, headersfile) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end)
\ No newline at end of file |
