-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake.py
92 lines (70 loc) · 2.65 KB
/
make.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
# This file is part of the Kitfox Normal Brush distribution (https://github.com/blackears/blenderEasyFly).
# Copyright (c) 2021 Mark McKay
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import sys
import getopt
import platform
def copytree(src, dst):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
os.mkdir(d)
copytree(s, d)
else:
filename, extn = os.path.splitext(item)
print ("file " + filename + " extn " + extn)
if (extn != ".py" and extn != ".png"):
continue
shutil.copy(s, d)
def make(copyToBlenderAddons = False, createArchive = False):
projectName = 'normalBrush'
version = '_1_2_0_for_blender_4'
blenderHome = None
blenderHome = os.getenv('BLENDER_HOME')
#Create build directory
curPath = os.getcwd()
if os.path.exists('build'):
shutil.rmtree('build')
os.mkdir('build')
os.mkdir('build/' + projectName)
copytree("source", "build/" + projectName);
#Build addon zip file
if createArchive:
if os.path.exists('deploy'):
shutil.rmtree('deploy')
os.mkdir('deploy')
shutil.make_archive("deploy/" + projectName + version, "zip", "build")
if copyToBlenderAddons:
if blenderHome == None:
print("Error: BLENDER_HOME not set. Files not copied to <BLENDER_HOME>/script/addons.")
return
addonPath = os.path.join(blenderHome, "scripts/addons")
destPath = os.path.join(addonPath, projectName)
print("Copying to blender addons: " + addonPath)
if os.path.exists(destPath):
shutil.rmtree(destPath)
copytree("build", addonPath);
if __name__ == '__main__':
copyToBlenderAddons = False
createArchive = False
for arg in sys.argv[1:]:
if arg == "-a":
createArchive = True
if arg == "-b":
copyToBlenderAddons = True
make(copyToBlenderAddons, createArchive)