#!/usr/bin/env python

import os
import subprocess
import sys

# TODO: release/debug

root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform != "win32":
    cmd = ['make', '-C', root]
else:
    cmd = ['tools\win_build.bat']

print ' '.join(cmd)
sys.exit(subprocess.call(cmd, shell=True))

@@ -146,16 +146,70 @@
 le__)))%0A
+build_dir = os.path.join(root, 'out')%0A%0Adef build():%0A  
 if sys.p
@@ -236,41 +236,51 @@
     
+  
 cmd = 
-%5B
 'make
-', '-C', root%5D%0A
+ -C %25s' %25 build_dir%0A  
 else:%0A
+  
     
@@ -289,9 +289,8 @@
 d = 
-%5B
 'too
@@ -310,70 +310,600 @@
 bat'
-%5D
 %0A%0A
+  
 print 
-' '.join(cmd)%0Asys.exit(subprocess.call(cmd, shell=True))
+cmd%0A  sys.exit(subprocess.call(cmd, shell=True))%0A%0Adef test():%0A  agent = os.path.join(root, 'monitoring-agent')%0A  cmd = '%25s --zip monitoring-test.zip -e tests -c docs/sample.state' %25 agent%0A  print cmd%0A  rc = subprocess.call(cmd, shell=True)%0A  sys.exit(rc)%0A%0Acommands = %7B%0A  'build': build,%0A  'test': test,%0A%7D%0A%0Adef usage():%0A  print('Usage: build.py %5B%25s%5D' %25 ', '.join(commands.keys()))%0A  sys.exit(1)%0A%0Aif len(sys.argv) != 2:%0A  usage()%0A%0Ains = sys.argv%5B1%5D%0Aif not commands.has_key(ins):%0A  print('Invalid command: %25s' %25 ins)%0A  sys.exit(1)%0A%0Aprint('Running %25s' %25 ins)%0Acmd = commands.get(ins)%0Acmd()%0A
 %0A

upgrade build.py