-
-
Notifications
You must be signed in to change notification settings - Fork 816
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
add jar generate in swig mode #5536
Conversation
最近有点忙,等后两天我看下 |
I've been a little busy lately. I'll check it out in the next two days. |
xmake/rules/swig/xmake.lua
Outdated
autogenfiles = os.files(path.join(autogendir, "*.java")) | ||
local buildjar = target:extraconf("rules", "swig.c", "buildjar") or target:extraconf("rules", "swig.cpp", "buildjar") | ||
if buildjar then | ||
autogenfiles = path.join(autogendir , target:name()..".jar") |
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.
这里的 ,
和 ..
两边空格不对
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.
autogenfiles = path.join(autogendir, target:name() .. ".jar")
xmake/rules/swig/xmake.lua
Outdated
@@ -76,12 +76,23 @@ rule("swig.base") | |||
end | |||
local autogenfiles | |||
local autogendir = path.join(target:autogendir(), "rules", "swig") | |||
|
|||
local user_outdir = import("build_module_file").find_user_outdir(fileconfig) |
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.
这个 import 放到开头
-- jar build | ||
local buildjar = target:extraconf("rules", "swig.c", "buildjar") or target:extraconf("rules", "swig.cpp", "buildjar") | ||
if moduletype == "java" and buildjar then | ||
jar_build(target , fileconfig , opt) |
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.
,
两边空格不对
jar_build(target, fileconfig, opt)
@@ -73,3 +148,50 @@ function main(target, batchcmds, sourcefile, opt) | |||
batchcmds:set_depmtime(os.mtime(objectfile)) | |||
batchcmds:set_depcache(target:dependfile(objectfile)) | |||
end | |||
|
|||
|
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.
删掉一个空行
end | ||
|
||
|
||
|
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.
删掉多余的空行
-- user specified output path | ||
if fileconfig and fileconfig.swigflags then | ||
-- find -outdir path | ||
for i , par in pairs(fileconfig.swigflags) do |
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.
,
两边空格不对
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.
swigflags 是 array ,用 ipairs
end | ||
end | ||
|
||
function jar_build(target , fileconfig , opt) |
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 filelistname = os.tmpfile() | ||
local file = io.open(filelistname, "w") | ||
if file then | ||
for _, sourcebatch in pairs(autogenfiles) do |
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.
用 ipairs
|
||
-- compile to class file | ||
progress.show(opt.progress, "${color.build.object}compiling.javac %s class file", target:name()) | ||
os.vrunv(javac.program, {"--release", "17", "-d", jar_dst_dir , "@"..filelistname}) |
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.
..
两边加空格
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.
jar_dst_dir 后面的空格去掉
|
||
-- generate jar file | ||
progress.show(opt.progress, "${color.build.object}compiling.jar %s", target:name()..".jar") | ||
os.vrunv(jar.program, {"-cf" , path.join(java_src_dir , target:name()..".jar") , jar_dst_dir}) |
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 autogenfiles = os.files(path.join(java_src_dir, "*.java")) | ||
|
||
-- write file list | ||
local filelistname = os.tmpfile() |
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.
这个也挪到 autogendir 里去
@@ -63,6 +119,25 @@ function main(target, batchcmds, sourcefile, opt) | |||
end | |||
|
|||
table.insert(argv, sourcefile) | |||
return { argv = argv | |||
, objectfile = objectfile | |||
, swig = swig |
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.
逗号放后面
|
||
-- gen swig depend file , same with gcc .d | ||
local swigdep = os.tmpfile() | ||
local argv2 = {"-MMD" , "-MF" , swigdep} |
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.
,
前面空格去掉
compiler.compile(sourcefile_cx, objectfile, {target = target}) | ||
|
||
-- update depend file | ||
local deps = io.readfile(swigdep , {continuation = "\\"}) |
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.
还有这的 空格
thanks |
在使用swig生成java文件的场景下,添加javac和jar打包文件 这样可以直接使用jar包
使用方法如下 添加buildjar = true参数