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

Improve add_requires and find_package to integrate the 3rd package manager #339

Closed
waruqi opened this Issue Jan 29, 2019 · 5 comments

Comments

Projects
None yet
1 participant
@waruqi
Copy link
Member

waruqi commented Jan 29, 2019

Roadmap

  • add_requires("XXX::pkgname") -> package.manager.install_package("XXX::pkgname")
    • conan::zlib/1.2.11@conan/stable
    • vcpkg::zlib
    • brew::pcre2/libpcre2-8
    • clib::clibs/bytes@0.0.4
  • lib.detect.find_package("XXX::pkgname")
    • conan::zlib/1.2.11@conan/stable
    • vcpkg::zlib
    • brew::pcre2/libpcre2-8
    • pkg_config::zlib
    • clib::clibs/bytes@0.0.4
  • Add builtin api find_packages("XXX:pkgname", "zlib") to find multiple packages
  • Custom integration with the other package manager

Conan

  • pass platform settings
  • pass architecture settings
  • pass build mode settings
  • pass compiler settings
    • gcc
    • clang
    • msvc
  • cross-platform test verification
    • macOS x86_64
    • linux/ubuntu x86_64
    • windows x86/x86_64
  • install_package("conan::xxx", config = {})
    • settings, e.g. settings = {"compiler=gcc", "compiler.version=4.9"}
    • build_requires, e.g. build_requires = "xmake_generator/0.1.0@bincrafters/testing"
    • build, e.g. build = "all"
    • options, e.g. options = {"OpenSSL:shared=True"}
    • imports
    • remote, e.g. remote = "https://api.bintray.com/conan/bincrafters/public-conan"

Related issues

#327 Integrate with Conan package manager
#184 Improve lib.detect.find_package to support vcpkg
#69 Remote package management
#331 Creating xmake_generator for Conan
#330 Creating xmake_installer conan package
#332 Creating xmake "Build Helper" for Conan

@waruqi waruqi added this to the v2.2.4 milestone Jan 29, 2019

@waruqi

This comment has been minimized.

Copy link
Member Author

waruqi commented Jan 29, 2019

Examples

Install and use the required conan packages.

add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true})
add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl", 
    configs = {options = "OpenSSL:shared=True"}})

target("test")
    set_kind("binary")
    add_files("src/*.c") 
    add_packages("openssl", "zlib")

Build project

ruki:test_package ruki$ xmake
checking for the architecture ... x86_64
checking for the Xcode directory ... /Applications/Xcode.app
checking for the SDK version of Xcode ... 10.14
note: try installing these packages (pass -y to skip confirm)?
  -> CONAN::zlib/1.2.11@conan/stable  (debug)
  -> CONAN::OpenSSL/1.0.2n@conan/stable  
please input: y (y/n)

  => installing CONAN::zlib/1.2.11@conan/stable .. ok
  => installing CONAN::OpenSSL/1.0.2n@conan/stable .. ok

[  0%]: ccache compiling.release src/main.c
[100%]: linking.release test
@waruqi

This comment has been minimized.

Copy link
Member Author

waruqi commented Jan 29, 2019

Example

Uses find_packages.

add_requires("CONAN::zlib/1.2.11@conan/stable", {alias = "zlib", debug = true})
add_requires("CONAN::OpenSSL/1.0.2n@conan/stable", {alias = "openssl", 
    configs = {options = "OpenSSL:shared=True"}})

target("test")
    set_kind("binary")
    add_files("src/*.c") 

    on_load(function (target)
        target:add(find_packages("CONAN::OpenSSL/1.0.2n@conan/stable"))
        target:add(find_packages("CONAN::zlib/1.2.11@conan/stable", {mode = "debug"}))
    end)
@waruqi

This comment has been minimized.

Copy link
Member Author

waruqi commented Jan 29, 2019

We can also add the custom module to integrate with the 3rd package manager in projectdir/xmake.lua.

We do not need to modify the xmake project source code.

  • projectdir
    • main.c
    • xmake.lua
    • modules
      • package/manager/xxx
        • install_package.lua
        • find_package.lua
add_moduledirs("modules")
add_requires("xxx::zlib", {alias = "zlib"})
target("test")
    add_files("*.c")
    add_packages("zlib")
@waruqi

This comment has been minimized.

Copy link
Member Author

waruqi commented Jan 29, 2019

Example

Install and use brew packages

add_requires("brew::zlib", {alias = "zlib"}})
add_requires("brew::pcre2/libpcre2-8", {alias = "pcre2"}})

target("test")
    set_kind("binary")
    add_files("src/*.c") 
    add_packages("pcre2", "zlib")

Install and use vcpkg packages

add_requires("vcpkg::zlib", "vcpkg::pcre2")

target("test")
    set_kind("binary")
    add_files("src/*.c") 
    add_packages("vcpkg::zlib", "vcpkg::pcre2")
@waruqi

This comment has been minimized.

Copy link
Member Author

waruqi commented Apr 16, 2019

Add clib support #397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.