Skip to content
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

Cannot override package descriptions in a remote xmake-repo added by add_repositories #5840

Open
for2years opened this issue Nov 19, 2024 · 3 comments
Labels

Comments

@for2years
Copy link

Xmake Version

v2.9.6

Operating System Version and Architecture

wsl ubuntu 2204

Describe Bug

I have a project that references a remote xmake-repo containing many packages. However, I need to locally debug one of the packages, and I found that I cannot override the package description from the remote xmake-repo.

-- this remote repo contains a log of packages
add_repositories("my-repo https://github.com/for-2-years/xmake-repo.git")

-- I want to override a specific package to debug
package("my-package", function()
    set_policy("package.install_always", true)
    set_sourcedir("/root/my-package-dir")
    on_install(function(package)
        import("package.tools.xmake").install(package)
    end)
end)

Is there a way to prioritize local package descriptions over those in the remote repository?

After debugging the xmake source code, I found that this function merges the packages defined in the project with those defined in the remote repository.

-- load the package from the project file
function package.load_from_project(packagename, project)

    -- get it directly from cache first
    local instance = package._memcache():get2("packages", packagename)
    if instance then
        return instance
    end

    -- load packages (with cache) 
    local packages, errors = project.packages()
    if not packages then
        return nil, errors
    end

    -- get package info
    local packageinfo = packages[packagename]
    if not packageinfo then
        return
    end

    -- new an instance
    instance = _instance.new(packagename, packageinfo)
    package._memcache():set2("packages", instance)
    return instance
end

function package.load_from_project(packagename, project)

Expected Behavior

I can override a remote-repo package description by a local package.

Project Configuration

none

Additional Information and Error Logs

none

@for2years for2years added the bug label Nov 19, 2024
@smac89
Copy link

smac89 commented Nov 19, 2024

I don't think there is a way to do this from within the project file itself. You have to create a custom repo, copy the original xmake.lua file in there and configure your project to use it.

See https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository

After this you can run xmake require --info my-package, and it will show you where the package will be retrieved from.

@waruqi
Copy link
Member

waruqi commented Nov 20, 2024

you can use set_base to do it. see https://xmake.io/#/manual/package_dependencies?id=packageset_base

@for2years
Copy link
Author

I don't think there is a way to do this from within the project file itself. You have to create a custom repo, copy the original xmake.lua file in there and configure your project to use it.

See https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository

After this you can run xmake require --info my-package, and it will show you where the package will be retrieved from.

this remote repo contains a log of packages so I don't want to do this. but thanks for your idea anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants