Skip to content

Commit 694a04f

Browse files
committed
[#3729] Fix yang
1 parent e416852 commit 694a04f

File tree

5 files changed

+70
-58
lines changed

5 files changed

+70
-58
lines changed

meson.build

+54-39
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,36 @@ conf_data = configuration_data(
123123
},
124124
)
125125

126+
#### System-specific Variables
127+
128+
SYSTEM = build_machine.system()
129+
if SYSTEM == 'linux'
130+
conf_data.set('OS_LINUX', true)
131+
OS_TYPE = 'Linux'
132+
elif SYSTEM == 'freebsd'
133+
conf_data.set('OS_BSD', true)
134+
conf_data.set('OS_FREEBSD', true)
135+
OS_TYPE = 'BSD'
136+
elif SYSTEM == 'netbsd'
137+
conf_data.set('OS_BSD', true)
138+
conf_data.set('OS_NETBSD', true)
139+
OS_TYPE = 'BSD'
140+
elif SYSTEM == 'openbsd'
141+
conf_data.set('OS_BSD', true)
142+
conf_data.set('OS_OPENBSD', true)
143+
OS_TYPE = 'BSD'
144+
elif SYSTEM == 'sun'
145+
conf_data.set('OS_SOLARIS', true)
146+
OS_TYPE = 'Solaris'
147+
elif SYSTEM == 'darwin'
148+
conf_data.set('OS_BSD', true)
149+
conf_data.set('OS_OSX', true)
150+
OS_TYPE = 'BSD'
151+
else
152+
error(f'Build failed: Unsupported system "@SYSTEM@".')
153+
endif
154+
message(f'Detected system "@SYSTEM@".')
155+
126156
#### Programs
127157

128158
python_exe = find_program('python3', 'python', required: false)
@@ -261,15 +291,30 @@ foreach dep : ['yang', 'yang-cpp', 'sysrepo', 'sysrepo-cpp']
261291
endif
262292

263293
# Search in /opt.
264-
lib = cpp.find_library(dep, dirs: [f'/opt/@dep@/lib'], required: false)
265-
if lib.found()
266-
netconf_deps = netconf_deps + {
267-
dep: declare_dependency(
268-
dependencies: [lib],
269-
include_directories: include_directories(f'/opt/@dep@/include'),
270-
),
271-
}
272-
endif
294+
foreach prefix : ['', 'lib']
295+
path = f'/opt/@prefix@@dep@'
296+
lib = cpp.find_library(dep, dirs: [f'/@path@/lib'], required: false)
297+
if lib.found()
298+
netconf_deps = netconf_deps + {
299+
dep: declare_dependency(
300+
dependencies: [lib],
301+
include_directories: include_directories(f'/@path@/include'),
302+
variables: {'prefix': f'@path@'},
303+
),
304+
}
305+
if SYSTEM == 'darwin'
306+
add_project_link_arguments(
307+
f'-Wl,-rpath,@path@/lib',
308+
language: 'cpp',
309+
)
310+
else
311+
add_project_link_arguments(
312+
f'-Wl,-rpath=@path@/lib',
313+
language: 'cpp',
314+
)
315+
endif
316+
endif
317+
endforeach
273318
endforeach
274319
foreach dep : ['yang', 'yang-cpp', 'sysrepo', 'sysrepo-cpp']
275320
if netconf_deps[dep].found()
@@ -341,36 +386,6 @@ result = cpp.run(
341386
)
342387
conf_data.set('HAVE_STREAM_TRUNCATED_ERROR', result.returncode() == 0)
343388

344-
#### System-specific Variables
345-
346-
SYSTEM = build_machine.system()
347-
if SYSTEM == 'linux'
348-
conf_data.set('OS_LINUX', true)
349-
OS_TYPE = 'Linux'
350-
elif SYSTEM == 'freebsd'
351-
conf_data.set('OS_BSD', true)
352-
conf_data.set('OS_FREEBSD', true)
353-
OS_TYPE = 'BSD'
354-
elif SYSTEM == 'netbsd'
355-
conf_data.set('OS_BSD', true)
356-
conf_data.set('OS_NETBSD', true)
357-
OS_TYPE = 'BSD'
358-
elif SYSTEM == 'openbsd'
359-
conf_data.set('OS_BSD', true)
360-
conf_data.set('OS_OPENBSD', true)
361-
OS_TYPE = 'BSD'
362-
elif SYSTEM == 'sun'
363-
conf_data.set('OS_SOLARIS', true)
364-
OS_TYPE = 'Solaris'
365-
elif SYSTEM == 'darwin'
366-
conf_data.set('OS_BSD', true)
367-
conf_data.set('OS_OSX', true)
368-
OS_TYPE = 'BSD'
369-
else
370-
error(f'Build failed: Unsupported system "@SYSTEM@".')
371-
endif
372-
message(f'Detected system "@SYSTEM@".')
373-
374389
#### System-specific Compiler Flags
375390

