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

[criterion] Adapt JSON traversal to work with later versions of meson #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oyvindaakre
Copy link
Contributor

@oyvindaakre oyvindaakre commented Feb 11, 2025

The criterion adapter uses meson introspect --targets to map the currently open buffer with a test executable. The output of this command has changed with later versions of meson which breaks this adapter in its current form when traversing the decoded json.

Specifically the target_sources entry can contain linker information on newer versions whereas older versions does not include that. The adapter was originally written using meson version 0.64.1 where this issue went unnoticed.

These changes has been tested with meson version 0.64.1 and 1.5.1.

Example output with meson 1.5.1

[
  {
    "name": "hello",
    "id": "hello@exe",
    "type": "executable",
    "defined_in": "/home/oyvind/hello/meson.build",
    "filename": [
      "/home/oyvind/hello/build/hello"
    ],
    "target_sources": [
      {
        "language": "c",
        "compiler": [
          "cc"
        ],
        "parameters": [
          "-I/home/oyvind/hello/build/hello.p",
          "-I/home/oyvind/hello/build",
          "-I/home/oyvind/hello",
          "-fdiagnostics-color=always",
          "-D_FILE_OFFSET_BITS=64",
          "-Wall",
          "-Winvalid-pch",
          "-Wextra",
          "-Wpedantic",
          "-O0",
          "-g"
        ],
        "sources": [
          "/home/oyvind/hello/hello.c"
        ],
        "generated_sources": [],
        "unity_sources": []
      },
      {
        "linker": [
          "cc"
        ],
        "parameters": [
          "-Wl,--as-needed",
          "-Wl,--no-undefined"
        ]
      }
    ],
    "extra_files": [],
    "subproject": null,
    "dependencies": [],
    "depends": [],
    "win_subsystem": "console",
    "installed": true,
    "install_filename": [
      "/usr/local/bin/hello"
    ]
  }
]

Example output with meson 0.64.1

[
  {
    "name": "hello",
    "id": "hello@exe",
    "type": "executable",
    "defined_in": "/home/oyvind/hello/meson.build",
    "filename": [
      "/home/oyvind/hello/build/hello"
    ],
    "build_by_default": true,
    "target_sources": [
      {
        "language": "c",
        "compiler": [
          "cc"
        ],
        "parameters": [
          "-I/home/oyvind/hello/build/hello.p",
          "-I/home/oyvind/hello/build",
          "-I/home/oyvind/hello",
          "-fdiagnostics-color=always",
          "-D_FILE_OFFSET_BITS=64",
          "-Wall",
          "-Winvalid-pch",
          "-Wextra",
          "-Wpedantic",
          "-O0",
          "-g"
        ],
        "sources": [
          "/home/oyvind/hello/hello.c"
        ],
        "generated_sources": []
      }
    ],
    "extra_files": [],
    "subproject": null,
    "installed": true,
    "install_filename": [
      "/usr/local/bin/hello"
    ]
  }
]

… meson 1.5.1

The plugin was originally written using meson version <1.0.

At some point meson started adding linker information to
"target_sources" in the output generated from the command:
  meson introspect --targets build

This breaks the code which this commit attempts to fix.
Tested on both meson 0.64.1 and meson 1.5.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

Successfully merging this pull request may close these issues.

1 participant