diff options
| author | ririyeye <[email protected]> | 2024-09-02 14:09:10 +0800 |
|---|---|---|
| committer | ririyeye <[email protected]> | 2024-09-02 14:09:10 +0800 |
| commit | 6cad7300ea2de380863c1f46e896a372b74d84a7 (patch) | |
| tree | 2a4c5c125115e41eced45e4dbafaab38a8d65a2f | |
| parent | 306faf3772a7dd183ce478b1db69ac3d6a3da90e (diff) | |
add swig find_user_outdir
| -rw-r--r-- | xmake/rules/swig/build_module_file.lua | 29 | ||||
| -rw-r--r-- | xmake/rules/swig/xmake.lua | 18 |
2 files changed, 20 insertions, 27 deletions
diff --git a/xmake/rules/swig/build_module_file.lua b/xmake/rules/swig/build_module_file.lua index 8c568d00d..451e65d40 100644 --- a/xmake/rules/swig/build_module_file.lua +++ b/xmake/rules/swig/build_module_file.lua @@ -24,26 +24,31 @@ import("utils.progress") import("core.project.depend") import("core.tool.compiler") -function jar_build(target , fileconfig , opt) - local javac = assert(find_tool("javac"), "javac not found!") - local jar = assert(find_tool("jar"), "jar not found!") - - local java_src_dir = path.join(target:autogendir(), "rules", "swig") - local jar_dst_dir = path.join(target:autogendir(), "rules", "swig") - +function find_user_outdir(fileconfig) -- user specified output path if fileconfig and fileconfig.swigflags then -- find -outdir path - local idx = -1 for i , par in pairs(fileconfig.swigflags) do if par == "-outdir" then - idx = i + local dirpath = fileconfig.swigflags[i + 1] + if os.isdir(dirpath) then + return dirpath + end end end + end +end - if idx > 0 then - java_src_dir = fileconfig.swigflags[idx + 1] - end +function jar_build(target , fileconfig , opt) + local javac = assert(find_tool("javac"), "javac not found!") + local jar = assert(find_tool("jar"), "jar not found!") + + local java_src_dir = path.join(target:autogendir(), "rules", "swig") + local jar_dst_dir = path.join(target:autogendir(), "rules", "swig") + + local user_outdir = find_user_outdir(fileconfig) + if user_outdir then + java_src_dir = user_outdir end -- get java files diff --git a/xmake/rules/swig/xmake.lua b/xmake/rules/swig/xmake.lua index 5fc1745c4..915d1bd66 100644 --- a/xmake/rules/swig/xmake.lua +++ b/xmake/rules/swig/xmake.lua @@ -75,21 +75,9 @@ rule("swig.base") local autogenfiles local autogendir = path.join(target:autogendir(), "rules", "swig") - if fileconfig then - scriptdir = fileconfig.scriptdir - if fileconfig.swigflags then - -- find -outdir path - local idx = -1 - for i , par in pairs(fileconfig.swigflags) do - if par == "-outdir" then - idx = i - end - end - - if idx > 0 then - autogendir = fileconfig.swigflags[idx + 1] - end - end + local user_outdir = import("build_module_file").find_user_outdir(fileconfig) + if user_outdir then + autogendir = user_outdir end if moduletype == "python" then |
