当前位置:网站首页>Proficient in xmake2
Proficient in xmake2
2022-06-11 19:34:00 【fqbqrr】
Tool chains have corresponding include/lib Catalog , It's similar :
- bin
- Tools
- Tools
- ...
- lib
- libxxx.a
- include
- xxx.h
structure . You can use :
$ xmake f -p cross --sdk=/home/toolchains_sdkdir
To compile .-p cross Indicates cross compilation ,--sdk= Tool chain root directory . commonly xmake Automatic processing .
Manual adjustment :
$ xmake f -p linux --sdk=/home/toolchains_sdkdir --bin=/usr/opt/bin
//bin Catalog
$ xmake
use --cross= Configure compilation Tools Prefix .
$ xmake f -p linux --sdk=/usr/toolsdk --bin=/opt/bin --cross=armv7-linux-
$ xmake f -p linux --sdk=/user/toolsdk --cc=armv7-linux-clang --cxx=armv7-linux-clang++
// Continue adding options
--cc by c.--cxx by C++ compiler . Yes CC/CXX Environment variables , environment variable first .
xmake f --cxx=clang++@/home/xxx/c++mips.exe
// Equivalent
$ xmake f -p linux --sdk=/user/toolsdk --ld=armv7-linux-clang++ --sh=armv7-linux-clang++ --ar=armv7-linux-ar
ld The linker ,sh share ,ar Static library , Again LD/SH/AR environment variable .
use --includedirs and --linkdirs and --links To add Search for route .
use : perhaps ;( window ) To segment .
use --cflags,--cxxflags,--ldflags,--shflags and --arflags set an option ,as For assembler .
$ xmake f -p mingw
$ xmake -v
//
$ xmake g --mingw=/home/mingwsdk
$ xmake f -p mingw
$ xmake
Switching platform .
Set up tool chain , No need Manual Appoint .
target("test")
set_kind("binary")
set_toolchain("cxx", "clang")
set_toolchain("ld", "clang++")
Set up To configure Parameters , Equivalent to xmake f:
set_config("cflags", "-DTEST")
set_config("sdk", "/home/xxx/tooksdk")
set_config("cc", "gcc")
set_config("ld", "g++")
Also available -p/--plat= Custom platform .
$ xmake f -p linux --sdk=/usr/local/arm-xxx-gcc/
$ xmake
Lin Cao platform .
The goal is Sub project .
add_links("tbox")
add_linkdirs("lib")
add_includedirs("include")
// Put a common one outside
target("test1")
set_kind("binary")
add_files("src/test1/*.c")
target("test2")
set_kind("binary")
add_files("src/test2/*.c")
Different items , individualization . use add_deps Set dependencies .
target("foo")
set_kind("static")
add_files("*.c")
add_defines("FOO", {
public = true})
add_includedirs("foo/inc", {
public = true})
target("test1")
set_kind("binary")
add_deps("foo")
add_files("test1/*.c")
target("test2")
set_kind("binary")
add_deps("foo")
add_files("test2/*.c")
inheritable linkdirs,links,includedirs as well as defines Such as relationship , And automatically process the compilation sequence . rely on Or cascading .
add_deps("dep1", "dep2", {
inherit = false})
// Non inherited dependencies .
add_includedirs("inc1", {
public = true})
// Public directory .
Yes private( Default , private )/public( Open )/interface( Only be dependent on ) Three .add_includedirs, add_defines, add_cflags etc. , Both support visibility .
Big project
Sub project , use xmake.lua, use includes Import .
$ xmake build test1
$ xmake run test3
$ xmake install demo1
// There is no need to switch to a subdirectory to operate .
root xmake.lua Put general configuration .
-- Define the project
set_project("tbox")
set_xmakever("2.3.2")
set_version("1.6.5", {
build = "%Y%m%d%H%M"})
-- Common signs
set_warnings("all", "error")
set_languages("c99")
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined")
add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined")
-- Build a model
add_rules("mode.release", "mode.debug")
-- Include subprojects
includes("test", "demo")
Sub configuration It only affects Myself and the lower class . subprojects Straddlable xmake.lua Rely solely on .
target("demo1")
set_kind("binary")
add_files("demo1/*.c")
add_deps("test1")
// Rely on your peers . Priority compilation is dependent , The dependent party automatically links to the corresponding library
add_files,add_includedirs It's all relative to subprojects Catalog . Just consider the current directory .
projectdir
- test
- xmake.lua
- test1/ *.c
- test2/ *.c
//
target("test1")
add_files("test1/*.c")
target("test2")
add_files("test2/*.c")
// such .
use $(projectdir) Root directory .includes Is the global interface .
includes("test1", "test2")
// To do this , Can't put ` The goal is ` Inside
target("test")
set_kind("static")
add_files("test/*.c")
direct includes("test1") Just reference the directory .
Batch :
includes("test/*/xmake.lua")
// recursive
includes("test/**/xmake.lua")
Description domain The configuration file . Complex scripts in Script domain Write in .on_xxx,after_xxx,before_xxx All are script fields .
You can use import Interface import xmake All kinds of built-in lua modular , And users lua Script
target("test")
set_kind("binary")
add_files("src/*.c")
on_load("modules.test.load")
on_install("modules.test.install")
// Script in a separate file .
More complex... Can be configured .
A separate lua Script file to main Main entrance .
import("core.project.config")
import("mymodule")
// Import built-in / Self writing extension .
function main(target)
if is_plat("linux", "macosx") then
target:add("links", "pthread", "m", "dl")
end
end
// The main entrance
on_load stay Load target When to start , Only once . and Description domain May be executed more than once .
also ,on/after/before_build/install/package/run Stage . Script Available for Customize (on_build,on_run..) Script , Developing a plug-in , Development templates , Expansion platform , Custom tasks, etc .
import("core.base.option")
import("core.base.task")
// use . Split the path .
function main()
-- Take parameter options
print(option.get("version"))
-- Run tasks and plug-ins
task.run("hello")
end
//
import("modules.hello1")
import("modules.hello2")
// Custom module , nothing _ Prefixes are exported
Import the specified
import("hello3", {
rootdir = "/home/xxx/modules"})
// Catalog .
Specify alias
import("core.platform.platform", {
alias = "p"})
function main()
-- So it can be used p To call `platform` Modular `plats` Interface , Take all `xmake` List of supported platforms
print(p.plats())
end
new
import("xxx.xxx", {
try = true, anonymous = true})
try Failure , Return without error , anonymous Do not introduce the current domain .
test lua.
function main()
print("hello xmake!")
end
// function .
$ xmake lua /tmp/test.lua
$ xmake lua lib.detect.find_tool gcc
// Fast execution .
$ xmake lua
// Interactive mode
Import extension module
> task = import("core.project.task")
// Interactive mode
> task.run("hello")
hello xmake!
use target:set,target:add To add The goal is attribute .set_,add_ The former can be used to dynamically configure . There are many other interfaces . Such as name , take , Target file , The target type , Dependents , rely on , Options , Options , Bags , package , Source list .on_link Handle When linking action .on_build Build time ,
target("test")
on_build("windows", function (target)
print("build for windows")
end)
// It can also be targeted at platforms .
on_build_file Custom compilation script .on_build_files A group of .
target("test")
set_kind("binary")
add_files("src/*.c")
on_build_files(function (target, sourcebatch, opt)
end)
//sourcebatch To express .
sourcebatch There are methods sourcekind/sourcefiles/objectfiles/dependfileson_clean Cleaning action .on_package pack ,on_install install ,on_uninstall uninstall .on_run function apk etc.
also target:before_xxx and target:after_xxx Series hooks .xmake Built-in module , Such as os,io operation . The following functions will be omitted .
边栏推荐
- [solution] codeforces round 798 (Div. 2)
- Poj1028 web navigation
- 关于富文本储存数据库格式转译问题
- Detailed explanation of iSCSI (IV) -- actual configuration of iSCSI server
- Pyramid test principle: 8 tips for writing unit tests
- 【mysql进阶】10种数据类型的区别以及如何优化表结构(三)
- PyMySQL利用游标操作数据库方法封装!!!
- 【信号去噪】基于FFT和FIR实现信号去噪附matlab代码
- Hdu3527 (Hangdian) spy problem
- 【信号去噪】基于非线性滤波器实现语音自适应去噪附matlab代码
猜你喜欢

