makepanda: Add a "self-destruct" script for removing makepanda specifics

This commit is contained in:
Sam Edwards 2016-12-26 14:11:23 -07:00
parent b326c6e12d
commit e730b8be56

38
makepanda/selfdestruct.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python2
import os
import re
import sys
import shutil
# Ensure user WANTS th
if len(sys.argv) < 2 or sys.argv[1] != '--yes':
print('======== MAKEPANDA SELF-DESTRUCT ========')
print('This script will destroy every trace of')
print('makepanda from the Panda3D directory that')
print('contains it. This is for testing CMake\'s')
print('dependencies and fully removing makepanda')
print('should the latter buildsystem no longer')
print('be desired.')
print('')
print('If you are sure, pass --yes')
sys.exit(1)
# Some sanity-checks to make sure this script is in the right location:
scriptdir = os.path.abspath(os.path.dirname(__file__))
assert os.path.split(scriptdir)[1] == 'makepanda'
root = os.path.dirname(scriptdir)
assert os.path.isfile(os.path.join(root, 'LICENSE'))
assert os.path.isdir(os.path.join(root, 'pandatool'))
# Now we get to work! First, the makepanda directory isn't needed:
shutil.rmtree(os.path.join(root, 'makepanda'))
# Then we look under each of the separate project trees:
projects = ['contrib', 'direct', 'dtool', 'panda', 'pandatool']
for project in projects:
for path, dirs, files in os.walk(os.path.join(root, project)):
# Get rid of _composite#.cxx files
for filename in files:
if re.match(r'.*_composite[0-9]+\.cxx', filename):
os.unlink(os.path.join(path, filename))