Skip to content

Commit

Permalink
Fix git version [Vas Crabb]
Browse files Browse the repository at this point in the history
* git version is set by top-level make, not just when GENie runs
* can set IGNORE_GIT=1 for make to ignore git
* git ignored/unavailable uses "unknown" in version string
* mark modified trees as dirty
* note that version now comes from makefile
  • Loading branch information
cuavas committed Jun 9, 2016
1 parent ebd8e7d commit 93cd0cd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 60 deletions.
47 changes: 34 additions & 13 deletions makefile
Expand Up @@ -15,6 +15,7 @@
# REGENIE = 1
# VERBOSE = 1
# NOWERROR = 1
# IGNORE_GIT = 1

# TARGET = mame
# SUBTARGET = tiny
Expand Down Expand Up @@ -893,26 +894,19 @@ $(error Python is not available in path)
endif

ifneq ($(GIT_AVAILABLE),git)
PARAMS += --IGNORE_GIT='1'
IGNORE_GIT := 1
endif
ifeq ($(wildcard .git/*),)
PARAMS += --IGNORE_GIT='1'
IGNORE_GIT := 1
endif

ifeq ($(GIT_AVAILABLE),git)
NEW_GIT_VERSION := $(shell git describe)
ifeq (posix,$(SHELLTYPE))
OLD_GIT_VERSION := $(shell cat .mame_version 2> /dev/null)
OLD_GIT_VERSION := $(file <$(GENDIR)/git_desc)
ifneq ($(IGNORE_GIT),1)
NEW_GIT_VERSION := $(shell git describe --dirty)
else
OLD_GIT_VERSION := $(shell cat .mame_version 2> NUL)
endif
ifneq ($(NEW_GIT_VERSION),$(OLD_GIT_VERSION))
$(shell git describe > .mame_version)
$(shell touch $(SRC)/version.cpp)
endif
NEW_GIT_VERSION := unknown
endif


GENIE := 3rdparty/genie/bin/$(GENIEOS)/genie$(EXE)

ifeq ($(TARGET),$(SUBTARGET_FULL))
Expand Down Expand Up @@ -1463,6 +1457,7 @@ genie: $(GENIE)
generate: \
genie \
$(GEN_FOLDERS) \
$(GENDIR)/version.cpp \
$(patsubst %.po,%.mo,$(call rwildcard, language/, *.po)) \
$(patsubst $(SRC)/%.lay,$(GENDIR)/%.lh,$(LAYOUTS)) \
$(GENDIR)/mame/drivers/ymmu100.hxx \
Expand All @@ -1473,6 +1468,32 @@ $(GENDIR)/includes/SDL2:
-$(call MKDIR,$@)
-$(call COPY,3rdparty/SDL2/include/,$(GENDIR)/includes/SDL2)

ifneq ($(NEW_GIT_VERSION),$(OLD_GIT_VERSION))
stale:

.PHONY: stale

$(GENDIR)/git_desc: stale | $(GEN_FOLDERS)
@echo $(NEW_GIT_VERSION) > $@
endif

ifeq (posix,$(SHELLTYPE))
$(GENDIR)/version.cpp: $(GENDIR)/git_desc | $(GEN_FOLDERS)
@echo '#define BARE_BUILD_VERSION "0.174"' > $@
@echo 'extern const char bare_build_version[];' >> $@
@echo 'extern const char build_version[];' >> $@
@echo 'const char bare_build_version[] = BARE_BUILD_VERSION;' >> $@
@echo 'const char build_version[] = BARE_BUILD_VERSION " ($(NEW_GIT_VERSION))";' >> $@
else
$(GENDIR)/version.cpp: $(GENDIR)/git_desc
@echo \#define BARE_BUILD_VERSION "0.174" > $@
@echo extern const char bare_build_version[]; >> $@
@echo extern const char build_version[]; >> $@
@echo const char bare_build_version[] = BARE_BUILD_VERSION; >> $@
@echo const char build_version[] = BARE_BUILD_VERSION " ($(NEW_GIT_VERSION))"; >> $@
endif


$(GENDIR)/%.lh: $(SRC)/%.lay scripts/build/complay.py | $(GEN_FOLDERS)
@echo Compressing $<...
$(SILENT)$(PYTHON) scripts/build/complay.py $< $@ layout_$(basename $(notdir $<))
Expand Down
9 changes: 0 additions & 9 deletions scripts/genie.lua
Expand Up @@ -349,15 +349,6 @@ newoption {
}
}

newoption {
trigger = "IGNORE_GIT",
description = "Ignore usage of git command in build process",
allowed = {
{ "0", "Do not ignore" },
{ "1", "Ingore" },
},
}

newoption {
trigger = "SOURCES",
description = "List of sources to compile.",
Expand Down
20 changes: 5 additions & 15 deletions scripts/src/main.lua
Expand Up @@ -147,17 +147,7 @@ end
end

configuration { }

if _OPTIONS["IGNORE_GIT"]~="1" then
GIT_VERSION = backtick( "git describe --dirty" )
local p = string.find(GIT_VERSION, '-', 1)
if (p~=nil) then
defines {
"GIT_VERSION=" .. string.sub(GIT_VERSION,p+1)
}
end
end


if _OPTIONS["targetos"]=="android" then
includedirs {
MAME_DIR .. "3rdparty/SDL2/include",
Expand Down Expand Up @@ -277,7 +267,7 @@ if (STANDALONE~=true) then
"-sectcreate __TEXT __info_plist " .. _MAKE.esc(GEN_DIR) .. "resource/" .. _subtarget .. "-Info.plist"
}
custombuildtask {
{ MAME_DIR .. "src/version.cpp" , GEN_DIR .. "resource/" .. _subtarget .. "-Info.plist", { MAME_DIR .. "scripts/build/verinfo.py" }, {"@echo Emitting " .. _subtarget .. "-Info.plist" .. "...", PYTHON .. " $(1) -p -b " .. _subtarget .. " $(<) > $(@)" }},
{ GEN_DIR .. "version.cpp" , GEN_DIR .. "resource/" .. _subtarget .. "-Info.plist", { MAME_DIR .. "scripts/build/verinfo.py" }, {"@echo Emitting " .. _subtarget .. "-Info.plist" .. "...", PYTHON .. " $(1) -p -b " .. _subtarget .. " $(<) > $(@)" }},
}
dependency {
{ "$(TARGET)" , GEN_DIR .. "resource/" .. _subtarget .. "-Info.plist", true },
Expand Down Expand Up @@ -312,7 +302,7 @@ if (STANDALONE~=true) then
end
files {
mainfile,
MAME_DIR .. "src/version.cpp",
GEN_DIR .. "version.cpp",
GEN_DIR .. _target .. "/" .. _subtarget .."/drivlist.cpp",
}

Expand Down Expand Up @@ -355,14 +345,14 @@ if (STANDALONE~=true) then

configuration { "mingw*" }
custombuildtask {
{ MAME_DIR .. "src/version.cpp" , GEN_DIR .. "resource/" .. rctarget .. "vers.rc", { MAME_DIR .. "scripts/build/verinfo.py" }, {"@echo Emitting " .. rctarget .. "vers.rc" .. "...", PYTHON .. " $(1) -r -b " .. rctarget .. " $(<) > $(@)" }},
{ GEN_DIR .. "version.cpp" , GEN_DIR .. "resource/" .. rctarget .. "vers.rc", { MAME_DIR .. "scripts/build/verinfo.py" }, {"@echo Emitting " .. rctarget .. "vers.rc" .. "...", PYTHON .. " $(1) -r -b " .. rctarget .. " $(<) > $(@)" }},
}

configuration { "vs*" }
prebuildcommands {
"mkdir " .. path.translate(GEN_DIR .. "resource/","\\") .. " 2>NUL",
"@echo Emitting ".. rctarget .. "vers.rc...",
PYTHON .. " " .. path.translate(MAME_DIR .. "scripts/build/verinfo.py","\\") .. " -r -b " .. rctarget .. " " .. path.translate(MAME_DIR .. "src/version.cpp","\\") .. " > " .. path.translate(GEN_DIR .. "resource/" .. rctarget .. "vers.rc", "\\") ,
PYTHON .. " " .. path.translate(MAME_DIR .. "scripts/build/verinfo.py","\\") .. " -r -b " .. rctarget .. " " .. path.translate(GEN_DIR .. "version.cpp","\\") .. " > " .. path.translate(GEN_DIR .. "resource/" .. rctarget .. "vers.rc", "\\") ,
}
end

Expand Down
2 changes: 1 addition & 1 deletion scripts/src/tools.lua
Expand Up @@ -87,7 +87,7 @@ includedirs {
files {
MAME_DIR .. "src/tools/chdman.cpp",
MAME_DIR .. "src/emu/emucore.cpp",
MAME_DIR .. "src/version.cpp",
GEN_DIR .. "version.cpp",
}

configuration { "mingw*" or "vs*" }
Expand Down
22 changes: 0 additions & 22 deletions src/version.cpp

This file was deleted.

0 comments on commit 93cd0cd

Please sign in to comment.