-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
ninja: error: build.ninja:68: unknown build rule 'cu' #5646
Comments
Xmake version2.9.4 Operating system version and architectureArchlinux Describe the problemThe build.ninja generated by Expected resultsninja can compile successfully Project configurationxmake create [project_name]
mv src/main.cpp src/main.cu add_rules("mode.debug", "mode.release")
target("xmake_cuda_ninja_test")
set_kind("binary")
add_files("src/*.cu") Additional information and error logsCreate OK! |
我暂时没有 cuda 环境,你可以自己在这个位置加上
|
I don’t have a cuda environment for the time being. You can try adding the
|
rule name 很早就加了,所以这里加一行就能编译正常 cuda 代码。不过 devlink 不是基于 batchcmd,目前不太好处理。 diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua
index 2e55faf05..4d913a3ea 100644
--- a/xmake/plugins/project/ninja/build_ninja.lua
+++ b/xmake/plugins/project/ninja/build_ninja.lua
@@ -182,6 +182,14 @@ function _add_rules_for_compiler_windres(ninjafile, sourcekind, program)
ninjafile:print("")
end
+-- add rules for complier (cuda/nvcc)
+function _add_rules_for_compiler_cuda(ninjafile, sourcekind, program)
+ ninjafile:print("rule %s", sourcekind)
+ ninjafile:print(" command = %s -c $ARGS $in -o $out", program)
+ ninjafile:print(" description = compiling.%s $in", config.mode())
+ ninjafile:print("")
+end
+
-- add rules for complier
function _add_rules_for_compiler(ninjafile)
ninjafile:print("# rules for compiler")
@@ -203,7 +211,8 @@ function _add_rules_for_compiler(ninjafile)
ml = _add_rules_for_compiler_msvc_ml,
ml64 = _add_rules_for_compiler_msvc_ml,
rc = _add_rules_for_compiler_msvc_rc,
- windres = _add_rules_for_compiler_windres
+ windres = _add_rules_for_compiler_windres,
+ nvcc = _add_rules_for_compiler_cuda,
}
for sourcekind, _ in pairs(language.sourcekinds()) do
local program, toolname = platform.tool(sourcekind)
|
The rule name was added very early, so adding one line here can compile normal cuda code. However, devlink is not based on batchcmd and is currently not easy to handle. diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua
index 2e55faf05..4d913a3ea 100644
--- a/xmake/plugins/project/ninja/build_ninja.lua
+++ b/xmake/plugins/project/ninja/build_ninja.lua
@@ -182,6 +182,14 @@ function _add_rules_for_compiler_windres(ninjafile, sourcekind, program)
ninjafile:print("")
end
+-- add rules for complier (cuda/nvcc)
+function _add_rules_for_compiler_cuda(ninjafile, sourcekind, program)
+ ninjafile:print("rule %s", sourcekind)
+ ninjafile:print(" command = %s -c $ARGS $in -o $out", program)
+ ninjafile:print(" description = compiling.%s $in", config.mode())
+ ninjafile:print("")
+end
+
-- add rules for complier
function _add_rules_for_compiler(ninjafile)
ninjafile:print("# rules for compiler")
@@ -203,7 +211,8 @@ function _add_rules_for_compiler(ninjafile)
ml = _add_rules_for_compiler_msvc_ml,
ml64 = _add_rules_for_compiler_msvc_ml,
rc = _add_rules_for_compiler_msvc_rc,
- windres = _add_rules_for_compiler_windres
+ windres = _add_rules_for_compiler_windres,
+ nvcc = _add_rules_for_compiler_cuda,
}
for sourcekind, _ in pairs(language.sourcekinds()) do
local program, toolname = platform.tool(sourcekind)
|
Xmake 版本
2.9.4
操作系统版本和架构
Archlinux
描述问题
xmake project -k ninja
生成的build.ninja没有cuda编译相关的rule,不能正常编译但是直接xmake build可以
期待的结果
ninja能够成功编译
工程配置
附加信息和错误日志
create ok!
The text was updated successfully, but these errors were encountered: