Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
339e1d39 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
src,modules: meson: move remove previous rust definitions

Those definitions were finally added in modules/ here when the whole
infrastructure was thought to be going into the modules/ folder, but now
that it's in the src/rust/ folder, the definition there is better to
have the core crates use the same definitions.

- - - - -
3f98515d by Loïc Branstett at 2026-01-22T10:24:53+01:00
vlcrs-core: meson: add definition for crate

Co-authored-by: Alexandre Janniaux <[email protected]>

Most of the code was written by Loïc and extracted from his original
merge request, but those snippets were not merged upstream. The code was
extracted to a separate meson build definition.

- - - - -
e797521c by Loïc Branstett at 2026-01-22T10:24:53+01:00
vlcrs-macros: meson: add definition for crate

Co-authored-by: Alexandre Janniaux <[email protected]>

Most of the code was written by Loïc and extracted from his original
merge request, but those snippets were not merged upstream. The code was
extracted to a separate meson build definition.

The added extension addition allows ensuring the built artifact matches
with what cargo will build. Since it's a proc-macro crate, it will build
a plugin for the compiler, which is a dynamic library of the building
platform.

The plugin itself is not used currently, but this allows checking that
the proc_macro builds correctly.

- - - - -
dfe99cd6 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
cargo-rustc-static-libs: add --target parameter

- - - - -
1902466d by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
cargo-rustc-static-libs: set edition to 2024

- - - - -
853c76f0 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
cargo-rustc-static-libs: open file with encoding

Fix warnings with encoding not being defined with open.

- - - - -
63c62712 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
cargo-rustc-static-libs: add more infos on error

The output of the command was displayed but it lacked the f-string
marker to inject the variable data into stderr.

- - - - -
c363a7d8 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
cargo-rustc-static-lib: rename "main" function in staticlib

Since we build a staticlib, we don't need a main() function and it can
be confusing. The goal is to extract the dependencies that we'll use
when building the other plugins.

- - - - -
1b7e3844 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
rust: meson: add support for triplet

It supports any 'triplet' supported by rustc and cargo. Note that it's
not necessarily a triplet but the naming comes from GNU triplet.

See https://doc.rust-lang.org/nightly/rustc/platform-support.html for
more information on those triplets.

- - - - -
d361f2c6 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
meson: rust: always define dependencies from rust

To be able to declare modules unconditionally, declare the rust
dependencies and state variables that will be used when declaring
modules, without executing the commands that depend on Rust.

In short, this allows using the enabled: flag instead of conditionally
defining the module under an if get_option('rust').allowed() block.

- - - - -
7b64335b by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
logger: meson: use enabled flag

- - - - -
f4b7c133 by Alexandre Janniaux at 2026-01-22T10:24:53+01:00
logger: meson: add telegraf tracer

- - - - -


7 changed files:

- buildsystem/cargo-rustc-static-libs.py
- modules/logger/meson.build
- modules/meson.build
- src/meson.build
- + src/rust/meson.build
- + src/rust/vlcrs-core/meson.build
- + src/rust/vlcrs-macros/meson.build


Changes:

=====================================
buildsystem/cargo-rustc-static-libs.py
=====================================
@@ -1,6 +1,7 @@
 #!/usr/bin/env python3
 # SPDX-License-Identifier: LGPL-2.1-or-later
 # Copyright (C) 2022 Loïc Branstett <[email protected]>
+# Copyright (C) 2025 Alexandre Janniaux <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published by
@@ -30,12 +31,15 @@ import os, sys, json, subprocess, tempfile, argparse
 NATIVE_STATIC_LIBS="native-static-libs"
 
 parser = argparse.ArgumentParser()
+parser.add_argument("--target")
 parser.add_argument("cargo_cmds", nargs=argparse.REMAINDER)
 
 args = parser.parse_args()
 
 cargo_argv = args.cargo_cmds
 cargo_argv.append("rustc")
+if args.target is not None:
+    cargo_argv.append(f"--target={args.target}")
 cargo_argv.append("--message-format=json")
 cargo_argv.append("--crate-type=staticlib")
 cargo_argv.append("--quiet")
@@ -45,21 +49,22 @@ cargo_argv.append("--print=native-static-libs")
 with tempfile.TemporaryDirectory() as tmpdir:
     os.chdir(tmpdir)
 
