-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathmeson.build
More file actions
184 lines (168 loc) · 6.71 KB
/
meson.build
File metadata and controls
184 lines (168 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
project('rt-claw', 'c',
version: '0.2.0',
default_options: [
'c_std=gnu99',
'warning_level=2',
'werror=true',
],
)
osal_backend = get_option('osal')
project_root = meson.project_source_root()
# Platform-specific include directories and compile definitions
platform_defs = []
platform_incs = []
if osal_backend == 'rtthread'
rtthread_bsp = get_option('rtthread_bsp')
rtthread_cpuport = get_option('rtthread_cpuport')
platform_defs += ['-D_POSIX_SOURCE', '-DCLAW_PLATFORM_RTTHREAD']
rtt = project_root / 'vendor' / 'rt-thread'
platform_incs += include_directories(
'vendor/os/rt-thread/include',
rtthread_cpuport,
'vendor/os/rt-thread/components/legacy',
'vendor/os/rt-thread/components/finsh',
'vendor/os/rt-thread/components/net/lwip/port',
'vendor/os/rt-thread/components/net/lwip/port/netif',
'vendor/os/rt-thread/components/libc/compilers/common/include',
'vendor/os/rt-thread/components/libc/compilers/newlib',
'vendor/os/rt-thread/components/libc/posix/io/poll',
'vendor/os/rt-thread/components/libc/posix/io/stdio',
'vendor/os/rt-thread/components/libc/posix/ipc',
'vendor/os/rt-thread/components/drivers/include',
'vendor/os/rt-thread/components/net/sal/include',
'vendor/os/rt-thread/components/net/sal/include/socket',
'vendor/os/rt-thread/components/net/sal/include/socket/sys_socket',
'vendor/os/rt-thread/components/net/netdev/include',
'vendor/os/rt-thread/components/net/lwip/lwip-2.1.2/src/include',
'vendor/os/rt-thread/components/net/lwip/lwip-2.1.2/src/include/netif',
rtthread_bsp,
rtthread_bsp / 'drivers',
is_system: true,
)
elif osal_backend == 'freertos'
_plat = get_option('platform')
if _plat == 'zynq-a9'
platform_defs += ['-DCLAW_PLATFORM_FREERTOS']
platform_incs += include_directories(
'vendor/os/freertos/include',
'vendor/os/freertos/portable/GCC/ARM_CA9',
'vendor/bsp/xilinx',
'vendor/bsp/xilinx/standalone/common',
'vendor/bsp/xilinx/standalone/cortexa9',
'vendor/bsp/xilinx/drivers/scugic',
'vendor/bsp/xilinx/drivers/scutimer',
'vendor/bsp/xilinx/drivers/emacps',
'vendor/lib/freertos-plus-tcp/source/include',
'vendor/lib/freertos-plus-tcp/source/portable/Compiler/GCC',
'platform/zynq-a9',
is_system: true,
)
else
platform_defs += ['-DCLAW_PLATFORM_ESP_IDF']
endif
elif osal_backend == 'zephyr'
platform_defs += ['-DCLAW_PLATFORM_ZEPHYR']
elif osal_backend == 'linux'
platform_defs += ['-DCLAW_PLATFORM_LINUX']
endif
# Bare-metal platforms lack HTTPS/WebSocket; reject feishu/telegram.
_bare_metal = (osal_backend == 'rtthread') or \
(osal_backend == 'freertos' and get_option('platform') == 'zynq-a9') or \
(osal_backend == 'zephyr')
if _bare_metal and (get_option('feishu') or get_option('telegram'))
error('feishu/telegram are not supported on bare-metal platforms (no HTTPS/WebSocket)')
endif
# ---- Unified configuration via claw_config_generated.h ----
#
# All rt-claw credentials and tunable parameters are configured here,
# NOT in vendor SDK configs (ESP-IDF Kconfig, RT-Thread rtconfig).
#
# Priority: meson option (-Dai_api_key=...) > env var (RTCLAW_AI_API_KEY)
# > claw_config.h #ifndef default.
#
# String config: [meson_option, env_var_name, config_macro_name]
_str_overrides = {
'ai_api_key': ['RTCLAW_AI_API_KEY', 'CONFIG_RTCLAW_AI_API_KEY'],
'ai_api_url': ['RTCLAW_AI_API_URL', 'CONFIG_RTCLAW_AI_API_URL'],
'ai_model': ['RTCLAW_AI_MODEL', 'CONFIG_RTCLAW_AI_MODEL'],
'feishu_app_id': ['RTCLAW_FEISHU_APP_ID', 'CONFIG_RTCLAW_FEISHU_APP_ID'],
'feishu_app_secret':['RTCLAW_FEISHU_APP_SECRET','CONFIG_RTCLAW_FEISHU_APP_SECRET'],
'telegram_bot_token':['RTCLAW_TELEGRAM_BOT_TOKEN','CONFIG_RTCLAW_TELEGRAM_BOT_TOKEN'],
'telegram_api_url': ['RTCLAW_TELEGRAM_API_URL', 'CONFIG_RTCLAW_TELEGRAM_API_URL'],
'ota_url': ['RTCLAW_OTA_URL', 'CONFIG_RTCLAW_OTA_URL'],
}
# Integer config: [meson_option, env_var_name, config_macro_name]
_int_overrides = {
'ai_max_tokens': ['RTCLAW_AI_MAX_TOKENS', 'CONFIG_RTCLAW_AI_MAX_TOKENS'],
'ai_context_size': ['RTCLAW_AI_CONTEXT_SIZE', 'CONFIG_RTCLAW_AI_CONTEXT_SIZE'],
'ai_memory_max_msgs': ['RTCLAW_AI_MEMORY_MAX_MSGS', 'CONFIG_RTCLAW_AI_MEMORY_MAX_MSGS'],
'ota_check_interval_ms': ['RTCLAW_OTA_CHECK_INTERVAL_MS', 'CONFIG_RTCLAW_OTA_CHECK_INTERVAL_MS'],
}
conf_data = configuration_data()
_has_any = false
# Version from git describe (e.g. "v0.2.0" or "v0.2.0-3-gabcdef").
# Without --always so it fails cleanly when no tag is reachable
# (e.g. shallow CI clone), falling back to meson.project_version().
_git_ver = run_command('git', 'describe', '--tags',
'--dirty=-dirty', check: false)
if _git_ver.returncode() == 0
_ver_str = _git_ver.stdout().strip()
if _ver_str.startswith('v')
_ver_str = _ver_str.substring(1)
endif
else
_ver_str = meson.project_version()
endif
conf_data.set_quoted('RT_CLAW_VERSION', _ver_str)
_has_any = true
foreach opt_name, pair : _str_overrides
_val = get_option(opt_name)
if _val == ''
_r = run_command('sh', '-c',
'printf "%s" "${' + pair[0] + ':-}"', check: false)
_val = _r.stdout().strip()
endif
if _val != ''
conf_data.set_quoted(pair[1], _val)
_has_any = true
endif
endforeach
foreach opt_name, pair : _int_overrides
_val = get_option(opt_name)
if _val > 0
conf_data.set(pair[1], _val)
_has_any = true
else
_r = run_command('sh', '-c',
'printf "%s" "${' + pair[0] + ':-}"', check: false)
_env = _r.stdout().strip()
if _env != ''
conf_data.set(pair[1], _env.to_int())
_has_any = true
endif
endif
endforeach
claw_config_gen = configure_file(
input: 'claw_gen_config.h.in',
output: 'claw_gen_config.h',
configuration: conf_data,
)
# Tell claw_config.h to include the generated header
platform_defs += ['-DCLAW_HAS_GENERATED_CONFIG']
# Unified header directories:
# - project root: claw_config.h
# - include/: all other public headers
# - build dir: claw_gen_config.h (added implicitly by Meson)
claw_root_inc = include_directories('.')
claw_inc = include_directories('include')
subdir('vendor/lib/cjson')
subdir('osal')
subdir('claw')
subdir('tests/unit')
_fw_plat = get_option('platform')
if _fw_plat == 'zynq-a9'
subdir('platform/zynq-a9')
endif
if osal_backend == 'linux'
subdir('platform/linux')
endif