summaryrefslogtreecommitdiff
path: root/Chalice/make
blob: 643832ef95c8c22a550cfc88493b9aef9c5e8b47 (plain)
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
#! /bin/python

import os
import glob
import sys
import datetime

bindir = "bin"
if not os.path.exists(bindir):
    os.makedirs(bindir)
    
srcspecs = ["src/*.scala"]
srcfiles = [file for spec in srcspecs for file in glob.glob(spec)]

buildstamp = "makestamp"

lastbuild = None
if os.path.exists(buildstamp):
    lastbuild = os.path.getmtime(buildstamp)

changedfiles = [file for file in srcfiles if not lastbuild or lastbuild <= os.path.getmtime(file)]

if not changedfiles:
    print "Build is up-to-date."
    sys.exit(0)

def printtime():
    print datetime.datetime.now().strftime("%H:%M:%S")

printtime()
cmd = "scalac -d bin -unchecked -deprecation " + " ".join(changedfiles) + " 2>&1"
print cmd
result = os.system(cmd)
printtime()

if result == 0:
    open(buildstamp, "w").close()
else:
    print "Build failed."