Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@PRIVATE_DIR@ in run_target() trigger an unhandled exception #14082

Open
DevilishSpirits opened this issue Jan 7, 2025 · 0 comments
Open

@PRIVATE_DIR@ in run_target() trigger an unhandled exception #14082

DevilishSpirits opened this issue Jan 7, 2025 · 0 comments

Comments

@DevilishSpirits
Copy link

Describe the bug
Using @PRIVATE_DIR@ in a run_target() command array trigger an error.

$ meson setup builddir
The Meson build system
Version: 1.6.1
Source dir: /tmp/run_target_private_dir
Build dir: /tmp/run_target_private_dir/builddir
Build type: native build
Project name: run_target_private_dir
Project version: undefined
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1

Found ninja-1.12.1 at /usr/bin/ninja
Traceback (most recent call last):                                                                                                                                                                                  
  File "/usr/lib/python3.13/site-packages/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 365, in run
    app.generate()
    ~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 188, in generate
    return self._generate(env, capture, vslite_ctx)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 253, in _generate
    captured_compile_args = intr.backend.generate(capture, vslite_ctx)
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/ninjabackend.py", line 656, in generate
    self.generate_target(t)
    ~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/ninjabackend.py", line 883, in generate_target
    self.generate_run_target(target)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/ninjabackend.py", line 1239, in generate_run_target
    _, _, cmd = self.eval_custom_target_command(target)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/backends.py", line 1586, in eval_custom_target_command
    pdir = self.get_target_private_dir_abs(target)
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/backends.py", line 395, in get_target_private_dir_abs
    return os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target))
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/backends.py", line 392, in get_target_private_dir
    return os.path.join(self.get_target_filename(target, warn_multi_output=False) + '.p')
                        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/backend/backends.py", line 304, in get_target_filename
    assert isinstance(t, build.BuildTarget), t
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
AssertionError: <RunTarget private_dir_failure@run: /usr/bin/mkdir>

ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

To Reproduce

Use this meson.build file :

project('run_target_private_dir')

run_target('private_dir_failure', command: [
	'mkdir','@PRIVATE_DIR@'
])

Expected behavior
I initially expected Meson to adopt the same behavior than in custom_target() by allocating a directory path for private data.
Though after reading the documentation this substitution not listed among the supported ones.

In case this is not supported I expect Meson to catch to produce a clear error such as @PRIVATE_DIR@ substitutions are not supported in run_target() command.

I did more testing and found that @BUILD_ROOT@ and @OUTPUT@ substitution works, the later expanding to the target name in Ninja.build.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native
  • what operating system : ArchLinux
  • what Python version : Python 3.13.1
  • what meson --version : 1.6.1
  • what ninja --version : 1.12.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant