-
-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support ispc compiler #3017
support ispc compiler #3017
Conversation
tests/projects/other/ispc/xmake.lua
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use object kind? Example projects should be as simple as possible
target("test")
set_kind("binary")
add_rules("utils.ispc", {header_extension = "_ispc.h"})
set_values("ispc.flags", "--target=host")
add_files("src/*.ispc")
add_files("src/*.cpp")
tests/projects/other/ispc/xmake.lua
Outdated
@@ -0,0 +1,16 @@ | |||
add_rules("mode.debug", "mode.release") | |||
|
|||
includes("ispc.lua") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove it.
xmake/rules/utils/ispc/ispc.lua
Outdated
@@ -0,0 +1,77 @@ | |||
rule("utils.ispc") | |||
set_extensions(".ispc") | |||
add_deps("utils.inherit.links") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove it
xmake/rules/utils/ispc/ispc.lua
Outdated
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use batchcmds:mkdir
in before_buildcmd_file, only obj_outputdir need be create here
xmake/rules/utils/ispc/ispc.lua
Outdated
before_buildcmd_file(function (target, batchcmds, sourcefile_ispc, opt) | ||
import("lib.detect.find_tool") | ||
ispc = find_tool("ispc") | ||
assert(ispc, "ispc not found!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing local keyword
local ispc = assert(find_tool("ispc"), "ispc not found!")
xmake/rules/utils/ispc/ispc.lua
Outdated
header_file = path.join(header_outputdir, path.filename(sourcefile_ispc) .. ".h") | ||
end | ||
|
||
batchcmds:show_progress(opt.progress, "${color.build.object}cache compiling %s", sourcefile_ispc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove cache
prefix
"${color.build.object}cache compiling.ispc %s"
xmake/rules/utils/ispc/ispc.lua
Outdated
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to objectfile
xmake/rules/utils/ispc/ispc.lua
Outdated
end | ||
|
||
local header_outputdir = path.join(target:autogendir(), "ispc_headers") | ||
local obj_outputdir = path.join(target:autogendir(), "ispc_objs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objectdir
xmake/rules/utils/ispc/ispc.lua
Outdated
obj_extension = ".obj" | ||
end | ||
|
||
local header_outputdir = path.join(target:autogendir(), "ispc_headers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headersdir
xmake/rules/utils/ispc/ispc.lua
Outdated
batchcmds:vrunv(ispc.program, table.join2(flags, | ||
{"-o", obj_file, | ||
"-h", header_file, | ||
path.join(os.projectdir(), sourcefile_ispc)})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use sourcefile_ispc
directly
xmake/rules/utils/ispc/ispc.lua
Outdated
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need use path(headerfile)
to wrap it for supporting project generator.
xmake/rules/utils/ispc/ispc.lua
Outdated
|
||
batchcmds:show_progress(opt.progress, "${color.build.object}cache compiling %s", sourcefile_ispc) | ||
batchcmds:vrunv(ispc.program, table.join2(flags, | ||
{"-o", obj_file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path(objectfile)
xmake/rules/utils/ispc/ispc.lua
Outdated
end | ||
|
||
batchcmds:show_progress(opt.progress, "${color.build.object}cache compiling %s", sourcefile_ispc) | ||
batchcmds:vrunv(ispc.program, table.join2(flags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use table.insert to insert flags first. it will avoid once object copy.
xmake/rules/utils/ispc/ispc.lua
Outdated
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate set_depmtime
and set_depcache
, you can only set once
xmake/rules/utils/ispc/ispc.lua
Outdated
set_extensions(".ispc") | ||
|
||
on_load(function (target) | ||
local header_outputdir = path.join(target:autogendir(), "ispc_headers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local headersdir = path.join(target:autogendir(), "rules", "utils", "ispc", "headers")
xmake/rules/utils/ispc/ispc.lua
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
xmake/rules/utils/ispc/ispc.lua
Outdated
obj_extension = ".obj" | ||
end | ||
|
||
local headersdir = path.join(target:autogendir(), "ispc_headers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local headersdir = path.join(target:autogendir(), "rules", "utils", "ispc", "headers")
xmake/rules/utils/ispc/ispc.lua
Outdated
end | ||
|
||
local headersdir = path.join(target:autogendir(), "ispc_headers") | ||
local objectdir = path.join(target:autogendir(), "ispc_objs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
xmake/rules/utils/ispc/ispc.lua
Outdated
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local objectfile = target:objectfile(sourcefile_ispc)
xmake/rules/utils/ispc/ispc.lua
Outdated
|
||
local headersdir = path.join(target:autogendir(), "rules", "utils", "ispc", "headers") | ||
local objectdir = path.join(target:autogendir(), "rules", "utils", "ispc", "objs") | ||
local objectfile = path.join(objectdir, path.filename(target:objectfile(sourcefile_ispc))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local objectfile = target:objectfile(sourcefile_ispc)
local objectdir = path.directory(objectfile)
No description provided.