Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
69 stars 50 forks source link

Setting `cprjdir` to `$ProjectDir()$/foo` will expand to the wrong path #1570

Closed Torbjorn-Svensson closed 1 week ago

Torbjorn-Svensson commented 2 weeks ago

Describe the bug When using a csolution file like this:

solution:
  output-dirs:
    intdir: $ProjectDir()$/build/$BuildType$
    outdir: $ProjectDir()$/build/$BuildType$
    cprjdir: $ProjectDir()$/baz
  generators:
    base-dir: $ProjectDir()$/generated
  build-types:
    - type: debug
      compiler: GCC
  target-types:
    - type: main
  projects:
    - project: foo/bar.cproject.yml

The expected place for the .cprj files are in foo/baz/, but it will be incorrectly expanded to ../../foo/baz/ (expressed relative to the .csolution.yml file).

To Reproduce

  1. Save the above as app.csolution.yml
  2. Create a sub-directory called foo.
  3. Create a minimal cproject.yml and save it to foo/bar.cproject.yml.
  4. Run csolution convert -s /absolute/path/to/app.csolution.yml

Expected behavior The .cprj files should be placed in foo/baz/.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

ReinhardKeil commented 2 weeks ago

To make it easier to reproduce you may attach a ZIP file with a test project.

For the native CMake backend we need to revise the possibilities of intdir:. Maybe we need to review also outdir: in this context.

Torbjorn-Svensson commented 2 weeks ago

To make it easier to reproduce you may attach a ZIP file with a test project.

I went one step further and created #1571 with a test case that highlights this problem. When creating the test case, I actually found that in some situations, the $ProjectDir()$ is not replaced and would create a directory with that literal name on the filesystem.