Fix git version [Vas Crabb]

* 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
This commit is contained in:
Vas Crabb 2016-06-10 00:36:29 +10:00
parent ebd8e7d74b
commit 93cd0cd40b
5 changed files with 40 additions and 60 deletions

View File

@ -15,6 +15,7 @@
# REGENIE = 1
# VERBOSE = 1
# NOWERROR = 1
# IGNORE_GIT = 1
# TARGET = mame
# SUBTARGET = tiny
@ -893,25 +894,18 @@ $(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)
NEW_GIT_VERSION := unknown
endif
ifneq ($(NEW_GIT_VERSION),$(OLD_GIT_VERSION))
$(shell git describe > .mame_version)
$(shell touch $(SRC)/version.cpp)
endif
endif
GENIE := 3rdparty/genie/bin/$(GENIEOS)/genie$(EXE)
@ -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 \
@ -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 $<))

View File

@ -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.",

View File

@ -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",
@ -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 },
@ -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",
}
@ -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

View File

@ -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*" }

View File

@ -1,22 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
version.c
Version string source file for MAME.
***************************************************************************/
#define BARE_BUILD_VERSION "0.174"
extern const char bare_build_version[];
extern const char build_version[];
const char bare_build_version[] = BARE_BUILD_VERSION;
#if defined(GIT_VERSION)
#define VERSION_TO_STRING(s) XVERSION_TO_STRING(s)
#define XVERSION_TO_STRING(ver) #ver
const char build_version[] = BARE_BUILD_VERSION " (" VERSION_TO_STRING(GIT_VERSION) ")";
#else
const char build_version[] = BARE_BUILD_VERSION;
#endif