376391
compile_args = []

src/share/yang/modules/utils/check-hashes.sh.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC")
3+
# Copyright (C) 2018-2025 Internet Systems Consortium, Inc. ("ISC")
44
#
55
# This Source Code Form is subject to the terms of the Mozilla Public
66
# License, v. 2.0. If a copy of the MPL was not distributed with this

src/share/yang/modules/utils/check-revisions.sh.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC")
3+
# Copyright (C) 2018-2025 Internet Systems Consortium, Inc. ("ISC")
44
#
55
# This Source Code Form is subject to the terms of the Mozilla Public
66
# License, v. 2.0. If a copy of the MPL was not distributed with this
+12-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
yangdir = f'@DATADIR@/kea/yang/modules/utils'
22
yang_utils_conf_data = configuration_data()
33
# Comment says sources (vs build)
4-
yang_utils_conf_data.set('abs_top_builddir', TOP_SOURCE_DIR)
4+
yang_utils_conf_data.set('abs_top_builddir', TOP_BUILD_DIR)
55
# Beware that top_srcdir here must be a relative path.
66
yang_utils_conf_data.set('top_srcdir', '../../../../..')
77
yang_utils_conf_data.set('datarootdir', f'@PREFIX@/@DATADIR@')
8-
yang_lint = find_program('/opt/bin/yanglint', required: false)
9-
if yang_lint.found()
10-
yang_utils_conf_data.set('LIBYANG_PREFIX', '/opt')
11-
yang_utils_conf_data.set('SYSREPO_PREFIX', '/opt')
12-
else
13-
yang_utils_conf_data.set('SYSREPO_PREFIX', '/usr/local')
14-
yang_lint = find_program('/usr/local/bin/yanglint', required: false)
15-
if yang_lint.found()
16-
yang_utils_conf_data.set('LIBYANG_PREFIX', '/usr/local')
17-
else
18-
yang_lint = find_program('yanglint', required: true)
19-
yang_utils_conf_data.set('LIBYANG_PREFIX', '')
20-
endif
21-
endif
8+
yang_utils_conf_data.set('prefix', PREFIX)
9+
yang_utils_conf_data.set(
10+
'LIBYANG_PREFIX',
11+
netconf_deps['yang'].get_variable('prefix'),
12+
)
13+
yang_utils_conf_data.set(
14+
'SYSREPO_PREFIX',
15+
netconf_deps['sysrepo'].get_variable('prefix'),
16+
)
2217

2318
configure_file(
2419
input: 'check-hashes.sh.in',
@@ -34,4 +29,6 @@ configure_file(
3429
input: 'reinstall.sh.in',
3530
output: 'reinstall.sh',
3631
configuration: yang_utils_conf_data,
32+
install: true,
33+
install_dir: 'share/kea/yang/modules/utils',
3734
)

src/share/yang/modules/utils/reinstall.sh.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# Copyright (C) 2021-2024 Internet Systems Consortium, Inc. ("ISC")
3+
# Copyright (C) 2021-2025 Internet Systems Consortium, Inc. ("ISC")
44
#
55
# This Source Code Form is subject to the terms of the Mozilla Public
66
# License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -87,7 +87,7 @@ prefix="@prefix@"
8787
# If script is in sources, use modules from sources.
8888
# If script is in installation, use modules from installation.
8989
for i in \
90-
"@datarootdir@/@PACKAGE_NAME@/yang/modules" \
90+
"@datarootdir@/kea/yang/modules" \
9191
"@abs_top_builddir@/src/share/yang/modules" \
9292
; do
9393
if test "${script_path}" = "${i}/utils"; then

0 commit comments

Comments
 (0)