当前位置:网站首页>Xmake help 2
Xmake help 2
2022-06-11 19:34:00 【fqbqrr】
Example
target("demo")
-- When building a library , prohibit
if has_config("onlylib") then
set_default(false)
end
-- Plus dependence
add_deps("xmake")
-- exe
set_kind("binary")
-- Add definition
add_defines("__tb_prefix__=\"xmake\"")
-- Add include directory
add_includedirs("$(projectdir)", "$(projectdir)/src")
-- Add source
add_files("**.c")
-- Add resource file .
if is_plat("windows") then
add_files("*.rc")
end
-- Add links
if is_plat("windows") then
add_links("ws2_32", "advapi32", "shell32")
add_ldflags("/export:malloc", "/export:free")
else
add_links("pthread", "dl", "m", "c")
end
-- xp compatible .
if is_plat("windows") then
if is_arch("x86") then
add_ldflags("/subsystem:console,5.01")
else
add_ldflags("/subsystem:console,5.02")
end
end
-- Copy into build directory .
after_build(function (target)
os.cp(target:targetfile(), "$(buildir)/xmake" .. (is_plat("windows") and ".exe" or ""))
end)
Plus mode
add_rules("mode.release", "mode.debug")
if is_mode("release") then
set_optimize("smallest")
if is_plat("windows") then
add_ldflags("/LTCG")
end
end
Mark and define
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=nullability-completeness", "-Wno-error=parentheses-equality")
-- Add definition
add_defines("_GNU_SOURCE=1", "_FILE_OFFSET_BITS=64", "_LARGEFILE_SOURCE")
-- Window platform
if is_plat("windows") then
add_cxflags("-MT")
add_ldflags("-nodefaultlib:msvcrt.lib")
add_links("kernel32", "user32", "gdi32")
-- Add links
end
-- Plus engineering
includes("src/lua-cjson", "src/lcurses", "src/sv","src/luajit", "src/lua", "src/tbox", "src/xmake", "src/demo")
Add configuration directory
set_configdir("$(buildir)/config")
add_configfiles("test.c.in", {
filename = "mytest.c"})
add_includedirs("$(buildir)/config/header")
// Add include directory
Header file only
target("foo")
set_kind("headeronly")
add_headerfiles("src/foo.h")
add_rules("utils.install.cmake_importfiles")
add_rules("utils.install.pkgconfig_importfiles")
add_files("src/*.manifest")
// Add list
template("console")
add_configfiles("xmake.lua")
// Templates , Add configuration file .
Tooling chain
toolchain("dlang")
-- Home page , describe
set_homepage("https://dlang.org/")
set_description("D Language ")
-- Check
on_check("check")
-- load
on_load(function (toolchain)
-- Import
import("core.project.config")
-- Prefix
local cross = toolchain:cross() or ""
-- Toolset
toolchain:add("toolset", "dc", "$(env DC)", "dmd", "ldc2", cross .. "gdc")
toolchain:add("toolset", "dcld", "$(env DC)", "dmd", "ldc2", cross .. "gdc")
toolchain:add("toolset", "dcsh", "$(env DC)", "dmd", "ldc2", cross .. "gdc")
toolchain:add("toolset", "dcar", "$(env DC)", "dmd", "ldc2", cross .. "gcc-ar")
-- Initial flag
local march
if toolchain:is_arch("x86_64", "x64") then
march = "-m64"
elseif toolchain:is_arch("i386", "x86") then
march = "-m32"
end
toolchain:add("dcflags", march or "")
toolchain:add("dcshflags", march or "")
toolchain:add("dcldflags", march or "")
end)
xmake Of xmake
target("xmake")
-- Static library
set_kind("static")
-- Plus dependence
if has_config("curses") or has_config("pdcurses") then
add_deps("lcurses")
end
add_deps("sv", "lua-cjson", "tbox")
add_deps(get_config("runtime"))
-- Add definition
add_defines("__tb_prefix__=\"xmake\"")
if is_mode("debug") then
add_defines("__tb_debug__", {
public = true})
end
-- Set to generate automatically ` To configure .h`
set_configdir("$(buildir)/$(plat)/$(arch)/$(mode)")
add_configfiles("xmake.config.h.in")
-- Add include directory
add_includedirs("..", {
interface = true})
add_includedirs("$(buildir)/$(plat)/$(arch)/$(mode)", {
public = true})
-- Header file .
add_headerfiles("../(xmake/*.h)")
add_headerfiles("../(xmake/prefix/*.h)")
add_headerfiles("$(buildir)/$(plat)/$(arch)/$(mode)/xmake.config.h", {
prefixdir = "xmake"})
-- Add source file
add_files("**.c|winos/*.c")
if is_plat("windows", "msys", "cygwin") then
add_files("winos/*.c")
end
-- Plus options
add_options("readline")
if is_plat("windows") then
add_defines("UNICODE", "_UNICODE")
end
Define the rules
rule("markdown")
set_extensions(".md", ".markdown")
on_load(function (target)
print("markdown: on_load")
end)
on_build_file(function (target, sourcefile)
print("compile %s", sourcefile)
os.cp(sourcefile, path.join(target:targetdir(), path.basename(sourcefile) .. ".html"))
end)
About the same , Yes , Look again .
边栏推荐
- 无监督图像分类《SCAN:Learning to Classify Images without》代码分析笔记(1):simclr
- 【信号去噪】基于非线性滤波器实现语音自适应去噪附matlab代码
- Review of software testing technology
- Flash ckeditor rich text compiler can upload and echo images of articles and solve the problem of path errors
- About my experience of "binary deployment kubernetes cluster"
- SISO decoder for repetition (supplementary Chapter 4)
- High performance architecture design
- Hanging memory recursive dynamic programming (with example explanation POJ 1163)
- Usage of duck beak wire stripper
- Golang学习笔记—基础篇
猜你喜欢

