xmake-io / xmake-gradle

A gradle plugin that integrates xmake seamlessly
https://xmake.io
Apache License 2.0
50 stars 4 forks source link

Install target packages #14

Closed A2va closed 1 month ago

A2va commented 2 months ago

I noticed that the target packages were not installed, like other so file, so I added that. In addition, apart from the target file, no files are deleted in the _clean_artifacts function (cxx stl, ...).

A2va commented 1 month ago

@waruqi I started working on using the install function with optional installdir and libdir. But I'm confronted with a problem when changing arch, I thought of using something like:

local targets = _get_targets(...)
for _, arch in ipairs({"armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"}) do
    if abi_filters[arch] then
        options["arch"] = arch
        task.run("config", options)
    end
end

But since _get_targets calls project.target or project.ordertargets, the targets are loaded there. So when running the config task it says project and targets may have been loaded early! Do you have any idea to find a way around it ?

waruqi commented 1 month ago

please do not run config task. gradle will call config task

A2va commented 1 month ago

Yes I know, but how to change arch without running the config task ? The install function install the target (and the deps) only for current arch.

A2va commented 1 month ago

I think, I have found a solution.

import("private.action.require.register", {alias = "register_packages"})

local targets = _get_targets(...)
for _, arch in ipairs({"armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"}) do
    if abi_filters[arch] then
        config.set("arch", arch)
        register_packages()
    end
end

What do you think ?

waruqi commented 1 month ago

maybe we can split it to gradle task for each arch.

waruqi commented 1 month ago

We can add xmakeInstallForArmv7, xmakeInstallForXXX tasks to install so for each arch in xmakeInstall task.

like build task:

https://github.com/xmake-io/xmake-gradle/blob/3259f30efefc3a035016d780993fb29d2df351ec/gradle-xmake-plugin/src/main/groovy/org/tboox/gradle/XMakePlugin.groovy#L134

then modify install_artifacts.lua to only install single arch library.

A2va commented 1 month ago

Yes, that's exactly what I was thinking when I looked at the code.

waruqi commented 1 month ago

Thanks, I will test it in these days.

waruqi commented 1 month ago

I have fixed it.