Debugging meson

Recently I started using meson for personal mini projects. I have used CMake in the past and my personal impression is that things get rapidly complicated and I believe they don't need to be like so. I prefer meson for its simplicity.

These days meson build seems promising except its Xcode support is not very good (apparently not many Xcode users use meson). So I decided to fix it myself (at least the parts I know). I write my notes here since I am not very familiar with python and its development environment.

Notes on how to debug/fix issues with meson

  1. Clone meson
    git clone git@github.com:mesonbuild/meson.git
    
  2. Open meson directory in Visual Code
    code meson
    
  3. Create settings.json and launch.json
    • settings.json
      Create settings.json to make sure the correct python version (3.5 or above) is set for the workspace (and also because I want Visual Code stop asking me frequently if it should install a linter. I set it to no because I already set the git commit hook recommended for this project. )

      This is my .vscode/settings.json file:
      {
          "python.linting.pylintEnabled": false,
          "python.pythonPath": "/usr/local/bin/python3"
      }
      
    • launch.json
      Create launch.json to be able to start the debugger from within the editor window and be able to put breakpoints and inspect variables more easily.
      Simple create file .vscode/launch.json with below contents.
      FYI: To create the default launch,json file change to the debug pane (Shift + Cmd + D) and add a configuration; The file will be created with various debug configurations. Most of them are for server/client development and are not relevant to meson project, feel free to delete them if not needed.

      This is my .vscode/launch.json file:
      {
          "version": "0.2.0",
          "configurations": [
              // Configuration that uses meson.py to run one of the project tests.
              // Move to a test dir and execute `meson.py build --backend=xcode`.
              {
                  "name": "run project test 1",
                  "type": "python",
                  "request": "launch",
                  "program": "${workspaceFolder}/meson.py",
                  "console": "integratedTerminal",
                  "args": [
                      "build",
                      "--backend=xcode",
                  ],
                  "cwd": "${workspaceFolder}/test cases/common/1 trivial"
              },
              // Configuration that uses run_unittests.py to run a particular test.
              // Move to root directory and execute:
              // `run_unittests.py -v TestCase.testMethod`. Since `--backend=xcode`
              // cannot be set via an argument use an environment variable.
              {
                  "name": "run_unittests.py",
                  "type": "python",
                  "request": "launch",
                  "program": "${workspaceFolder}/run_unittests.py",
                  "console": "integratedTerminal",
                  "args": [
                      "-v",
                      "AllPlatformTests.test_always_prefer_c_compiler_for_asm",
                  ],
                  "cwd": "${workspaceFolder}",
                  "env": {
                      "MESON_UNIT_TEST_BACKEND":"xcode"
                  }
              },
          ]
      }
      
  4. Now just set your brake points and debug/code :)

0 comments :

This work is licensed under BSD Zero Clause License | nacho4d ®