forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselfdestruct.py
More file actions
executable file
·47 lines (41 loc) · 1.75 KB
/
selfdestruct.py
File metadata and controls
executable file
·47 lines (41 loc) · 1.75 KB
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
#!/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:
# Remove non-CMakeLists.txt files from */metalibs/*/
for path, dirs, files in os.walk(os.path.join(root, project, 'metalibs')):
for filename in files:
if filename.lower() != 'cmakelists.txt':
os.unlink(os.path.join(path, filename))
# Unlink the directory itself, if empty
if not os.listdir(path):
os.rmdir(path)
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|h|mm)', filename):
os.unlink(os.path.join(path, filename))