Got the HanldeFunc() working, but not the file server.
[armadillo.git] / build.py
1 #!/usr/bin/env python2.5
2 import os
3 import shutil
4 import subprocess
5 import sys
6
7 ROOT = os.path.dirname(os.path.realpath(__file__))
8 SRC_PATH = os.path.join(ROOT, 'src')
9 PROD_PATH = os.path.join(ROOT, 'out')
10 FE_PATH = os.path.join(ROOT, 'web_frontend')
11
12 SOURCES = [
13 'server.go',
14 'main.go'
15 ]
16 PRODUCT_NAME = 'armadillo'
17
18 COMPILER = '8g'
19 LINKER = '8l'
20 O_EXTENSION = '8'
21
22 def _ObjFileName(gofile):
23 gofile = os.path.basename(gofile)
24 return os.path.join(PROD_PATH, os.path.splitext(gofile)[0] + '.' + O_EXTENSION)
25
26 def Main():
27 print '=== Starting Build ==='
28 os.chdir(PROD_PATH)
29
30 # Compile.
31 for gofile in SOURCES:
32 gofile = os.path.join(SRC_PATH, gofile)
33 args = [ COMPILER, gofile ]
34 print ' ' + ' '.join(args)
35 handle = subprocess.Popen(args, stdout = sys.stdout, stderr = sys.stderr)
36 handle.wait()
37
38 # Link
39 objects = map(_ObjFileName, SOURCES)
40 args = [ LINKER, '-o', os.path.join(PROD_PATH, PRODUCT_NAME), 'main.8' ]
41 print ' ' + ' ' .join(args)
42 handle = subprocess.Popen(args, stdout = sys.stdout, stderr = sys.stderr)
43 handle.wait()
44
45 # Copy
46 fe_resources = os.path.join(PROD_PATH, 'fe')
47 handle = subprocess.Popen([ 'rm', '-rf', fe_resources ])
48 handle.wait()
49 shutil.copytree(FE_PATH, fe_resources)
50
51
52 if __name__ == '__main__':
53 Main()