-    with open("Cargo.toml", "w") as cargo_toml:
+    with open("Cargo.toml", "w", encoding="utf-8") as cargo_toml:
         cargo_toml.write("""
 [package]
 name = "native-static-libs"
 version = "0.0.0"
+edition = "2024"
 
 [lib]
 path = "lib.rs"
 """)
     
-    with open("lib.rs", "w") as lib_rs:
-        lib_rs.write("#![allow(dead_code)] fn main(){}")
+    with open("lib.rs", "w", encoding="utf-8") as lib_rs:
+        lib_rs.write("#![allow(dead_code)] fn foo(){}")
 
-    # Execute the cargo build and redirect stdout (and not stderr)
-    cargo_r = subprocess.run(cargo_argv, stdout=subprocess.PIPE)
+    # Execute the cargo build and redirect stdout/stderr
+    cargo_r = subprocess.run(cargo_argv, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 
     # We don't use `check=True in run because it raise an execption
     # and outputing a python traceback isn't useful at all.
@@ -67,8 +72,10 @@ path = "lib.rs"
     # We also exit here so that the output o tmp dir is not cleared when
     # there is an error.
     if cargo_r.returncode != 0:
-        print("command: {cargo_argv}", file=sys.stderr)
-        print("cwd: {tmpdir}", file=sys.stderr)
+        print(f"command: {' '.join(cargo_argv)}", file=sys.stderr)
+        print(f"cwd: {tmpdir}", file=sys.stderr)
+        print(cargo_r.stderr, file=sys.stderr)
+        print(cargo_r.stdout, file=sys.stderr)
         sys.exit(cargo_r.returncode)
 
 # Get the jsons output


=====================================
modules/logger/meson.build
=====================================
@@ -11,24 +11,28 @@ vlc_modules += {
 }
 
 # Syslog logger
-if cc.check_header('syslog.h')
-    vlc_modules += {
-        'name' : 'syslog',
-        'sources' : files('syslog.c')
-    }
-endif
+vlc_modules += {
+    'name' : 'syslog',
+    'sources' : files('syslog.c'),
+    'enabled' : cc.check_header('syslog.h'),
+}
 
 # Systemd journal logger
 libsystemd_dep = dependency('libsystemd', required: false)
-if libsystemd_dep.found()
-    vlc_modules += {
-        'name' : 'sd_journal',
-        'sources' : files('journal.c'),
-        'dependencies' : [libsystemd_dep]
-    }
-endif
+vlc_modules += {
+    'name' : 'sd_journal',
+    'sources' : files('journal.c'),
+    'dependencies' : [libsystemd_dep],
+    'enabled' : libsystemd_dep.found(),
+}
 
 vlc_modules += {
     'name' : 'json_tracer',
     'sources' : files('json.c')
 }
+
+vlc_rust_modules += {
+    'name' : 'telegraf_rs',
+    'sources' : files('telegraf-rs/src/lib.rs'),
+    'cargo_toml' : files('telegraf-rs/Cargo.toml'),
+}


=====================================
modules/meson.build
=====================================
@@ -482,29 +482,6 @@ endforeach
 
 # Rust/cargo common handling code
 if get_option('rust').enabled()
-    rust_optimization_args = {
-        'plain': [],
-        '0': [],
-        'g': ['-C', 'opt-level=0'],
-        '1': ['-C', 'opt-level=1'],
-        '2': ['-C', 'opt-level=2'],
-        '3': ['-C', 'opt-level=3'],
-        's': ['-C', 'opt-level=s'],
-    }
-
-    print_static_libs_rustc = run_command([cargo_rustc_static_libs, cargo_bin],
-        check: true, capture: true)
-    rust_common_link_args = print_static_libs_rustc.stdout().split()
-
-    # Do not try to reorder those two operations, they may triger a bug in
-    # meson where array += element is not equal to array += array
-    rust_flags = get_option('extra_rust_flags')
-    rust_flags += rust_optimization_args[get_option('optimization')]
-
-    cargo_target_dir = join_paths(meson.current_build_dir(), 'cargo_target')
-
-    extra_cargo_args = []
-    module_cargo_depends = []
     if get_option('vendored_rust_deps') != 'no'
         if get_option('vendored_rust_deps') == 'yes'
             cargo_fetch_deps_tgt = custom_target('cargo_fetch_deps',


=====================================
src/meson.build
=====================================
@@ -514,3 +514,4 @@ vlc_tests += {
     'link_with' : [libvlccore],
 }
 
+subdir('rust')


=====================================
src/rust/meson.build
=====================================
@@ -0,0 +1,44 @@
+rust_optimization_args = {
+    'plain': [],
+    '0': [],
+    'g': ['-C', 'opt-level=0'],
+    '1': ['-C', 'opt-level=1'],
+    '2': ['-C', 'opt-level=2'],
+    '3': ['-C', 'opt-level=3'],
+    's': ['-C', 'opt-level=s'],
+}
+
+extra_cargo_args = []
+module_cargo_depends = []
+rust_common_link_args = []
+rust_target = []
+
+if get_option('rust').enabled()
+    if meson.is_cross_build()
+        rust_target = ['--target=' + 
meson.get_external_property('rust_triplet')]
+        extra_cargo_args += rust_target
+    endif
+
+    print_static_libs_rustc = run_command(cargo_rustc_static_libs, 
rust_target, cargo_bin,
+        check: true, capture: true)
+    rust_common_link_args = print_static_libs_rustc.stdout().split()
+endif
+
+# Do not try to reorder those two operations, they may trigger a bug in
+# meson where array += element is not equal to array += array
+rust_flags = get_option('extra_rust_flags')
+rust_flags += rust_optimization_args[get_option('optimization')]
+
+cargo_target_dir = join_paths(meson.current_build_dir(), 'cargo_target')
+
+vlcrs_core = disabler()
+if get_option('rust').enabled()
+    subdir('vlcrs-core')
+endif
+
+vlcrs_core_macros = disabler()
+if get_option('rust').enabled()
+    subdir('vlcrs-macros')
+endif
+
+module_cargo_depends += [vlcrs_core, vlcrs_core_macros]


=====================================
src/rust/vlcrs-core/meson.build
=====================================
@@ -0,0 +1,26 @@
+vlcrs_core = custom_target('vlcrs_core-cargo',
+    capture: false,
+    console: true,
+    build_by_default: true,
+    input: files(
+        'Cargo.toml',
+        'src/object/mod.rs',
+        'src/object/sys.rs',
+        'src/plugin/mod.rs',
+        'src/plugin/sys.rs',
+        'src/tracer/mod.rs',
+        'src/tracer/sys.rs',
+        'src/lib.rs',
+    ),
+    output: 'libvlcrs_core.rlib',
+    depfile: 'libvlcrs_core.d',
+    depends: module_cargo_depends,
+    env: {
+      'RUSTFLAGS': rust_flags,
+      'CARGO_TARGET_DIR': cargo_target_dir
+    },
+    command: [cargo_output, '--output', '@OUTDIR@', '--depfile',
+        cargo_bin, 'build', '--locked', extra_cargo_args,
+        '--manifest-path', files('Cargo.toml'),
+        '-p', 'vlcrs-core']
+)


=====================================
src/rust/vlcrs-macros/meson.build
=====================================
@@ -0,0 +1,30 @@
+rust_macros_extension = ''
+if build_machine.system() == 'darwin'
+    rust_macros_extension = 'dylib'
+elif build_machine.system() == 'windows'
+    rust_macros_extension = 'dll'
+else
+    rust_macros_extension = 'so'
+endif
+
+vlcrs_core_macros = custom_target('vlcrs_macros-cargo',
+    capture: false,
+    console: true,
+    build_by_default: true,
+    input: files(
+        'Cargo.toml',
+        'src/lib.rs',
+        'src/module.rs',
+    ),
+    depfile: 'libvlcrs_macros.d',
+    output: 'libvlcrs_macros.@0@'.format(rust_macros_extension),
+    depends: module_cargo_depends,
+    env: {
+      'RUSTFLAGS': rust_flags,
+      'CARGO_TARGET_DIR': cargo_target_dir
+    },
+    command: [cargo_output, '--output', '@OUTDIR@', '--depfile',
+        cargo_bin, 'build', '--locked', extra_cargo_args,
+        '--manifest-path', files('Cargo.toml'),
+        '-p', 'vlcrs-macros']
+)



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/f58ef6d4d2e3365aeda72e6d273850936b4210f4...f4b7c133c5752e958912181e6a1e22b875417e87

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/f58ef6d4d2e3365aeda72e6d273850936b4210f4...f4b7c133c5752e958912181e6a1e22b875417e87
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to