release.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function dorelease()
  2. --
  3. -- Helper function: runs a command (formatted, with optional arguments) and
  4. -- suppresses any output. Works on both Windows and POSIX. Might be a good
  5. -- candidate for a core function.
  6. --
  7. local function exec(cmd, ...)
  8. cmd = string.format(cmd, ...)
  9. local z = os.execute(cmd .. " > output.log 2> error.log")
  10. os.remove("output.log")
  11. os.remove("error.log")
  12. return z
  13. end
  14. print("Updating version number...")
  15. local f = io.popen("git rev-list --count HEAD")
  16. local rev = string.match(f:read("*a"), ".*%S")
  17. f:close()
  18. f = io.popen("git log --format=format:%H -1")
  19. local sha1 = f:read("*a")
  20. f:close()
  21. io.output("src/host/version.h")
  22. io.write("#define VERSION " ..rev .. "\n")
  23. io.write("#define VERSION_STR \"version " ..rev .. " (commit " .. sha1 .. ")\"\n")
  24. io.close()
  25. print("Updating embedded scripts...")
  26. local z = exec(_PREMAKE_COMMAND .. " embed")
  27. if z ~= true then
  28. error("** Failed to update the embedded scripts", 0)
  29. end
  30. print("Generating project files...")
  31. exec(_PREMAKE_COMMAND .. " /to=../build/gmake.windows /os=windows gmake")
  32. exec(_PREMAKE_COMMAND .. " /to=../build/gmake.linux /os=linux gmake")
  33. exec(_PREMAKE_COMMAND .. " /to=../build/gmake.darwin /os=macosx /platform=universal32 gmake")
  34. print("")
  35. print( "Finished.")
  36. end