Raki's notes on reading paper: memory replace with data compression for continuous learning
![[Multisim Simulation] using operational amplifier to generate sawtooth wave](/img/98/27086746dc552ada25fd36a82cb52b.png)
[Multisim Simulation] using operational amplifier to generate sawtooth wave

Performance of MOS transistor 25n120 of asemi in different application scenarios
【 aide 】 comment puis - je faire en sorte que les messages sélectionnés ci - dessous puissent être affichés après l'ouverture de l'article Wechat public number dans un navigateur externe?

On the translation of rich text storage database format

Tensorflow---TFRecord文件的创建与读取
![[video denoising] video denoising based on salt with matlab code](/img/79/e1f8255061a342e02232ac1e393217.png)
[video denoising] video denoising based on salt with matlab code

谷歌提出超强预训练模型CoCa,在ImageNet上微调Top-1准确率达91%!在多个下游任务上SOTA!...

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

Activate function formulas, derivatives, image notes
随机推荐
司空见惯 - 会议室名称
干货丨MapReduce的工作流程是怎样的?
Tensorflow---TFRecord文件的创建与读取
Record the phpstudy configuration php8.0 and php8.1 extension redis
[video denoising] video denoising based on salt with matlab code
09-MySQL锁
On the translation of rich text storage database format
Flask CKEditor 富文本编译器实现文章的图片上传以及回显,解决路径出错的问题
【高精度】X进制整数加法
On Workflow selection
CMU 15-445 database course lesson 5 text version - buffer pool
[image denoising] impulse noise image denoising based on absolute difference median filter, weighted median filter and improved weighted median filter with matlab code attached
Specific methods for porting WinCC flexible 2008 project to botu WinCC
[image segmentation] image segmentation based on Markov random field with matlab code
556. 下一个更大元素 III-(31. 下一个排列)-两次遍历
[image denoising] image denoising based on Markov random field with matlab code
使用贝叶斯优化进行深度神经网络超参数优化
Flutter--Button浅谈
On high availability architecture
【求助】請問如何讓微信公眾號文章在外部瀏覽器中打開後還能顯示下方的精選留言?