Skip to content

Instantly share code, notes, and snippets.

@DanielG
Last active January 24, 2021 11:04
Show Gist options
  • Select an option

  • Save DanielG/d12035ea90eefd87d6ba1aad2ed2477f to your computer and use it in GitHub Desktop.

Select an option

Save DanielG/d12035ea90eefd87d6ba1aad2ed2477f to your computer and use it in GitHub Desktop.

Revisions

  1. DanielG revised this gist Jan 24, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.mk
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ F:=$$F
    dollar := $$

    # This stuff gets expanded at git-archive(1) time due to the export-subst
    # setting for this file in .gitattributes
    # setting for this file in .gitattributes. See gitattributes(5)
    GIT_COMMIT := $Format:%H$
    GIT_DATE := $Format:%cD$
    GIT_TIMESTAMP := $Format:%ct$
  2. DanielG revised this gist Jan 24, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.mk
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ GIT_TIMESTAMP := $Format:%ct$
    GIT_SUBJ := $Format:%s$
    GIT_DIRTY :=

    # If the above didn't get expanded get version info straight from git
    # If the above wasn't expanded get version info straight from git
    ifeq ($(GIT_COMMIT),$(dollar)Format:%H$(dollar))
    GIT_COMMIT := $(shell git rev-parse HEAD)
    GIT_DATE := $(shell git show -s --pretty=format:%cD)
  3. DanielG revised this gist Jan 24, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git.mk
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ GIT_TIMESTAMP := $Format:%ct$
    GIT_SUBJ := $Format:%s$
    GIT_DIRTY :=

    # If the above didn't get expanded get version info straight from git
    ifeq ($(GIT_COMMIT),$(dollar)Format:%H$(dollar))
    GIT_COMMIT := $(shell git rev-parse HEAD)
    GIT_DATE := $(shell git show -s --pretty=format:%cD)
  4. DanielG revised this gist Jan 24, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.mk
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # SPDX-License-Identifier: FSFAP OR CC0-1.0
    # SPDX-License-Identifier: MIT OR FSFAP OR CC0-1.0

    F:=$$F
    dollar := $$
  5. DanielG revised this gist Jan 24, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git.mk
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # SPDX-License-Identifier: FSFAP OR CC0-1.0

    F:=$$F
    dollar := $$

  6. DanielG created this gist Jan 24, 2021.
    1 change: 1 addition & 0 deletions .gitattributes
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    /git.mk export-subst
    26 changes: 26 additions & 0 deletions git.mk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    F:=$$F
    dollar := $$

    # This stuff gets expanded at git-archive(1) time due to the export-subst
    # setting for this file in .gitattributes
    GIT_COMMIT := $Format:%H$
    GIT_DATE := $Format:%cD$
    GIT_TIMESTAMP := $Format:%ct$
    GIT_SUBJ := $Format:%s$
    GIT_DIRTY :=

    ifeq ($(GIT_COMMIT),$(dollar)Format:%H$(dollar))
    GIT_COMMIT := $(shell git rev-parse HEAD)
    GIT_DATE := $(shell git show -s --pretty=format:%cD)
    GIT_TIMESTAMP := $(shell git show -s --pretty=format:%ct)
    GIT_SUBJ := $(shell git show -s --pretty=format:%s)
    GIT_DIRTY := -dirty
    endif

    .PHONY: FORCE
    git.h: FORCE
    @printf ' GIT\t$@\n'
    @echo '#pragma once' > $@
    @echo '#define GIT_COMMIT "commit $(GIT_COMMIT)$(GIT_DIRTY)"' >> $@
    @echo '#define GIT_SUBJ "$(GIT_SUBJ)"' >> $@
    @echo '#define GIT_DATE "$(GIT_DATE)"' >> $@