xmake開(kāi)發(fā)文檔


閱讀(17.2k) 收藏 (2)

手冊(cè)簡(jiǎn)介

一個(gè)基于Lua 的跨平臺(tái)構(gòu)建工具

手冊(cè)說(shuō)明

logo256c


xmake


一個(gè)基于Lua的輕量級(jí)跨平臺(tái)自動(dòng)構(gòu)建工具

簡(jiǎn)介


XMake是一個(gè)基于Lua的輕量級(jí)跨平臺(tái)自動(dòng)構(gòu)建工具,支持在各種主流平臺(tái)上構(gòu)建項(xiàng)目

xmake的目標(biāo)是開(kāi)發(fā)者更加關(guān)注于項(xiàng)目本身開(kāi)發(fā),簡(jiǎn)化項(xiàng)目的描述和構(gòu)建,并且提供平臺(tái)無(wú)關(guān)性,使得一次編寫(xiě),隨處構(gòu)建

它跟cmake、automake、premake有點(diǎn)類(lèi)似,但是機(jī)制不同,它默認(rèn)不會(huì)去生成IDE相關(guān)的工程文件,采用直接編譯,并且更加的方便易用 采用lua的工程描述語(yǔ)法更簡(jiǎn)潔直觀,支持在大部分常用平臺(tái)上進(jìn)行構(gòu)建,以及交叉編譯

并且xmake提供了創(chuàng)建、配置、編譯、打包、安裝、卸載、運(yùn)行等一些actions,使得開(kāi)發(fā)和構(gòu)建更加的方便和流程化。

不僅如此,它還提供了許多更加高級(jí)的特性,例如插件擴(kuò)展、腳本宏記錄、批量打包、自動(dòng)文檔生成等等。。

如果你想要了解更多,請(qǐng)參考:

安裝


使用curl

bash <(curl -fsSL https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh)

使用wget

bash <(wget https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh -O -)

使用powershell

Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content

簡(jiǎn)單的工程描述


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

構(gòu)建工程


$ xmake

運(yùn)行目標(biāo)


$ xmake run console

調(diào)試程序


$ xmake run -d console

支持特性


  • Tasks
  • Macros
  • Actions
  • Options
  • Plugins
  • Templates

支持平臺(tái)


  • Windows (x86, x64, amd64, x86_amd64)
  • Macosx (i386, x86_64)
  • Linux (i386, x86_64, cross-toolchains ...)
  • Android (armv5te, armv6, armv7-a, armv8-a, arm64-v8a)
  • iPhoneOS (armv7, armv7s, arm64, i386, x86_64)
  • WatchOS (armv7k, i386)
  • Mingw (i386, x86_64)

支持語(yǔ)言


  • C/C++
  • Objc/Objc++
  • Swift
  • Assembly
  • Golang
  • Rust
  • Dlang

內(nèi)置插件


  • 宏記錄腳本和回放插件
  • 加載自定義lua腳本插件
  • 生成IDE工程文件插件(makefile, vs2002 - vs2017, ...)
  • 生成doxygen文檔插件

更多插件


請(qǐng)到插件倉(cāng)庫(kù)進(jìn)行下載安裝: xmake-plugins.

簡(jiǎn)單例子



創(chuàng)建一個(gè)c++ console項(xiàng)目:

    xmake create -l c++ -t 1 console
or  xmake create --language=c++ --template=1 console

工程描述文件:xmake.lua

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

配置工程:

這個(gè)是可選的步驟,如果只想編譯當(dāng)前主機(jī)平臺(tái)的項(xiàng)目,是可以不用配置的,默認(rèn)編譯release版本。

   xmake f -p iphoneos -m debug
or xmake f --plat=macosx --arch=x86_64
or xmake f -p windows
or xmake config --plat=iphoneos --mode=debug
or xmake config --plat=android --arch=armv7-a --ndk=xxxxx
or xmake config -p linux -a i386
or xmake config -p mingw --cross=i386-mingw32- --toolchains=/xxx/bin
or xmake config -p mingw --sdk=/mingwsdk
or xmake config --help

編譯工程:

   xmake
or xmake -r
or xmake --rebuild

運(yùn)行目標(biāo):

   xmake r console
or xmake run console

調(diào)試目標(biāo):

   xmake r -d console
or xmake run -d console

打包所有:

   xmake p
or xmake package
or xmake package console
or xmake package -o /tmp
or xmake package --output=/tmp

通過(guò)宏腳本打包所有架構(gòu):

   xmake m package 
or xmake m package -p iphoneos
or xmake m package -p macosx -f "-m debug" -o /tmp/
or xmake m package --help

安裝目標(biāo):

   xmake i
or xmake install
or xmake install console
or xmake install -o /tmp
or xmake install --output=/tmp

詳細(xì)使用方式和參數(shù)說(shuō)明,請(qǐng)參考文檔 或者運(yùn)行:

   xmake -h
or xmake --help
or xmake config --help
or xmake package --help
or xmake macro --help
...

一些使用xmake的項(xiàng)目:


簡(jiǎn)單例子


-- the debug mode
if is_mode("debug") then
    
    -- enable the debug symbols
    set_symbols("debug")

    -- disable optimization
    set_optimize("none")
end

-- the release mode
if is_mode("release") then

    -- set the symbols visibility: hidden
    set_symbols("hidden")

    -- enable fastest optimization
    set_optimize("fastest")

    -- strip all symbols
    set_strip("all")
end

-- add target
target("test")

    -- set kind
    set_kind("static")

    -- add files
    add_files("src/*.c") 

聯(lián)系方式


感謝


  • TitanSnow: 提供xmake logo 和安裝腳本
  • uael: 提供語(yǔ)義版本跨平臺(tái)c庫(kù) sv


更新記錄

在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)