meson步骤记录

1. 下载工具

https://github.com/mesonbuild/meson/releases

 

We provide an MSI installer on the GitHub release page that can be used to install both Meson and Ninja at once for Windows. It also contains an embedded copy of Python, so scripts that use the Python module and do not have any external dependencies will continue to work as expected.

 在windows 下面,直接采用msi安装包,就可以将meson和ninja都安装上,并且包含一个所需的python的拷贝。不需要其他额外的安装操作

2.  在某些windows操作系统上,需要配置path环境变量,以便找到meson和ninja 

3.  到sourceforge上下载mingw64编译工具链。并配置path,而后运行gcc查询版本,能查询到版本,则正常使用。

4. 建立meson.build 文件,并在其中增加内容:

  project('test','c')   //表示工程的名字为test,使用c语言
executable('hellomeson','hellomeson.c')   //表示生成的可执行文件为hellomeson, 源文件为hellomeson.c

5. 运行记录如下,此处看到gcc的编译工具链式tdm。配置path后可以使用mingw64
C:\Windows\system32>d:

D:\>cd meson

D:\meson>cd test

D:\meson\test>meson build
The Meson build system
Version: 0.53.1
Source dir: D:\meson\test
Build dir: D:\meson\test\build
Build type: native build
Project name: test
Project version: undefined
C compiler for the host machine: gcc (gcc 5.1.0 "gcc (tdm64-1) 5.1.0")
C linker for the host machine: gcc GNU ld.bfd 2.25
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1

Found ninja.EXE-1.9.0 at "C:\Program Files\Meson\ninja.EXE"

D:\meson\test>cd build

D:\meson\test\build>ninja
[2/2] Linking target hellomeson.exe.

D:\meson\test\build>hellomeson.exe
i am hello meson

D:\meson\test\build>

6. 常用函数及参数说明

test--

     |--hellomeson.c

    |-meson.build

    |---common

           |--cmn.c

           |-cmn.h

           |-meson.build

    

头文件包含方法

1) 在cmn的meson.build,其内容为:

 cmn=files('cmn.c')

cmn_inc=include_directories('.')

其中files函数生成了cmn变量,表示要编译的源文件,cmn_inc表示头文件所在的目录,此处为cmn目录

2) 而test目录下的meson.build的内容为:

subdir('cmn')  表示进入cmn目录之星cmn目录下的meson.build,进而就生成了cmn和cmn_inc两个变量。

executable('hellomeson','hellomeson.c',cmn,include_directories:[cmn_inc]) 在此处即可以引用cmn\cmn_inc两个变量了,此时可以编译多个目录下的文件,及包含相应的头文件了。

编译链接参数设置方法

 编译参数设定:

https://gitlab.com/federicomenaquintero/bzip2/-/blob/master/meson.build

add_project_arguments('-D_WIN32', language : 'c'),即增加一个编译控制WIN32

官网资料为:https://mesonbuild.com/Adding-arguments.html

  比如指定是否连接库等。

链接参数设定

https://mesonbuild.com/Reference-manual.html

link_args是关键字

link_args=['-lpcre2-posix','-lpcre2-8']
executable('hellomeson','hellomeson.c',link_args:link_args)

和python的结合 

在meson中调用python脚本的方法及参数传递

dpdk项目中有个实例

 

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

proware

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值