Various improvements, most notably that --installer now supports creating FreeBSD packages. Also, default install path for installpanda.py is now /usr/local

This commit is contained in:
rdb 2010-05-30 19:11:29 +00:00
parent 1eb6bf3d42
commit d73fd17eac
3 changed files with 181 additions and 99 deletions

View File

@ -17,7 +17,7 @@ from distutils.sysconfig import get_python_lib
from optparse import OptionParser from optparse import OptionParser
from makepandacore import * from makepandacore import *
if (platform.architecture()[0] == "64bit"): if (platform.architecture()[0] == "64bit" and not sys.platform.startswith("freebsd")):
libdir = "/lib64" libdir = "/lib64"
else: else:
libdir = "/lib" libdir = "/lib"
@ -116,10 +116,17 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built"):
oscmd("mkdir -p "+destdir+prefix+"/share/applications") oscmd("mkdir -p "+destdir+prefix+"/share/applications")
oscmd("mkdir -p "+destdir+prefix+libdir+"/panda3d") oscmd("mkdir -p "+destdir+prefix+libdir+"/panda3d")
oscmd("mkdir -p "+destdir+PPATH) oscmd("mkdir -p "+destdir+PPATH)
if (sys.platform.startswith("freebsd")):
oscmd("mkdir -p "+destdir+prefix+"/etc")
else:
oscmd("mkdir -p "+destdir+"/etc/ld.so.conf.d") oscmd("mkdir -p "+destdir+"/etc/ld.so.conf.d")
WriteFile(destdir+prefix+"/share/panda3d/direct/__init__.py", "") WriteFile(destdir+prefix+"/share/panda3d/direct/__init__.py", "")
Configrc = ReadFile(outputdir+"/etc/Config.prc") Configrc = ReadFile(outputdir+"/etc/Config.prc")
Configrc = Configrc.replace("model-path $THIS_PRC_DIR/..", "model-path "+prefix+"/share/panda3d") Configrc = Configrc.replace("model-path $THIS_PRC_DIR/..", "model-path "+prefix+"/share/panda3d")
if (sys.platform.startswith("freebsd")):
WriteFile(destdir+prefix+"/etc/Config.prc", Configrc)
oscmd("cp "+outputdir+"/etc/Confauto.prc "+destdir+prefix+"/etc/Confauto.prc")
else:
WriteFile(destdir+"/etc/Config.prc", Configrc) WriteFile(destdir+"/etc/Config.prc", Configrc)
oscmd("cp "+outputdir+"/etc/Confauto.prc "+destdir+"/etc/Confauto.prc") oscmd("cp "+outputdir+"/etc/Confauto.prc "+destdir+"/etc/Confauto.prc")
oscmd("cp -R "+outputdir+"/include "+destdir+prefix+"/include/panda3d") oscmd("cp -R "+outputdir+"/include "+destdir+prefix+"/include/panda3d")
@ -138,24 +145,25 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built"):
oscmd("cp doc/LICENSE "+destdir+prefix+"/share/panda3d/LICENSE") oscmd("cp doc/LICENSE "+destdir+prefix+"/share/panda3d/LICENSE")
oscmd("cp doc/LICENSE "+destdir+prefix+"/include/panda3d/LICENSE") oscmd("cp doc/LICENSE "+destdir+prefix+"/include/panda3d/LICENSE")
oscmd("cp doc/ReleaseNotes "+destdir+prefix+"/share/panda3d/ReleaseNotes") oscmd("cp doc/ReleaseNotes "+destdir+prefix+"/share/panda3d/ReleaseNotes")
oscmd("echo '"+prefix+libdir+"/panda3d'> "+destdir+"/etc/ld.so.conf.d/panda3d.conf")
oscmd("echo '"+prefix+"/share/panda3d' > "+destdir+PPATH+"/panda3d.pth") oscmd("echo '"+prefix+"/share/panda3d' > "+destdir+PPATH+"/panda3d.pth")
oscmd("echo '"+prefix+libdir+"/panda3d'>> "+destdir+PPATH+"/panda3d.pth") oscmd("echo '"+prefix+libdir+"/panda3d'>> "+destdir+PPATH+"/panda3d.pth")
if (not sys.platform.startswith("freebsd")):
oscmd("echo '"+prefix+libdir+"/panda3d'> "+destdir+"/etc/ld.so.conf.d/panda3d.conf")
oscmd("chmod +x "+destdir+"/etc/ld.so.conf.d/panda3d.conf") oscmd("chmod +x "+destdir+"/etc/ld.so.conf.d/panda3d.conf")
oscmd("ln -s "+PEXEC+" "+destdir+prefix+"/bin/ppython") oscmd("ln -s "+PEXEC+" "+destdir+prefix+"/bin/ppython")
oscmd("cp "+outputdir+"/bin/* "+destdir+prefix+"/bin/") oscmd("cp "+outputdir+"/bin/* "+destdir+prefix+"/bin/")
for base in os.listdir(outputdir+"/lib"): for base in os.listdir(outputdir+"/lib"):
if (not base.endswith(".a")): if (not base.endswith(".a")):
oscmd("cp -d "+outputdir+"/lib/"+base+" "+destdir+prefix+libdir+"/panda3d/"+base) oscmd("cp -P "+outputdir+"/lib/"+base+" "+destdir+prefix+libdir+"/panda3d/"+base)
# rpmlint doesn't like it if we compile pyc. # rpmlint doesn't like it if we compile pyc.
#for base in os.listdir(destdir+prefix+"/share/panda3d/direct"): #for base in os.listdir(destdir+prefix+"/share/panda3d/direct"):
# if ((base != "extensions") and (base != "extensions_native")): # if ((base != "extensions") and (base != "extensions_native")):
# compileall.compile_dir(destdir+prefix+"/share/panda3d/direct/"+base) # compileall.compile_dir(destdir+prefix+"/share/panda3d/direct/"+base)
#compileall.compile_dir(destdir+prefix+"/share/panda3d/Pmw") #compileall.compile_dir(destdir+prefix+"/share/panda3d/Pmw")
DeleteCVS(destdir+prefix+"/include/panda3d") DeleteCVS(destdir)
DeleteCVS(destdir+prefix+"/share/panda3d") DeleteBuildFiles(destdir)
# rpmlint doesn't like these files, for some reason. DeleteEmptyDirs(destdir)
DeleteBuildFiles(destdir+prefix+"/share/panda3d") # rpmlint doesn't like this file, for some reason.
if (os.path.isfile(destdir+prefix+"/share/panda3d/direct/leveleditor/copyfiles.pl")): if (os.path.isfile(destdir+prefix+"/share/panda3d/direct/leveleditor/copyfiles.pl")):
os.remove(destdir+prefix+"/share/panda3d/direct/leveleditor/copyfiles.pl") os.remove(destdir+prefix+"/share/panda3d/direct/leveleditor/copyfiles.pl")
@ -182,8 +190,8 @@ def InstallRuntime(destdir="", prefix="/usr", outputdir="built"):
oscmd("cp "+outputdir+"/bin/panda3d "+destdir+prefix+"/bin/") oscmd("cp "+outputdir+"/bin/panda3d "+destdir+prefix+"/bin/")
if (__name__ == "__main__"): if (__name__ == "__main__"):
if (sys.platform != "linux2"): if (sys.platform.startswith("win") or sys.platform == "darwin"):
exit("This script only works on linux at the moment!") exit("This script is not supported on Windows or Mac OS X at the moment!")
destdir = "/" destdir = "/"
if (os.environ.has_key("DESTDIR")): if (os.environ.has_key("DESTDIR")):
@ -192,7 +200,7 @@ if (__name__ == "__main__"):
parser = OptionParser() parser = OptionParser()
parser.add_option('', '--outputdir', dest = 'outputdir', help = 'Makepanda\'s output directory (default: built)', default = 'built') parser.add_option('', '--outputdir', dest = 'outputdir', help = 'Makepanda\'s output directory (default: built)', default = 'built')
parser.add_option('', '--destdir', dest = 'destdir', help = 'Destination directory [default=%s]' % destdir, default = destdir) parser.add_option('', '--destdir', dest = 'destdir', help = 'Destination directory [default=%s]' % destdir, default = destdir)
parser.add_option('', '--prefix', dest = 'prefix', help = 'Prefix [default=/usr]', default = '/usr') parser.add_option('', '--prefix', dest = 'prefix', help = 'Prefix [default=/usr/local]', default = '/usr/local')
parser.add_option('', '--runtime', dest = 'runtime', help = 'Specify if runtime build [default=no]', action = 'store_true', default = False) parser.add_option('', '--runtime', dest = 'runtime', help = 'Specify if runtime build [default=no]', action = 'store_true', default = False)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()

