当前位置:网站首页>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 .
边栏推荐
- 5g communication test manual based on Ti am5728 + artix-7 FPGA development board (dsp+arm)
- Skywalking source code analysis Part 5 - server configuration configuration module startup
- [untitled]
- MOS transistor 24n50 parameters of asemi, 24n50 package, 24n50 size
- pstack和dmesg
- High performance architecture design
- collect. stream(). Use of the collect() method
- Yolov3 pytoch code and principle analysis (II): network structure and loss calculation
- Flash ckeditor rich text compiler can upload and echo images of articles and solve the problem of path errors
- 【Multisim仿真】利用运算放大器产生锯齿波
猜你喜欢

Use Mysql to determine the day of the week

2022 the latest software testing classic summarized by major manufacturers. After reading it, I'm not afraid I won't get an offer

Raki's notes on reading paper: memory replace with data compression for continuous learning

Record the phpstudy configuration php8.0 and php8.1 extension redis

Detailed explanation of iSCSI (IV) -- actual configuration of iSCSI server

AHB2Standard_handshake_bridge 设计

Common - name of conference room

【C语言刷题——Leetcode10道简单题】

Flask CKEditor 富文本编译器实现文章的图片上传以及回显,解决路径出错的问题

On the translation of rich text storage database format
随机推荐
Kubernetes binary installation (v1.20.15) (VIII) deploying network plug-ins
计算926的9260次方里的字符串里有多少个926
Questions and requirements of the "high rise building structure" assignment of Dayong in the 21st autumn [standard answer]
AHB2APB_bridge 设计
[Multisim Simulation] generate square wave and triangular wave generators by operational amplifier
【求助】请问如何让微信公众号文章在外部浏览器中打开后还能显示下方的精选留言?
[Multisim Simulation] using operational amplifier to generate sawtooth wave
Zzulioj 2903: the power of warriors
Hdu3527 (Hangdian) spy problem
09-MySQL锁
I don't want to open an account online. Is it safe to open an account online?
AHB2Standard_handshake_bridge 设计
Tensorflow---TFRecord文件的创建与读取
mysql 联合索引和BTree
Detailed explanation of iSCSI (IV) -- actual configuration of iSCSI server
Practice of Flink CDC in Dajian cloud warehouse
[signal denoising] signal denoising based on FFT and fir with matlab code
[Lao Wang's fallacy of brain science] Why do blind people "seem" to be more "sensitive" than normal people?
09 MySQL lock
What is the workflow of dry goods MapReduce?