Introduction to go language (VI) -- loop statement

【图像去噪】基于马尔可夫随机场实现图像去噪附matlab代码

On the translation of rich text storage database format

Yolov3 pytoch code and principle analysis (I): runthrough code

计算926的9260次方里的字符串里有多少个926
![[Multisim Simulation] generate square wave and triangular wave generators by operational amplifier](/img/44/11a6a78877e8eebcae495871af8cb5.png)
[Multisim Simulation] generate square wave and triangular wave generators by operational amplifier

Hospital intelligent infusion management system source code hospital source code

Operator new and placement new
![[C language questions -- 10 simple questions for leetcode]](/img/60/c7aca1392eb85c3a7185abe4c82f16.png)
[C language questions -- 10 simple questions for leetcode]

Tensorflow---TFRecord文件的创建与读取
随机推荐
Gmail: how do I recall an outgoing message?
mysql 联合索引和BTree
[image denoising] impulse noise image denoising based on absolute difference median filter, weighted median filter and improved weighted median filter with matlab code attached
【求助】請問如何讓微信公眾號文章在外部瀏覽器中打開後還能顯示下方的精選留言?
High concurrency architecture design
leetcode:66.加一
Practice of Flink CDC in Dajian cloud warehouse
Flutter--Button浅谈
Template and requirements of curriculum design of reinforced concrete structure in autumn 21 of Dagong [standard answer]
程序员10年巨变,一切都变了又好像没变...
Multimodal learning toolkit paddlemm based on propeller
MongoDB 什么兴起的?应用场景有哪些?
On the translation of rich text storage database format
High performance architecture design
AHB_Bus_Matrix_3x3 设计
What is the workflow of dry goods MapReduce?
01. Telecommunications_ Field business experience
【Laravel系列7.5】事件系统
Performance of MOS transistor 25n120 of asemi in different application scenarios
Activate function formulas, derivatives, image notes