Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 73336ae

Browse files
committed
Write new python packaging script
1 parent 83744b3 commit 73336ae

File tree

3 files changed

+120
-4
lines changed

3 files changed

+120
-4
lines changed

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ifndef SPINC
33
endif
44

55
LFLAGS := -L library/
6-
FOLDERS := .
6+
FOLDERS := library/
77

88
OBJECTS := $(shell find $(FOLDERS) -name \*.spin )
99
BINARIES := $(OBJECTS:.spin=.binary)

scripts/release.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/env python
2+
3+
import os, sys, shutil
4+
import errno
5+
import subprocess
6+
import zipfile
7+
8+
9+
def zipdir(path, ziph):
10+
for root, dirs, files in os.walk(path):
11+
for file in files:
12+
ziph.write(os.path.join(root, file))
13+
14+
def mkdir(path):
15+
try:
16+
os.makedirs(path)
17+
except OSError as exc: # Python >2.5
18+
if exc.errno == errno.EEXIST and os.path.isdir(path):
19+
pass
20+
else:
21+
raise
22+
23+
version = 'master'
24+
25+
if len(sys.argv) > 1:
26+
version = sys.argv[1]
27+
28+
release = "lamestation-sdk-"+version
29+
archive = release+".zip"
30+
builddir = ".build"
31+
32+
print release
33+
34+
try:
35+
shutil.rmtree(builddir)
36+
except:
37+
pass
38+
shutil.copytree("library",builddir)
39+
40+
def command(cmd):
41+
try:
42+
out = subprocess.check_output(cmd)
43+
except subprocess.CalledProcessError as e:
44+
print "Error: Command failed"
45+
sys.exit(1)
46+
return out
47+
48+
49+
out = command(["git","ls-tree","-r",version,"--name-only"])
50+
51+
for line in out.splitlines():
52+
53+
if not line.endswith(".spin"): continue
54+
55+
filebase = os.path.basename(line)
56+
57+
if filebase.startswith('gfx'): continue
58+
if filebase.startswith('map'): continue
59+
if filebase.startswith('snd'): continue
60+
if filebase.startswith('ins'): continue
61+
if filebase.startswith('song'): continue
62+
if filebase.startswith('wav'): continue
63+
64+
filecomps = line.split(os.sep)
65+
filecomps.pop(0)
66+
filename = os.sep.join(filecomps)
67+
newfilename = os.path.join(builddir, filename)
68+
69+
print line
70+
logs = command(["git","log", "--format=%aD","--follow", line]).splitlines()
71+
today = logs[0].split()[3]
72+
created = logs[-1].split()[3]
73+
74+
age = created + "-" + today
75+
if created == today:
76+
age = today
77+
78+
f = open(line, 'r').read()
79+
80+
output = ""
81+
output += "' "+80*'-'+"\n"
82+
output += "' "+filename+"\n"
83+
output += "' Version: "+version+"\n"
84+
output += "' Copyright (c) "+age+" LameStation LLC\n"
85+
output += "' See end of file for terms of use.\n"
86+
output += "' "+80*'-'+"\n"
87+
88+
output += f
89+
90+
output += "\n\nDAT\n"
91+
output += open(os.path.join('scripts','license.stub'),'r').read()
92+
output += "DAT\n"
93+
94+
f = open(newfilename, 'w')
95+
f.write(output)
96+
f.close()
97+
98+
try:
99+
shutil.rmtree(release)
100+
except OSError:
101+
pass
102+
shutil.move(builddir, release)
103+
104+
try:
105+
os.remove(archive)
106+
except:
107+
pass
108+
109+
print "Building zip:",archive
110+
zipf = zipfile.ZipFile(archive, 'w', zipfile.ZIP_DEFLATED)
111+
zipdir(release, zipf)
112+
zipf.close()
113+
114+
shutil.move(release, builddir)

scripts/release.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BUILDDIR=.build
99
rm -rf ./$BUILDDIR/
1010
mkdir -p $BUILDDIR/
1111

12-
cp demos/ games/ tutorials/ library/* -r $BUILDDIR/
12+
cp library/demos/ library/games/ library/tutorials/ library/*.spin -r $BUILDDIR/
1313

1414
if [ -z $1 ] ; then
1515
echo "No version given... pass as parameter"
@@ -19,6 +19,7 @@ echo -n "Packaging SDK"
1919
while read LINE
2020
do
2121
if [[ ! -f $BUILDDIR/$LINE ]] ; then
22+
echo "Failed to find file $BUILDDIR/$LINE"
2223
continue
2324
fi
2425

@@ -42,6 +43,7 @@ do
4243

4344
if [[ ! "$F" =~ ^gfx_.*|^map_.*|^ins_.*|^song_.* ]]; then
4445

46+
echo "SOODO"
4547
cat > $BUILDDIR/$LINE << EOF
4648
' ${LINE}
4749
' -------------------------------------------------
@@ -69,7 +71,7 @@ EOF
6971

7072
done < <(git ls-tree -r ${VERSION} --name-only | grep .spin$)
7173

72-
cp media/ -r $BUILDDIR/
74+
cp library/media/ -r $BUILDDIR/
7375

7476
rm -f `find $BUILDDIR/ -name .\* -type f`
7577

@@ -78,6 +80,6 @@ echo "DONE"
7880
mv ${BUILDDIR} ${RELEASENAME}
7981

8082
rm -f ${RELEASENAME}.zip
81-
zip -r ${RELEASENAME}.zip ${RELEASENAME}/
83+
#zip -r ${RELEASENAME}.zip ${RELEASENAME}/
8284

8385
mv ${RELEASENAME} ${BUILDDIR}

0 commit comments

Comments
 (0)