Skip to content

Commit

Permalink
Build fixes for libuuid
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Nov 22, 2024
1 parent 7ccb022 commit f386f3c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ thirdparty_versions = {
'json-c': '0.12-20140410',
'libatomic_ops': '7.6.10',
'libunwind': '1.2.1',
'libuuid': '2.40.1',
'libuuid': '2.33.2',
'libuv': '1.35.0',
'ltdl': '2.4.6',
'openfec': '1.4.2.11',
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ AddOption('--disable-libunwind',
AddOption('--disable-libuuid',
dest='disable_libuuid',
action='store_true',
help='disable libuuid support')
help='disable libuuid support for reliable UUID generation')

AddOption('--disable-alsa',
dest='disable_alsa',
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci_checks/linux-checks/conditional-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ scons -Q --enable-werror --build-3rdparty=all \
--disable-tools \
--disable-c11 \
--disable-libunwind \
--disable-libuuid \
--disable-openfec \
--disable-openssl \
--disable-speexdsp \
Expand All @@ -22,6 +23,7 @@ scons -Q --enable-werror --build-3rdparty=all \
--enable-benchmarks \
--enable-examples \
--disable-libunwind \
--disable-libuuid \
--disable-openfec \
--disable-openssl \
--disable-speexdsp \
Expand Down
39 changes: 24 additions & 15 deletions scripts/scons_helpers/build-3rdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
field: '' for field in (
'root_dir work_dir dist_dir log_file commit_file'
' pkg_dir pkg_src_dir pkg_bin_dir pkg_lib_dir pkg_inc_dir pkg_rpath_dir'
' pkg pkg_name pkg_ver pkg_deps'
' pkg pkg_name pkg_ver pkg_ver_major pkg_ver_minor pkg_ver_patch pkg_deps'
' build host toolchain variant android_platform macos_platform macos_arch'
' prefer_cmake'
' env unparsed_env').split()
Expand Down Expand Up @@ -888,14 +888,20 @@ def parse_env(unparsed_vars):
return env

def parse_dep(unparsed_dep):
m = re.match('^(.*?)-([0-9][a-z0-9.-]+)$', unparsed_dep)
m = re.match(r'^(.*?)-([0-9][a-z0-9.-]+)$', unparsed_dep)
if not m:
die("can't determine version of '{}'", unparsed_dep)
return m.group(1), m.group(2)

def parse_ver(unparsed_ver):
def parse_ver(unparsed_ver, fn=str, count=None):
try:
return tuple(map(int, unparsed_ver.split('.')))
comps = list(map(fn, unparsed_ver.split('.')))
if count:
if len(comps) > count:
comps = comps[:count]
elif len(comps) < count:
comps = comps + [0] * (count-len(comps))
return tuple(comps)
except:
die("can't parse version '{}'", unparsed_ver)

Expand Down Expand Up @@ -1045,6 +1051,7 @@ def die(text, *args):

ctx.pkg = args.package
ctx.pkg_name, ctx.pkg_ver = parse_dep(args.package)
ctx.pkg_ver_major, ctx.pkg_ver_minor, ctx.pkg_ver_patch = parse_ver(ctx.pkg_ver, count=3)
ctx.pkg_deps = args.deps or []

ctx.build = args.build
Expand Down Expand Up @@ -1173,24 +1180,25 @@ def die(text, *args):
elif ctx.pkg_name == 'libuuid':
download(
ctx,
'https://github.com/util-linux/util-linux/archive/refs/tags/v{ctx.pkg_ver}.tar.gz',
'https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/'+
'v{ctx.pkg_ver_major}.{ctx.pkg_ver_minor}/util-linux-{ctx.pkg_ver}.tar.gz',
'util-linux-{ctx.pkg_ver}.tar.gz')
unpack(ctx,
'util-linux-{ctx.pkg_ver}.tar.gz',
'util-linux-{ctx.pkg_ver}')
changedir(ctx, 'util-linux-{ctx.pkg_ver}')
execute(ctx, './autogen.sh')
execute(ctx, './configure --disable-all-programs --enable-libuuid --host={host} {vars} {flags} {opts}'.format(
changedir(ctx, 'src/util-linux-{ctx.pkg_ver}')
execute(ctx, './configure --host={host} {vars} {flags} {opts}'.format(
host=ctx.toolchain,
vars=format_vars(ctx),
flags=format_flags(ctx, cflags='-fcommon -fPIC'),
opts=' '.join([
'--disable-shared',
'--enable-static',
])))
'--disable-year2038',
'--disable-all-programs',
'--enable-libuuid',
])))
execute_make(ctx)
install_files(ctx, 'libuuid/uuid.h', ctx.pkg_inc_dir)
install_files(ctx, 'src/.libs/libuuid.a', ctx.pkg_lib_dir)
install_files(ctx, 'libuuid/src/uuid.h', ctx.pkg_inc_dir)
install_files(ctx, '.libs/libuuid.a', ctx.pkg_lib_dir)
elif ctx.pkg_name == 'openfec':
if ctx.variant == 'debug':
setattr(ctx, 'res_dir', 'bin/Debug')
Expand Down Expand Up @@ -1381,7 +1389,7 @@ def die(text, *args):
ctx,
'pulseaudio-{ctx.pkg_ver}.tar.gz',
'pulseaudio-{ctx.pkg_ver}')
pa_ver = parse_ver(ctx.pkg_ver)
pa_ver = parse_ver(ctx.pkg_ver, int)
if (8, 99, 1) <= pa_ver < (11, 99, 1):
apply_patch(
ctx,
Expand Down Expand Up @@ -1601,7 +1609,8 @@ def die(text, *args):
'benchmark_v{ctx.pkg_ver}.tar.gz',
'benchmark-{ctx.pkg_ver}')
changedir(ctx, 'src/benchmark-{ctx.pkg_ver}')
if parse_ver(ctx.pkg_ver) < (1, 7, 1) and not which('python') and which('python3'):
bench_ver = parse_ver(ctx.pkg_ver, int)
if bench_ver < (1, 7, 1) and not which('python') and which('python3'):
subst_tree(
ctx, 'tools', ['*.py'],
from_='#!/usr/bin/env python', to='#!/usr/bin/env python3')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "roc_core/panic.h"

#include <uuid/uuid.h>
#include <uuid.h>

namespace roc {
namespace core {
Expand Down
6 changes: 4 additions & 2 deletions src/tests/roc_core/test_uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace core {
TEST_GROUP(uuid) {};

TEST(uuid, generate) {
char a_uuid[UuidLen + 1] = {};
char a_uuid[UuidLen + 1];
memset(a_uuid, 0xcc, sizeof(a_uuid));

CHECK(uuid_generare(a_uuid, sizeof(a_uuid)) == true);
CHECK(a_uuid[8] == '-');
Expand All @@ -27,7 +28,8 @@ TEST(uuid, generate) {
}

TEST(uuid, generated_with_bigger_buffer) {
char a_uuid[UuidLen + 1 + 4] = {};
char a_uuid[UuidLen + 1 + 4];
memset(a_uuid, 0xcc, sizeof(a_uuid));

CHECK(uuid_generare(a_uuid, sizeof(a_uuid)) == true);
CHECK(a_uuid[8] == '-');
Expand Down

0 comments on commit f386f3c

Please sign in to comment.