Menu

[r1]: / scripts / build.py  Maximize  Restore  History

Download this file

125 lines (99 with data), 3.0 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
 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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
""" build.py - Build script to create the web site from source.
This creates a directory 'build' under the source tree and populates
it with stuff.
"""
from path import path
import zipfile
HERE = path(__file__).parent
SRCDIR = HERE.parent
TGTDIR = SRCDIR / 'build'
VERSION = '0.1'
def buildAll():
webFiles = [
'index.html',
'about.html',
'style/tryscheme.css',
'style/docs.css',
'tests/tests.xml',
'js/scm/psyntaxpp.js']
copies(webFiles)
jsFiles = [
'js/scm/errors.js',
'js/scm/booleans.js',
'js/scm/numbers.js',
'js/scm/objects.js',
'js/scm/io.js',
'js/scm/procedures.js',
'js/scm/parse.js',
'js/scm/eval.js',
'js/scm/vm.js',
'js/scm/lib.js',
'js/scm/compile.js',
'js/scm/psyntax.js',
'js/ui/console.js',
'js/ui/util.js',
'js/ui/test.js'
]
concat(jsFiles, 'js/tryscheme.js')
devFiles = [
'scripts/build.py',
'scripts/testc.cmd',
'scripts/test-to-xml.py'
]
zipTarget = 'tryscheme-%s.zip' % VERSION
mkzip(webFiles + jsFiles + devFiles, zipTarget)
# --- path nonsense
def findSource(f):
f_segments = f.split('/')
return SRCDIR.joinpath(*f_segments)
def findTarget(f):
f_segments = f.split('/')
return TGTDIR.joinpath(*f_segments)
def joinDirs(realDir, pseudoRelPath):
segments = pseudoRelPath.split('/')
return realDir.joinpath(*segments)
# --- actions
def mkdir(d):
if not d.isdir():
d.makedirs()
def copies(files):
for f in files:
srcf = findSource(f)
tgtf = findTarget(f)
mkdir(tgtf.parent)
print "Copying %s to %s..." % (srcf, tgtf),
srcf.copyfile(tgtf)
print "done."
def concat(srcfiles, target):
tgtf = findTarget(target)
print "Creating %s..." % tgtf
mkdir(tgtf.parent)
outf = open(tgtf, 'wb')
for f in srcfiles:
srcf = findSource(f)
print "Adding %s..." % srcf
outf.write(srcf.bytes())
print "done."
def mkzip(srcFiles, target):
tgtf = findTarget(target)
print "Creating %s..." % tgtf
mkdir(tgtf.parent)
z = zipfile.ZipFile(tgtf, 'w', zipfile.ZIP_DEFLATED)
for f in srcFiles:
srcf = findSource(f)
print "Adding %s..." % srcf
z.write(srcf, 'tryscheme-%s/%s' % (VERSION, f))
z.close()
print "done."
def main():
global TGTDIR
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-o", "--output-dir", dest="outputDir",
help="put resulting web pages, etc. in DIR", metavar="DIR")
(options, args) = parser.parse_args()
assert len(args) == 0
if options.outputDir is not None:
TGTDIR = path(options.outputDir)
buildAll()
main()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.