aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/include/genie/scripts/release.lua
blob: d1173d5f9e85042aea76f1f3cdb05c00c11012ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function dorelease()
	--
	-- Helper function: runs a command (formatted, with optional arguments) and
	-- suppresses any output. Works on both Windows and POSIX. Might be a good
	-- candidate for a core function.
	--
	local function exec(cmd, ...)
		cmd = string.format(cmd, ...)
		local z = os.execute(cmd .. " > output.log 2> error.log")
		os.remove("output.log")
		os.remove("error.log")
		return z
	end


	print("Updating version number...")

	local f = io.popen("git rev-list --count HEAD")
	local rev = string.match(f:read("*a"), ".*%S")
	f:close()
	f = io.popen("git log --format=format:%H -1")
	local sha1 = f:read("*a")
	f:close()
	io.output("src/host/version.h")
	io.write("#define VERSION " ..rev .. "\n")
	io.write("#define VERSION_STR \"version " ..rev .. " (commit " .. sha1 .. ")\"\n")
	io.close()


	print("Updating embedded scripts...")

	local z = exec(_PREMAKE_COMMAND .. " embed")
	if z ~= true then
		error("** Failed to update the embedded scripts", 0)
	end


	print("Generating project files...")

	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.windows /os=windows gmake")
	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.linux /os=linux gmake")
	exec(_PREMAKE_COMMAND .. " /to=../build/gmake.darwin /os=macosx /platform=universal32 gmake")

	print("")
	print( "Finished.")

end