preprocessor define with content of a build variable

Sysprogs forums Forums VisualGDB preprocessor define with content of a build variable

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6888
    ahaupt
    Participant

    Hi all,

    I want to set a preprocessor define with the hash of my current git revision. I managed to put the revision into a custom build variable (git rev-parse HEAD in a custom build step).

    I tried to add  GITREV=”$(GIT_REVISION)” to the preprocessor macros in the Makefile-settings but that expands to -DGITREV=”” during the compiler run.

    What do i miss?

     

    regards,

     

    Andre

    #6894
    support
    Keymaster

    Please double-check that your custom variable has the “propagate to the environment” flag. This can be also caused by a bug in the .Net framework that changes all environment variables to lowercase. You can try $(git_revision) instead. If this does not help, you can explicitly specify it in GNU Make arguments: GIT_REVISION=$(GIT_REVISION). Then VisualGDB will expand $(GIT_REVISION) and pass the actual value to the Make command line.

    #6895
    ahaupt
    Participant

    There is no “propagate to the environment” flag if i set the variable via a custom build step.
    I do now specify it explicitly in the make arguments, as you suggested, and that works fine.

    Thank you very much.

    For the record, here is how to get the git revision as a preprocessor definition:

    1. add a custom build step that sets the variable to the output of git rev-parse:

    2. in the makefile settings add GITREV=$(GitRevision) to the preprocessor macros
    3. add these addtional arguments to make: GitRevision=$(GitRevision)

    #6901
    support
    Keymaster

    Hi,

    The “propagate to the environment” flag is only supported for the per-user variables, not for variables set from commands. In the case you mentioned, specifying GitRevision=$(GitRevision) explicitly is the recommended way to go.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.