当前位置:网站首页>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 .
边栏推荐
- Chrome tips - browser web page setting coding, solving the problem of web page garbled code, obtaining the latest version of charset plug-in, UTF-8 coding setting
- 构建Web应用程序
- MongoDB 什么兴起的?应用场景有哪些?
- leetcode:66.加一
- Big work and requirements of economics in autumn 21 of Dagong [standard answer]
- What is the workflow of dry goods MapReduce?
- STL application (unfinished
- [signal denoising] signal denoising based on FFT and fir with matlab code
- 何恺明团队的“视频版本MAE”,高效视频预训练!Mask Ratio高达90%时效果也很好!...
- Pymysql uses cursor operation database method to encapsulate!!!
猜你喜欢
![[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code](/img/fd/07cee3c51ac44ca40f730dd487aa20.png)
[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code

Hanging memory recursive dynamic programming (with example explanation POJ 1163)

使用贝叶斯优化进行深度神经网络超参数优化

Multimodal learning toolkit paddlemm based on propeller

CMU 15 - 445 cours de base de données Leçon 5 version texte - Pool tampon

Qubicle notes: Hello voxel

图床:PicGo+腾讯云+typora

基于飞桨搭建的多模态学习工具包PaddleMM
![[Lao Wang's fallacy of brain science] Why do blind people](/img/7c/98f27bb55a1a3b74c0ed8fd7fd2cc5.jpg)
[Lao Wang's fallacy of brain science] Why do blind people "seem" to be more "sensitive" than normal people?
![[C language questions -- 10 simple questions for leetcode]](/img/60/c7aca1392eb85c3a7185abe4c82f16.png)
[C language questions -- 10 simple questions for leetcode]
随机推荐
Usage of duck beak wire stripper
Anaconda installation, jupyter notebook default startup path modification and nbextensions plug-in installation
Introduction to typescript
Judge whether it is a balanced binary tree
First acquaintance with enterprise platform
YOLOv3 Pytorch代码及原理分析(一):跑通代码
管理者必须知道的三个常识
High performance architecture design
Pymysql uses cursor operation database method to encapsulate!!!
RTL仲裁器设计
Hdu3527 (Hangdian) spy problem
POJ 1458 longest common subsequence (dynamic planning exercise)
09-MySQL锁
vs2010链接sql2008数据库时无法打开
激活函数公式、导数、图像笔记
【 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?
[Multisim Simulation] using operational amplifier to generate sawtooth wave
Hanging memory recursive dynamic programming (with example explanation POJ 1163)
Practice of tag recognition based on Huawei cloud image
What is the workflow of dry goods MapReduce?