-
Notifications
You must be signed in to change notification settings - Fork 5
/
meson.build
170 lines (154 loc) · 3.7 KB
/
meson.build
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
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# SPDX-FileCopyrightText: Copyright 2021 Micron Technology, Inc.
project(
'hse-java',
'c',
'java',
version: run_command(
'mvn',
'-f',
meson.project_source_root() / 'pom.xml',
'help:evaluate',
'-Dexpression=project.version',
'--quiet',
'-DforceStdout',
check: true
).stdout().strip(),
license: 'Apache-2.0 OR MIT',
default_options: [
'prefix=/opt/hse',
'b_ndebug=if-release',
'c_std=gnu11',
'buildtype=debugoptimized',
'warning_level=3',
# Meson for whatever reason chooses not to respect HSE's default
# options :).
'force_fallback_for=lz4,cjson',
],
meson_version: '>=1.0.1'
)
version_components = meson.project_version().split('.')
hse_java_major_version = version_components[0].to_int()
hse_java_minor_version = version_components[1].to_int()
hse_java_patch_version = version_components[2].to_int()
fs = import('fs')
javamod = import('java')
cc = meson.get_compiler('c')
javac = meson.get_compiler('java')
mvn = find_program('mvn')
sh = find_program('sh', required: get_option('tests'))
python = find_program('python3', required: get_option('tests'))
pom_file = meson.project_source_root() / 'pom.xml'
group_id = run_command(
'mvn',
'-f',
pom_file,
'help:evaluate',
'-Dexpression=project.groupId',
'--quiet',
'-DforceStdout',
check: true
).stdout().strip()
artifact_id = run_command(
'mvn',
'-f',
pom_file,
'help:evaluate',
'-Dexpression=project.artifactId',
'--quiet',
'-DforceStdout',
check: true
).stdout().strip()
package = '@0@.@1@'.format(group_id, artifact_id)
jar_filename = '@0@-@[email protected]'.format(artifact_id, meson.project_version())
jni_dep = dependency('jni', version: '>=1.8.0')
hse_dep = dependency(
'hse-@0@'.format(hse_java_major_version),
version: [
'>=@[email protected]'.format(hse_java_major_version),
'<@[email protected]'.format(hse_java_major_version + 1),
],
default_options: [
'default_library=static',
'warning_level=0',
'werror=false',
'cli=false',
'docs=disabled',
'tests=false',
'tools=disabled',
'samples=false',
'bindings=none',
]
)
add_project_arguments(cc.get_supported_arguments(
'-Wdeclaration-after-statement'
),
language: 'c'
)
subdir('src')
if get_option('docs')
subdir('docs')
endif
if get_option('repo') == ''
repo = 'file://' + run_command(
mvn,
'help:evaluate',
'-Dexpression=settings.localRepository',
'--quiet',
'-DforceStdout',
check: true
).stdout().strip()
else
repo = get_option('repo')
endif
meson.add_install_script(
mvn,
'-f',
pom_file,
'deploy:deploy-file',
'-Dmaven.test.skip=true',
'-Durl=' + repo,
'-DpomFile=' + pom_file,
'-Dfile=' + hse_jar.full_path()
)
run_target(
'checkoss',
command: [
find_program('scripts/dev/checkoss.sh'),
'@BUILD_ROOT@',
'@SOURCE_ROOT@',
]
)
run_target(
'jshell',
command: [
find_program('jshell', required: false, disabler: true),
],
depends: [
hsejni,
hse_jar,
],
env: environment({
'LD_LIBRARY_PATH': fs.parent(hsejni.full_path()),
'CLASSPATH': hse_jar.full_path(),
})
)
run_target(
'checkstyle',
command: [
mvn,
'-f',
pom_file,
'checkstyle:check'
]
)
shellcheck = find_program('shellcheck', required: false)
if shellcheck.found()
run_target(
'shellcheck',
command: [
find_program('scripts/dev/shellcheck.sh'),
]
)
endif