Skip to content

xmake v2.5.4 Released, Support apt portage package manager and improve xrepo shell

ruki edited this page May 16, 2021 · 1 revision

xmake is a lightweight cross-platform build tool based on Lua. It uses xmake.lua to maintain project builds. Compared with makefile/CMakeLists.txt, the configuration syntax is more Concise and intuitive, it is very friendly to novices, and you can get started quickly in a short time, allowing users to focus more on actual project development.

In version 2.5.4, we added support for Apt and Portage package managers. On Ubuntu/Gentoo, we can also use add_requires to quickly integrate the packages they provide.

And we have also improved the support for the Vcpkg package manager, and added support for the installation of arm/arm64 architecture packages.

In addition, we have also enhanced the xrepo env shell environment. You can load a shell environment with a specific package configuration by configuring a series of add_requires package configurations in xmake.lua.

New feature introduction

New package manager support

Add dependency package of ubuntu/apt

Now we support the use of apt to integrate dependent packages, and will also automatically find packages that have been installed on the ubuntu system.

add_requires("apt::zlib1g-dev", {alias = "zlib"})

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

Add gentoo/portage dependency package

We also support the use of Portage to integrate dependency packages, and will automatically find packages already installed on the Gentoo system.

add_requires("portage::libhandy", {alias = "libhandy"})

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

Integrate arm/arm64 architecture package from Vcpkg

add_requires("vcpkg::zlib", {alias = "zlib"})

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

The configuration method is still the same as before. You only need to switch to the arm/arm64 architecture to compile to automatically pull the arm/arm64 package from Vcpkg.

$ xmake f -a arm64
$ xmake

Support import and export installation packages

Usually, after we use the xrepo command or xmake to install the package, if the same project is migrated to other machines for compilation, then the installation package must be downloaded again.

In order to improve development efficiency, xrepo can now quickly export installed packages, including corresponding library files, header files, and so on.

$ xrepo export -o /tmp/output zlib

Then we can also import the previously exported installation package on other machines to implement package migration.

$ xrepo import -i /xxx/packagedir zlib

After importing, the corresponding project compilation will use them directly, no additional reinstallation of packages is required.

Specific package shell environment support

xrepo has a xrepo env command, which can specify the environment to load a specific package, and then run a specific program, for example, load the installation environment of the luajit package, and then run luajit:

$ xrepo env luajit

Or bind a specific luajit version package environment, after loading bash, you can directly run the corresponding lujit.

$ xrepo env -b "luajit 5.1" bash
> luajit --version

However, there is a problem with this. If we install a lot of packages, different package configurations and versions are still different. If we want to load a bash environment with multiple packages at the same time.

Then, the previous method cannot be supported. Therefore, in the new version, we will further improve it. Yes, we can customize some package configurations by adding the xmake.lua file in the current directory, and then enter the specific package shell environment .

xmake.lua

add_requires("zlib 1.2.11")
add_requires("python 3.x", "luajit")

For example, as above, we have configured three packages in xmake.lua and want to use them in the shell at the same time, then just run the following command in the current directory.

$ xrepo env shell
> python --version
> luajit --version

It should be noted that here we used xrepo env shell instead of xrepo env bash, because bash can only be used on specific platforms, and xrepo env shell is a built-in command.

It can automatically detect the current terminal environment, load the corresponding bash, sh, zsh, and cmd or powershell environments under windows, all of which are automatic.

In addition, we also added some auxiliary features, such as prompt prompt, xrepo env quit environment exit command, historical input command switching and so on.

Set up image acceleration package download

In order to improve the problem of slow downloading of packages in the domestic network environment, xmake supports proxy settings, as well as pac.lua proxy configuration strategies.

In the new version, we have improved the configuration of pac.lua and further support the configuration of mirror proxy rules. For example, access to all github.com domain names is switched to the hub.fastgit.org domain name to achieve accelerated downloading of packages.

pac.lua configuration:

function mirror(url)
     return url:gsub("github.com", "hub.fastgit.org")
end

Then we set the second pac.lua file, the default path is ~/.xmake/pac.lua.

$ xmake g --proxy_pac=/tmp/pac.lua

Then, when we install the package, if we encounter the package source under the github.com domain name, it will automatically switch to the fastgit mirror to accelerate the download when downloading.

$ xrepo install libpng
> curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip

Custom switch package storage directory

Before, we could only configure and modify the default package installation directory through xmake g --pkg_installdir=/tmp/xx.

Now, we can also modify it through the XMAKE_PKG_INSTALLDIR environment variable. The default path is: ~/.xmake/packages.

In addition, we also added the XMAKE_PKG_CACHEDIR environment variable to modify the package cache directory. The default path is: ~/.xmake/cache/packages.

Changelog

New features

  • #1323: Support find and install package from apt, add_requires("apt::zlib1g-dev")
  • #1337: Add environment vars to change package directories
  • #1338: Support import and export installed packages
  • #1087: Add xrepo env shell and support load envs from add_requires/xmake.lua
  • #1313: Support private package for add_requires/add_deps
  • #1358: Support to set mirror url to speedup download package
  • #1369: Support arm/arm64 packages for vcpkg, thanks @fallending
  • #1405: Add portage package manager support, thanks @Phate6660

Change

  • Improve find_package and add package:find_package for xmake package
  • Remove deprecated set_config_h and set_config_h_prefix apis
  • #1343: Improve to search local package files
  • #1347: Improve to vs_runtime configs for binary package
  • #1353: Improve del_files() to speedup matching files
  • #1349: Improve xrepo env shell to support powershell

Bugs fixed

  • #1380: Fix add packages errors
  • #1381: Fix add local git source for package
  • #1391: Fix cuda/nvcc toolchain
Clone this wiki locally