premake / premake/premake-core

cfg.buildtarget tokens incorrect in postbuildcommands

Open
#2,248 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

What seems to be the problem?
The various cfg.buildtarget tokens appear to be incorrect in postbuildcommands.

The complete (dummy) project I'm using for learning Premake demonstrates the bug: https://github.com/richard-sim/build-sys-eval/blob/248c0abae20a8509e0d8eb63e435fa3925e3cb06/foobar/src/premake5.lua#L62

postbuildcommands {
    "{ECHO} %{prj.name} cfg.buildtarget.directory: %[%{cfg.buildtarget.directory}]",
    "{ECHO} %{prj.name} cfg.buildtarget.relpath: %[%{cfg.buildtarget.relpath}]",
    "{ECHO} %{prj.name} !cfg.buildtarget.relpath: %[%{!cfg.buildtarget.relpath}]",
    "{ECHO} %{prj.name} cfg.buildtarget.abspath: %[%{cfg.buildtarget.abspath}]",
    "{ECHO} %{prj.name} !cfg.buildtarget.abspath: %[%{!cfg.buildtarget.abspath}]",
    "{ECHO} %{prj.name} cfg.buildtarget.name: %[%{cfg.buildtarget.name}]",
    "{ECHO} %{prj.name} cfg.buildtarget.basename: %[%{cfg.buildtarget.basename}]",
    "{ECHO} %{prj.name} cfg.buildtarget.extension: %[%{cfg.buildtarget.extension}]"
}

output:

L3a.vcxproj -> D:\dev\build-sys-eval\foobar\src\.build\bin\windows-x86_64-debug\L3a\L3a.exe
L3a cfg.buildtarget.directory: "D:\dev\build-sys-eval\foobar\src\.build\bin\windows-x86_64-debug\L3a\"
L3a cfg.buildtarget.relpath: "..\bin\windows-x86_64-debug\L3a\L3a.exe"
L3a !cfg.buildtarget.relpath: "..\bin\windows-x86_64-debug\L3a\L3a.exe"
L3a cfg.buildtarget.abspath: "..\bin\windows-x86_64-debug\L3a\L3a.exe"
L3a !cfg.buildtarget.abspath: "bin\windows-x86_64-debug\L3a\L3a.exe"
L3a cfg.buildtarget.name: "L3a.exe"
L3a cfg.buildtarget.basename: "L3a"
L3a cfg.buildtarget.extension: "..\.exe"

Partial directory structure:

foobar/
    src/
        .build/ <-- workspace location
            bin/ <-- workspace targetdir
                <per-config name>/
                    L3a/ <-- project's outputs
            obj/ <-- workspace objdir
                <per-config name>/
                    L3a/ <-- project's object files
        foobar/
            L3a/
                premake5.lua
        premake5.lua

What did you expect to happen?

  • cfg.buildtarget.directory I'd expect to be relative to foobar/src/Premake5.lua as per Premake convention, not absolute.
  • cfg.buildtarget.relpath I'd expect to be relative to foobar/src/Premake5.lua, not relative to what seems to be foobar/src/.build/obj/ for some reason?!
  • !cfg.buildtarget.relpath I'd expect to be the absolute path.
  • cfg.buildtarget.abspath I'd also expect to be the absolute path.
  • !cfg.buildtarget.abspath I'd expect to... also be the abs path.
  • cfg.buildtarget.extension I'd expect to be .exe not ..\.exe. That's quite a unique definition of extension!

What have you tried so far?
I'm using %[%{cfg.buildtarget.directory}%{cfg.buildtarget.basename}.ext], which while is an absolute path, is fine for my needs.

How can we reproduce this?
This bare-bones repo can be cloned: https://github.com/richard-sim/build-sys-eval/blob/248c0abae20a8509e0d8eb63e435fa3925e3cb06/foobar/src/premake5.lua#L62

  • [ x ] Visual Studio 2022 (vs2022)
  • [ x ] Other (Please list below) premake-cmake

What version of Premake are you using?
Latest master branch.

Anything else we should know?
I'm new here. :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked foobar/src/premake5.lua reproduction and run it against the latest master to confirm the reported token output. Trace how cfg.buildtarget.directory, relpath, abspath, name, basename, and extension are expanded; done means their values match the expectations listed for the Visual Studio and premake-cmake cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.