Browse Source

Install worlds correctly.

master
poikilos 5 years ago
parent
commit
1c9cc7c5c1
  1. 98
      utilities/mtcompile-program-local.py

98
utilities/mtcompile-program-local.py

@ -207,16 +207,16 @@ for changes and progress on implementing features from
mtcompile-program.pl. mtcompile-program.pl.
""" """
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# module setup # module setup
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# TODO: Trap warnings to mimic the Perl version? # TODO: Trap warnings to mimic the Perl version?
#SIG["__WARN__"] = sub { die @_; } #SIG["__WARN__"] = sub { die @_; }
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# program parameters # program parameters
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
def streamEdit(inPath, replacements): def streamEdit(inPath, replacements):
""" """
@ -288,16 +288,16 @@ GITURL = 'http://git.minetest.org/minetest/minetest.git'
IE = 'Internal error' IE = 'Internal error'
Flags = {} Flags = {}
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# global variables # global variables
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
PROGNAME = None # Program name without path PROGNAME = None # Program name without path
DirStack = [os.getcwd()] # Directory stack DirStack = [os.getcwd()] # Directory stack
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# used by "--oldproto" # used by "--oldproto"
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
segment = """ segment = """
set(VERSION_MAJOR 0) set(VERSION_MAJOR 0)
@ -319,9 +319,9 @@ if VERSION_EXTRA:
if CMAKE_BUILD_TYPE STREQUAL Debug: if CMAKE_BUILD_TYPE STREQUAL Debug:
""" """
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
# low-level utility routines # low-level utility routines
#--------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -485,13 +485,13 @@ def UsageText(msg=""):
def main(): def main():
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Misc. variables. # Misc. variables.
#my $cmd; # Shell command string #my $cmd; # Shell command string
#my $tmpStr; # Scratch #my $tmpStr; # Scratch
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Mode flags. # Mode flags.
# These may be modified, indirectly, by command-line switches. # These may be modified, indirectly, by command-line switches.
@ -522,13 +522,13 @@ def main():
Flags["oldproto"] = True Flags["oldproto"] = True
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Initial setup. # Initial setup.
#select STDERR; $| = ONE; # Force STDERR flush on write #select STDERR; $| = ONE; # Force STDERR flush on write
#select STDOUT; $| = ONE; # Force STDOUT flush on write #select STDOUT; $| = ONE; # Force STDOUT flush on write
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Get absolute path for script directory. # Get absolute path for script directory.
# As a side effect, this function call initializes the global variable # As a side effect, this function call initializes the global variable
@ -537,7 +537,7 @@ def main():
THISDIR = GetProgDir() THISDIR = GetProgDir()
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Parse command-line arguments. # Parse command-line arguments.
if not GetOptions(nonBoolNames=["MT_SRC"], bareArgs=["build"]): if not GetOptions(nonBoolNames=["MT_SRC"], bareArgs=["build"]):
@ -562,7 +562,7 @@ def main():
"".format(Flags)) "".format(Flags))
UsageText(msg=msg) UsageText(msg=msg)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle misc. flag issues. # Handle misc. flag issues.
if Flags["edgy"]: if Flags["edgy"]:
Flags["fakemt4"] = True Flags["fakemt4"] = True
@ -571,7 +571,7 @@ def main():
if Flags["edgy"] and Flags["gitpull"]: if Flags["edgy"] and Flags["gitpull"]:
customExit("Error: Can't use both --edgy and --gitpull") customExit("Error: Can't use both --edgy and --gitpull")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Confirm that script is running in the right place. # Confirm that script is running in the right place.
if not os.path.isdir('mtsrc'): if not os.path.isdir('mtsrc'):
@ -581,7 +581,7 @@ which contains the "mtsrc" directory.
""") """)
exit(1) exit(1)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Additional directory paths. # Additional directory paths.
BALLDIR = os.path.join(THISDIR, "mtsrc", "newline") BALLDIR = os.path.join(THISDIR, "mtsrc", "newline")
@ -593,12 +593,12 @@ which contains the "mtsrc" directory.
LIBDIR = os.path.join(TOOLS_PREFIX, "lib") LIBDIR = os.path.join(TOOLS_PREFIX, "lib")
LIB64DIR = os.path.join(TOOLS_PREFIX, "lib64") LIB64DIR = os.path.join(TOOLS_PREFIX, "lib64")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Misc. setup. # Misc. setup.
if not BINDIR in os.environ["PATH"]: if not BINDIR in os.environ["PATH"]:
os.environ["PATH"] = BINDIR + os.pathsep + os.environ["PATH"] os.environ["PATH"] = BINDIR + os.pathsep + os.environ["PATH"]
which("g++") which("g++")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle some of the option flags. # Handle some of the option flags.
if Flags["debug"]: if Flags["debug"]:
MAKEDEBUG = True MAKEDEBUG = True
@ -612,7 +612,7 @@ which contains the "mtsrc" directory.
PORTABLE = True PORTABLE = True
TIDYUP = True TIDYUP = True
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--gitreset". # Handle "--gitreset".
if Flags["gitreset"]: if Flags["gitreset"]:
@ -638,7 +638,7 @@ move or rename the directory.
print(" " + " ".join(cmdParts)) print(" " + " ".join(cmdParts))
RunCmd(cmdParts); RunCmd(cmdParts);
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--gitpull". # Handle "--gitpull".
if Flags["gitpull"]: if Flags["gitpull"]:
@ -681,7 +681,7 @@ automatically.
RunCmd(cmdParts, exit_on_fail=false) RunCmd(cmdParts, exit_on_fail=false)
popd(); popd();
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--client" and "--server". # Handle "--client" and "--server".
client_line = "-DBUILD_CLIENT=1" client_line = "-DBUILD_CLIENT=1"
@ -695,7 +695,7 @@ automatically.
client_line = "-DBUILD_CLIENT=0" client_line = "-DBUILD_CLIENT=0"
server_line = "-DBUILD_SERVER=1" server_line = "-DBUILD_SERVER=1"
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Status messages. # Status messages.
NUBDF = "not used by default in this version" NUBDF = "not used by default in this version"
@ -705,7 +705,7 @@ automatically.
* sqlite3 (by default) * sqlite3 (by default)
""") """)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--postgres". # Handle "--postgres".
postgres_line = "-DENABLE_POSTGRESQL=0" postgres_line = "-DENABLE_POSTGRESQL=0"
@ -716,7 +716,7 @@ automatically.
else: else:
print("(skipping postgresql --"+NUBDF) print("(skipping postgresql --"+NUBDF)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--redis". # Handle "--redis".
redis_line = "-DENABLE_REDIS=0" redis_line = "-DENABLE_REDIS=0"
@ -727,7 +727,7 @@ automatically.
else: else:
print("(skipping redis --"+NUBDF) print("(skipping redis --"+NUBDF)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# "--portable" requires the bootstrapped "gcc". # "--portable" requires the bootstrapped "gcc".
if PORTABLE and not os.path.isfile(os.path.join(BINDIR, "gcc")): if PORTABLE and not os.path.isfile(os.path.join(BINDIR, "gcc")):
@ -738,7 +738,7 @@ gcc-bootstrap mode enabled.
""") """)
exit(1) exit(1)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Identify "gcc" major release number. # Identify "gcc" major release number.
#my ($GCCVER) = $tmpStr =~ m@\ngcc.* (\d+)*\.\d+\.@ #my ($GCCVER) = $tmpStr =~ m@\ngcc.* (\d+)*\.\d+\.@
@ -750,7 +750,7 @@ gcc-bootstrap mode enabled.
else: else:
customExit("Error: Not able to identify gcc release") customExit("Error: Not able to identify gcc release")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Replace existing "minetest" directory. # Replace existing "minetest" directory.
RESETDIR = (not os.path.isdir(PRODDIR)) or TIDYUP RESETDIR = (not os.path.isdir(PRODDIR)) or TIDYUP
@ -806,7 +806,7 @@ or rename it. Otherwise, drop the "--safe" switch.
os.chdir(PRODDIR) os.chdir(PRODDIR)
# or die "$IE #505850\n"; # or die "$IE #505850\n";
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Sanity check. # Sanity check.
if not os.path.isfile('CMakeLists.txt'): if not os.path.isfile('CMakeLists.txt'):
@ -820,7 +820,7 @@ again.
""") """)
exit(1) exit(1)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Delete leftover temporary files. # Delete leftover temporary files.
tmpFileNames = [ tmpFileNames = [
"C.includecache", "C.includecache",
@ -864,7 +864,7 @@ again.
elif endsWithAny(subPath, tmpFilePaths + tmpExtensions): elif endsWithAny(subPath, tmpFilePaths + tmpExtensions):
os.remove(subPath) os.remove(subPath)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Define paths for some ".a" library files. # Define paths for some ".a" library files.
IRRLICHT_LIBRARY = os.path.join(LIBDIR, "libIrrlicht.a") IRRLICHT_LIBRARY = os.path.join(LIBDIR, "libIrrlicht.a")
@ -872,7 +872,7 @@ again.
LUA_LIBRARY = os.path.join(LIBDIR, "libluajit-5.1.a") LUA_LIBRARY = os.path.join(LIBDIR, "libluajit-5.1.a")
SQLITE3_LIBRARY = os.path.join(LIBDIR, "libsqlite3.a") SQLITE3_LIBRARY = os.path.join(LIBDIR, "libsqlite3.a")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Set "$XCFLAGS" (extra compiler flags). # Set "$XCFLAGS" (extra compiler flags).
XCFLAGS = "-O2 -I" + INCDIR XCFLAGS = "-O2 -I" + INCDIR
@ -886,7 +886,7 @@ again.
print("XCFLAGS="+XCFLAGS) print("XCFLAGS="+XCFLAGS)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Get pathnames for "gcc" and "g++" compilers. # Get pathnames for "gcc" and "g++" compilers.
WHICH_GCC = which("gcc") WHICH_GCC = which("gcc")
@ -902,7 +902,7 @@ again.
customExit("g++ is not present or not executable in {}." customExit("g++ is not present or not executable in {}."
"".format(os.environ["PATH"])) "".format(os.environ["PATH"]))
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle another "--edgy step". # Handle another "--edgy step".
if Flags["edgy"]: if Flags["edgy"]:
@ -927,7 +927,7 @@ again.
# OFD.write(data) # OFD.write(data)
# except FileNotFoundError: # except FileNotFoundError:
# customExit("Internal error 0777") # customExit("Internal error 0777")
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--fakemt4". # Handle "--fakemt4".
if Flags["fakemt4"]: if Flags["fakemt4"]:
@ -957,7 +957,7 @@ again.
# OFD.write(data) # OFD.write(data)
# OFD.close() # or die "Internal error 0808\n"; # OFD.close() # or die "Internal error 0808\n";
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Handle "--oldproto". # Handle "--oldproto".
if Flags["oldproto"]: if Flags["oldproto"]:
@ -976,7 +976,7 @@ again.
# with open("CM", 'w') as OFD: # or die "Internal error 0715\n"; # with open("CM", 'w') as OFD: # or die "Internal error 0715\n";
# OFD.write(data) # OFD.write(data)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Run "cmake". # Run "cmake".
cmdParts = ["cmake"] cmdParts = ["cmake"]
cmdParts.append("-DCMAKE_BUILD_TYPE=release") cmdParts.append("-DCMAKE_BUILD_TYPE=release")
@ -1022,7 +1022,7 @@ again.
os.system(" ".join(cmdParts)) os.system(" ".join(cmdParts))
# TODO: use some absolute pathnames as the Perl version does # TODO: use some absolute pathnames as the Perl version does
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Replace some "-l..." switches with absolute pathnames. # Replace some "-l..." switches with absolute pathnames.
replacements = { replacements = {
@ -1037,7 +1037,7 @@ again.
if name == "link.txt": if name == "link.txt":
streamEdit(subPath, replacements) streamEdit(subPath, replacements)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Build the program. # Build the program.
NUMJOBS = 3 NUMJOBS = 3
print("* running make in {}...".format(os.getcwd())) print("* running make in {}...".format(os.getcwd()))
@ -1050,7 +1050,7 @@ again.
dstAKPath = os.path.join(PRODDIR, "arrowkeys.txt") dstAKPath = os.path.join(PRODDIR, "arrowkeys.txt")
shutil.copy(os.path.join(BALLDIR, "arrowkeys.txt"), dstAKPath) shutil.copy(os.path.join(BALLDIR, "arrowkeys.txt"), dstAKPath)
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Add preloaded cache. # Add preloaded cache.
thisCache = os.path.join(PRODDIR, "cache") thisCache = os.path.join(PRODDIR, "cache")
if os.path.isdir(thisCache): if os.path.isdir(thisCache):
@ -1060,7 +1060,7 @@ again.
tar.extractall(path=PRODDIR) tar.extractall(path=PRODDIR)
tar.close() tar.close()
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Add "_games". # Add "_games".
pushd('games'); pushd('games');
@ -1086,18 +1086,20 @@ again.
zf.extractall(gamePath) # pwd means password in this case zf.extractall(gamePath) # pwd means password in this case
popd(); popd();
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Add worlds. # Add worlds.
# pushd('worlds'); # pushd('worlds');
WORLDS_PATH = os.path.join(PRODDIR, "worlds") WORLDS_PATH = os.path.join(PRODDIR, "worlds")
for worldName in ["Bucket_City", "Wonder_World"]: for worldName in ["Bucket_City", "Wonder_World"]:
worldPath = os.path.join(WORLDS_PATH, worldName) worldPath = os.path.join(WORLDS_PATH, worldName)
tarPath = os.path.join(BALLDIR, worldName + ".taz.bz2")
if os.path.isdir(worldPath): if os.path.isdir(worldPath):
if os.path.isfile(tarPath):
# Only remove the old one if there is a new one.
shutil.rmtree(worldPath) shutil.rmtree(worldPath)
if Flags["edgy"]: if Flags["edgy"]:
continue continue
tarPath = os.path.join(BALLDIR, worldName)
if os.path.isfile(tarPath): if os.path.isfile(tarPath):
tar = tarfile.open(tarPath) tar = tarfile.open(tarPath)
tar.extractall(path=WORLDS_PATH) tar.extractall(path=WORLDS_PATH)
@ -1106,7 +1108,7 @@ again.
print("WARNING: \"{}\" is missing.".format(tarPath)) print("WARNING: \"{}\" is missing.".format(tarPath))
# popd(); # popd();
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Strip the executable(s). # Strip the executable(s).
if not MAKEDEBUG: if not MAKEDEBUG:
@ -1124,7 +1126,7 @@ again.
print("strip (optimizing the executable size)" print("strip (optimizing the executable size)"
" failed for {}".format(sub_path)) " failed for {}".format(sub_path))
#--------------------------------------------------------------------- # ------------------------------------------------------------------
# Additional cleanup. # Additional cleanup.
if TIDYUP: if TIDYUP:
@ -1163,7 +1165,7 @@ again.
# .[a-z]\* # .[a-z]\*
os.remove(subPath) os.remove(subPath)
#--------------------------------------------------------------------- # --------------------------------------------------------------
# Finish required "--portable" operations. # Finish required "--portable" operations.
if PORTABLE: if PORTABLE:
@ -1196,7 +1198,7 @@ again.
os.chmod(progWrapPath, 0o755) os.chmod(progWrapPath, 0o755)
# popd() # popd()
#--------------------------------------------------------------------- # --------------------------------------------------------------
if MAKEPROD: if MAKEPROD:
# os.chdir(THISDIR) # or die "$IE #505833\n"; # os.chdir(THISDIR) # or die "$IE #505833\n";

Loading…
Cancel
Save