xmake是一个基于Lua的轻量级现代化c/c++的项目构建工具,主要特色是:语法简单易上手,提供更加可读的项目维护,实现跨平台行为一致的构建体验。linux
本文主要详细讲解xmake在各个平台下的安装过程。c++
一般状况下咱们只须要经过一键安装脚本便可完成安装。git
bash <(curl -fsSL https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh)
bash <(wget https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh -O -)
Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content
注:若是ps脚本执行提示失败,能够尝试在管理员模式下执行github
windows下提供了预制的nsis安装包,咱们可直接从github的Releases下载页面下载后,运行安装包便可。shell
scoop install xmake
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew install xmake
或者:windows
或者安装master版本:安全
# 使用homebrew安装master版本 $ brew install xmake --HEAD # 或者直接调用shell下载安装 $ bash <(curl -fsSL https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh)
在archlinux上安装:ruby
$ yaourt xmake
或者下载deb包来安装:bash
dpkg -i xmake-xxxx.deb
最新版本的xmake已经很好地支持了termux,而咱们也一般只须要执行上面的一键安装脚本便可,若是失败,可参考下文本身拉取源码编译安装。curl
注:切记,xmake不建议在root下安装,因此尽可能不要在root下拉取源码编译安装!
$ git clone --recursive https://github.com/xmake-io/xmake.git $ cd ./xmake $ ./scripts/get.sh __local__ $ source ~/.xmake/profile
若是以为github的源太慢,能够经过gitee的镜像源拉取:clone --recursive https://gitee.com/tboox/xmake.git
注:因为目前xmake源码经过git submodule维护依赖,因此clone的时候须要加上--recursive
参数同时拉取全部submodules代码,请不要直接下载tar.gz源码,由于github不会自动打包submodules里面的代码。
若是git clone的时候忘记加--recursive
,那么也能够执行git submodule update --init
来拉取全部submodules,例如:
$ git clone https://github.com/xmake-io/xmake.git $ cd ./xmake $ git submodule update --init $ ./scripts/get.sh __local__
注:./get.sh __local__
是安装到~/.local/xmake
下,而后经过source ~/.xmake/profile
方式来加载的,因此安装完,当前终端若是执行xmake失败,提示找不到,就手动执行下 source ~/.xmake/profile
,而下次打开终端就不须要了。
$ ./scripts/get.sh __uninstall__
这个开发者本地调试xmake源码才须要:
$ ./scripts/get.sh __local__ __install_only__
xmake不推荐root下安装使用,由于这很不安全,若是用户非要root下装,装完后,若是提示xmake运行不了,请根据提示传递--root
参数,或者设置XMAKE_ROOT=y
环境变量强行启用下,前提是:用户须要随时注意root下误操做系统文件文件的风险。
xmake lua
命令执行REPL时候才须要。注:这种也是源码编译安装,可是安装路径会直接写入/usr/
下,须要root权限,所以除非特殊状况,不推荐这种安装方式,建议采用上文提供的./get.sh __local__
方式来安装,这两种安装方式的安装路径是不一样的,不要混用。
经过make进行编译安装:
$ make build; sudo make install
安装到其余指定目录:
$ sudo make install prefix=/usr/local
卸载:
$ sudo make uninstall
从v2.2.3版本开始,新增了xmake update
命令,来快速进行自我更新和升级,默认是升级到最新版本,固然也能够指定升级或者回退到某个版本:
$ xmake update 2.2.4
咱们也能够指定更新到master/dev分支版本:
$ xmake update master $ xmake update dev
从指定git源更新
$ xmake update github:xmake-io/xmake#master $ xmake update gitee:tboox/xmake#dev # gitee镜像
若是xmake/core没动过,仅仅更新xmake的lua脚本改动,能够加-s/--scriptonly
快速更新lua脚本
$ xmake update -s dev
最后,咱们若是要卸载xmake,也是支持的:xmake update --uninstall