View File

@ -4846,7 +4846,7 @@ Version: VERSION
Release: 1 Release: 1
License: BSD License License: BSD License
Group: Development/Libraries Group: Development/Libraries
BuildRoot: PANDASOURCE/linuxroot BuildRoot: PANDASOURCE/targetroot
%description %description
Panda3D is a game engine which includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Panda3D is open source and free software under the revised BSD license, and can be used for both free and commercial game development at no financial cost. Panda3D is a game engine which includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Panda3D is open source and free software under the revised BSD license, and can be used for both free and commercial game development at no financial cost.
Panda3D's intended game-development language is Python. The engine itself is written in C++, and utilizes an automatic wrapper-generator to expose the complete functionality of the engine in a Python interface. Panda3D's intended game-development language is Python. The engine itself is written in C++, and utilizes an automatic wrapper-generator to expose the complete functionality of the engine in a Python interface.
@ -4880,7 +4880,7 @@ Version: VERSION
Release: 1 Release: 1
License: BSD License License: BSD License
Group: Productivity/Graphics/Other Group: Productivity/Graphics/Other
BuildRoot: PANDASOURCE/linuxroot BuildRoot: PANDASOURCE/targetroot
%description %description
This package contains the runtime distribution and browser plugin of the Panda3D engine. It allows you view webpages that contain Panda3D content and to run games created with Panda3D that are packaged as .p3d file. This package contains the runtime distribution and browser plugin of the Panda3D engine. It allows you view webpages that contain Panda3D content and to run games created with Panda3D that are packaged as .p3d file.
%files %files
@ -4897,6 +4897,7 @@ This package contains the runtime distribution and browser plugin of the Panda3D
/usr/share/applications/*.desktop /usr/share/applications/*.desktop
""" """
# plist file for Mac OSX
Info_plist = """<?xml version="1.0" encoding="UTF-8"?> Info_plist = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
@ -4915,26 +4916,35 @@ Info_plist = """<?xml version="1.0" encoding="UTF-8"?>
</plist> </plist>
""" """
# FreeBSD pkg-descr
INSTALLER_PKG_DESCR_FILE = """
Panda3D is a game engine which includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Panda3D is open source and free software under the revised BSD license, and can be used for both free and commercial game development at no financial cost.
Panda3D's intended game-development language is Python. The engine itself is written in C++, and utilizes an automatic wrapper-generator to expose the complete functionality of the engine in a Python interface.
This package contains the SDK for development with Panda3D, install panda3d-runtime for the runtime files.
WWW: http://www.panda3d.org/
"""
def MakeInstallerLinux(): def MakeInstallerLinux():
import compileall
if RUNTIME: # No worries, it won't be used if RUNTIME: # No worries, it won't be used
PYTHONV = "python" PYTHONV = "python"
else: else:
PYTHONV = SDK["PYTHONVERSION"] PYTHONV = SDK["PYTHONVERSION"]
PV = PYTHONV.replace("python", "") PV = PYTHONV.replace("python", "")
if (os.path.isdir("linuxroot")): oscmd("chmod -R 755 linuxroot") if (os.path.isdir("targetroot")): oscmd("chmod -R 755 targetroot")
oscmd("rm -rf linuxroot data.tar.gz control.tar.gz panda3d.spec") oscmd("rm -rf targetroot data.tar.gz control.tar.gz panda3d.spec")
oscmd("mkdir linuxroot") oscmd("mkdir targetroot")
# Invoke installpanda.py to install it into a temporary dir # Invoke installpanda.py to install it into a temporary dir
if RUNTIME: if RUNTIME:
InstallRuntime(destdir = "linuxroot", outputdir = GetOutputDir()) InstallRuntime(destdir = "targetroot", outputdir = GetOutputDir())
else: else:
InstallPanda(destdir = "linuxroot", outputdir = GetOutputDir()) InstallPanda(destdir = "targetroot", outputdir = GetOutputDir())
oscmd("chmod -R 755 linuxroot/usr/share/panda3d") oscmd("chmod -R 755 targetroot/usr/share/panda3d")
if (os.path.exists("/usr/bin/rpmbuild") and not os.path.exists("/usr/bin/dpkg-deb")): if (os.path.exists("/usr/bin/rpmbuild") and not os.path.exists("/usr/bin/dpkg-deb")):
oscmd("rm -rf linuxroot/DEBIAN") oscmd("rm -rf targetroot/DEBIAN")
oscmd("rpm -E '%_target_cpu' > "+GetOutputDir()+"/tmp/architecture.txt") oscmd("rpm -E '%_target_cpu' > "+GetOutputDir()+"/tmp/architecture.txt")
ARCH = ReadFile(GetOutputDir()+"/tmp/architecture.txt").strip() ARCH = ReadFile(GetOutputDir()+"/tmp/architecture.txt").strip()
pandasource = os.path.abspath(os.getcwd()) pandasource = os.path.abspath(os.getcwd())
@ -4944,7 +4954,7 @@ def MakeInstallerLinux():
txt = INSTALLER_SPEC_FILE[1:] txt = INSTALLER_SPEC_FILE[1:]
txt = txt.replace("VERSION",VERSION).replace("PANDASOURCE",pandasource).replace("PYTHONV",PYTHONV).replace("PV",PV) txt = txt.replace("VERSION",VERSION).replace("PANDASOURCE",pandasource).replace("PYTHONV",PYTHONV).replace("PV",PV)
WriteFile("panda3d.spec", txt) WriteFile("panda3d.spec", txt)
oscmd("rpmbuild --define '_rpmdir "+pandasource+"' --root "+pandasource+" --buildroot linuxroot -bb panda3d.spec") oscmd("rpmbuild --define '_rpmdir "+pandasource+"' --root "+pandasource+" --buildroot targetroot -bb panda3d.spec")
if (RUNTIME): if (RUNTIME):
oscmd("mv "+ARCH+"/panda3d-runtime-"+VERSION+"-1."+ARCH+".rpm .") oscmd("mv "+ARCH+"/panda3d-runtime-"+VERSION+"-1."+ARCH+".rpm .")
else: else:
@ -4959,26 +4969,26 @@ def MakeInstallerLinux():
else: else:
txt = INSTALLER_DEB_FILE[1:] txt = INSTALLER_DEB_FILE[1:]
txt = txt.replace("VERSION",str(VERSION)).replace("PYTHONV",PYTHONV).replace("ARCH",ARCH).replace("PV",PV) txt = txt.replace("VERSION",str(VERSION)).replace("PYTHONV",PYTHONV).replace("ARCH",ARCH).replace("PV",PV)
oscmd("mkdir --mode=0755 -p linuxroot/DEBIAN") oscmd("mkdir --mode=0755 -p targetroot/DEBIAN")
oscmd("cd linuxroot ; (find usr -type f -exec md5sum {} \;) > DEBIAN/md5sums") oscmd("cd targetroot ; (find usr -type f -exec md5sum {} \;) > DEBIAN/md5sums")
if (not RUNTIME): if (not RUNTIME):
oscmd("cd linuxroot ; (find etc -type f -exec md5sum {} \;) >> DEBIAN/md5sums") oscmd("cd targetroot ; (find etc -type f -exec md5sum {} \;) >> DEBIAN/md5sums")
WriteFile("linuxroot/DEBIAN/conffiles","/etc/Config.prc\n") WriteFile("targetroot/DEBIAN/conffiles","/etc/Config.prc\n")
WriteFile("linuxroot/DEBIAN/control",txt) WriteFile("targetroot/DEBIAN/control",txt)
WriteFile("linuxroot/DEBIAN/postinst","#!/bin/sh\necho running ldconfig\nldconfig\n") WriteFile("targetroot/DEBIAN/postinst","#!/bin/sh\necho running ldconfig\nldconfig\n")
oscmd("cp linuxroot/DEBIAN/postinst linuxroot/DEBIAN/postrm") oscmd("cp targetroot/DEBIAN/postinst targetroot/DEBIAN/postrm")
oscmd("chmod -R 755 linuxroot/DEBIAN") oscmd("chmod -R 755 targetroot/DEBIAN")
if (RUNTIME): if (RUNTIME):
oscmd("dpkg-deb -b linuxroot panda3d-runtime_"+VERSION+"_"+ARCH+".deb") oscmd("dpkg-deb -b targetroot panda3d-runtime_"+VERSION+"_"+ARCH+".deb")
else: else:
oscmd("dpkg-deb -b linuxroot panda3d_"+VERSION+"_"+ARCH+".deb") oscmd("dpkg-deb -b targetroot panda3d_"+VERSION+"_"+ARCH+".deb")
oscmd("chmod -R 755 linuxroot") oscmd("chmod -R 755 targetroot")
if not (os.path.exists("/usr/bin/rpmbuild") or os.path.exists("/usr/bin/dpkg-deb")): if not (os.path.exists("/usr/bin/rpmbuild") or os.path.exists("/usr/bin/dpkg-deb")):
exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!") exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!")
# oscmd("chmod -R 755 linuxroot") # oscmd("chmod -R 755 targetroot")
# oscmd("rm -rf linuxroot data.tar.gz control.tar.gz panda3d.spec "+ARCH) # oscmd("rm -rf targetroot data.tar.gz control.tar.gz panda3d.spec "+ARCH)
def MakeInstallerOSX(): def MakeInstallerOSX():
if (RUNTIME): if (RUNTIME):
@ -5007,8 +5017,7 @@ def MakeInstallerOSX():
for base in os.listdir(GetOutputDir()+"/lib"): for base in os.listdir(GetOutputDir()+"/lib"):
if (not base.endswith(".a")): if (not base.endswith(".a")):
libname = "dstroot/base/Developer/Panda3D/lib/" + base libname = "dstroot/base/Developer/Panda3D/lib/" + base
# OSX needs the -R argument to copy symbolic links correctly, it doesn't have -d. How weird. oscmd("cp -P " + GetOutputDir() + "/lib/" + base + " " + libname)
oscmd("cp -R " + GetOutputDir() + "/lib/" + base + " " + libname)
# Execute install_name_tool to make them reference an absolute path # Execute install_name_tool to make them reference an absolute path
if (libname.endswith(".dylib") and not os.path.islink(libname)): if (libname.endswith(".dylib") and not os.path.islink(libname)):
@ -5213,6 +5222,52 @@ function have16installed() {
oscmd('hdiutil convert Panda3D-rw.dmg -format UDBZ -o Panda3D-%s.dmg' % VERSION) oscmd('hdiutil convert Panda3D-rw.dmg -format UDBZ -o Panda3D-%s.dmg' % VERSION)
oscmd('rm -f Panda3D-rw.dmg') oscmd('rm -f Panda3D-rw.dmg')
def MakeInstallerFreeBSD():
import compileall
oscmd("rm -rf targetroot pkg-descr pkg-plist")
oscmd("mkdir targetroot")
# Invoke installpanda.py to install it into a temporary dir
if RUNTIME:
InstallRuntime(destdir = "targetroot", prefix = "/usr/local", outputdir = GetOutputDir())
else:
InstallPanda(destdir = "targetroot", prefix = "/usr/local", outputdir = GetOutputDir())
if (not os.path.exists("/usr/sbin/pkg_create")):
exit("Cannot create an installer without pkg_create")
if (RUNTIME):
descr_txt = RUNTIME_INSTALLER_PKG_DESCR_FILE[1:]
else:
descr_txt = INSTALLER_PKG_DESCR_FILE[1:]
descr_txt = descr_txt.replace("VERSION", VERSION)
plist_txt = "@name panda3d-%s\n" % VERSION
for root, dirs, files in os.walk("targetroot/usr/local/", True):
for f in files:
plist_txt += os.path.join(root, f)[21:] + "\n"
for remdir in ("lib/panda3d", "share/panda3d", "include/panda3d"):
for root, dirs, files in os.walk("targetroot/usr/local/" + remdir, False):
for d in dirs:
plist_txt += "@dirrm %s\n" % os.path.join(root, d)[21:]
plist_txt += "@dirrm %s\n" % remdir
WriteFile("pkg-plist", plist_txt)
WriteFile("pkg-descr", descr_txt)
cmd = "pkg_create"
if GetVerbose():
cmd += " --verbose"
if PkgSkip("PYTHON")==0:
# If this version of Python was installed from a package, let's mark it as dependency.
oscmd("rm -f %s/tmp/python-pkg.txt" % GetOutputDir())
oscmd("pkg_info -E 'python%s>=%s' > %s/tmp/python-pkg.txt" % (SDK["PYTHONVERSION"][6:9:2], SDK["PYTHONVERSION"][6:9], GetOutputDir()), True)
if (os.path.isfile(GetOutputDir() + "/tmp/python-pkg.txt")):
python_pkg = ReadFile(GetOutputDir() + "/tmp/python-pkg.txt").strip()
if (python_pkg):
cmd += " -P " + python_pkg
cmd += " -p /usr/local -S \"%s\"" % os.path.abspath("targetroot")
cmd += " -c -\"The Panda3D free 3D engine SDK\""
cmd += " -d pkg-descr -f pkg-plist panda3d-%s" % VERSION
oscmd(cmd)
if (INSTALLER != 0): if (INSTALLER != 0):
ProgressOutput(100.0, "Building installer") ProgressOutput(100.0, "Building installer")
if (sys.platform.startswith("win")): if (sys.platform.startswith("win")):
@ -5232,6 +5287,8 @@ if (INSTALLER != 0):
MakeInstallerLinux() MakeInstallerLinux()
elif (sys.platform == "darwin"): elif (sys.platform == "darwin"):
MakeInstallerOSX() MakeInstallerOSX()
elif (sys.platform.startswith("freebsd")):
MakeInstallerFreeBSD()
else: else:
exit("Do not know how to make an installer for this platform") exit("Do not know how to make an installer for this platform")

View File

@ -232,6 +232,7 @@ def oscmd(cmd, ignoreError = False):
print GetColor("red") + "Interrogate failed, retrieving debug output..." + GetColor() print GetColor("red") + "Interrogate failed, retrieving debug output..." + GetColor()
os.system(cmd.split(" ", 1)[0] + " -v " + cmd.split(" ", 1)[1]) os.system(cmd.split(" ", 1)[0] + " -v " + cmd.split(" ", 1)[1])
exit("") exit("")
return res
######################################################################## ########################################################################
## ##
@ -681,10 +682,9 @@ def ConditionalWriteFile(dest,desiredcontents):
def DeleteCVS(dir): def DeleteCVS(dir):
if dir == "": dir = "." if dir == "": dir = "."
for entry in os.listdir(dir): for entry in os.listdir(dir):
if (entry != ".") and (entry != ".."): subdir = os.path.join(dir, entry)
subdir = dir + "/" + entry
if (os.path.isdir(subdir)): if (os.path.isdir(subdir)):
if (entry == "CVS"): if (entry == "CVS" or entry == "CVSROOT"):
shutil.rmtree(subdir) shutil.rmtree(subdir)
else: else:
DeleteCVS(subdir) DeleteCVS(subdir)
@ -692,14 +692,31 @@ def DeleteCVS(dir):
os.remove(subdir) os.remove(subdir)
def DeleteBuildFiles(dir): def DeleteBuildFiles(dir):
if dir == "": dir = "."
for entry in os.listdir(dir): for entry in os.listdir(dir):
if (entry != ".") and (entry != ".."): subdir = os.path.join(dir, entry)
subdir = dir + "/" + entry
if (os.path.isfile(subdir) and os.path.splitext(subdir)[-1] in SUFFIX_INC+[".pp", ".moved"]): if (os.path.isfile(subdir) and os.path.splitext(subdir)[-1] in SUFFIX_INC+[".pp", ".moved"]):
os.remove(subdir) os.remove(subdir)
elif (os.path.isdir(subdir)): elif (os.path.isdir(subdir)):
if (os.path.basename(subdir)[:3] == "Opt" and os.path.basename(subdir)[4] == "-"):
shutil.rmtree(subdir)
else:
DeleteBuildFiles(subdir) DeleteBuildFiles(subdir)
def DeleteEmptyDirs(dir):
if dir == "": dir = "."
entries = os.listdir(dir)
if not entries:
os.rmdir(dir)
return
for entry in entries:
subdir = os.path.join(dir, entry)
if (os.path.isdir(subdir)):
if (not os.listdir(subdir)):
os.rmdir(subdir)
else:
DeleteEmptyDirs(subdir)
def CreateFile(file): def CreateFile(file):
if (os.path.exists(file)==0): if (os.path.exists(file)==0):
WriteFile(file,"") WriteFile(file,"")