unbroke the crio build by converting it to build.py
diff --git a/aos/build/aos.gypi b/aos/build/aos.gypi
index c6fc79d..2ab2155 100644
--- a/aos/build/aos.gypi
+++ b/aos/build/aos.gypi
@@ -17,7 +17,7 @@
     'test_dir': '<(PRODUCT_DIR)/tests',
   },
   'conditions': [
-    ['OS=="crio"', {
+    ['PLATFORM=="crio"', {
         'make_global_settings': [
           ['CC', '<!(readlink -f <(AOS)/build/crio_cc)'],
           ['CXX', '<!(readlink -f <(AOS)/build/crio_cxx)'],
@@ -82,7 +82,7 @@
       # Set this to 1 to disable rsyncing the file to the target.
       'no_rsync%': 0,
       # Set this to 1 if this file is a test that should not be run by
-      # `build.sh tests`.
+      # `build.py tests`.
       'is_special_test%': 0,
     },
     'conditions': [
@@ -92,37 +92,35 @@
           ],
         }, {
           'cflags': [
+            # TODO(brians): -O4 for clang to enable LTO?
             '-O3',
             '-fomit-frame-pointer',
           ],
           'ldflags': [
             '-O3',
           ],
-          'conditions': [['OS=="crio"', {
+          'conditions': [['PLATFORM=="crio"', {
               'cflags': [
                 '-fstrength-reduce',
                 '-fno-builtin',
                 '-fno-strict-aliasing',
               ],
             }],
-            ['PLATFORM=="linux"', {
+            ['ARCHITECTURE=="arm"', {
               'cflags': [
                 '-mcpu=cortex-a8',
                 '-mfpu=neon',
               ],
             }],
-            ['PLATFORM=="linux-amd64"', {
+            ['ARCHITECTURE=="amd64"', {
               'cflags': [
-                '-march=atom',
-                '-mfpmath=sse',
-
                 '-fstack-protector-all',
               ],
             }],
           ]
         }
       ],
-      ['OS=="crio"', {
+      ['PLATFORM=="crio"', {
           'target_conditions': [
             ['_type=="shared_library"', {
                 'ldflags': [
diff --git a/aos/build/build.py b/aos/build/build.py
index 8b7790f..b1e02e3 100755
--- a/aos/build/build.py
+++ b/aos/build/build.py
@@ -15,10 +15,39 @@
     def __init__(self, message):
       self.message = message
 
+  class Platform(object):
+    def outdir(self):
+      return os.path.join(
+          Processor.aos_path(), '..', 'output', self.outname())
+    def build_ninja(self):
+      return os.path.join(self.outdir(), 'build.ninja')
+
   def aos_path():
     return os.path.join(os.path.dirname(__file__), '..')
 
 class CRIOProcessor(Processor):
+  class Platform(Processor.Platform):
+    def __init__(self, debug):
+      super(CRIOProcessor.Platform, self).__init__()
+
+      self.debug = debug
+
+    def __repr__(self):
+      return 'CRIOProcessor.Platform(debug=%s)' % self.debug
+    def __str__(self):
+      return 'crio%s' % ('-debug' if self.debug else '')
+
+    def outname(self):
+      return 'crio-debug' if self.debug else 'crio'
+    def os(self):
+      return 'vxworks'
+    def gyp_platform(self):
+      return 'crio'
+    def architecture(self):
+      return 'ppc'
+    def compiler(self):
+      return 'gcc'
+
   def __init__(self):
     super(CRIOProcessor, self).__init__()
 
@@ -28,17 +57,25 @@
       self.wind_base = '/usr/local/powerpc-wrs-vxworks/wind_base'
 
   def parse_platforms(self, string):
-    if string is not None and string != 'crio':
-      raise Processor.UnknownPlatform('Unknown cRIO platform "%s"!' % string, file=sys.stderr)
-    return CRIOPlatform()
+    if string is None or string == 'crio':
+      return (CRIOProcessor.Platform(False),)
+    elif string == 'crio-debug':
+      return (CRIOProcessor.Platform(True),)
+    else:
+      raise Processor.UnknownPlatform('Unknown cRIO platform "%s".' % string)
 
   def build_env(self):
     return {'WIND_BASE': self.wind_base}
+  def extra_gyp_flags(self):
+    return ('-DWIND_BASE=%s' % self.wind_base,)
+
   def is_crio(self): return True
 
 class PrimeProcessor(Processor):
-  class Platform(object):
+  class Platform(Processor.Platform):
     def __init__(self, architecture, compiler, debug):
+      super(PrimeProcessor.Platform, self).__init__()
+
       self.architecture = architecture
       self.compiler = compiler
       self.debug = debug
@@ -55,13 +92,8 @@
     def gyp_platform(self):
       return '%s-%s-%s' % (self.os(), self.architecture, self.compiler)
 
-    def outdir(self):
-      return os.path.join(
-          Processor.aos_path(), '..', 'output', self.outname())
     def outname(self):
       return str(self)
-    def build_ninja(self):
-      return os.path.join(self.outdir(), 'build.ninja')
 
   ARCHITECTURES = ['arm', 'amd64']
   COMPILERS = ['clang', 'gcc']
@@ -80,6 +112,8 @@
 
   def build_env(self):
     return {}
+  def extra_gyp_flags(self):
+    return ()
   def is_crio(self): return False
 
   def parse_platforms(self, string):
@@ -279,8 +313,8 @@
              '-DPLATFORM=%s' % platform.gyp_platform(),
              '-DARCHITECTURE=%s' % platform.architecture,
              '-DCOMPILER=%s' % platform.compiler,
-             '-DDEBUG=%s' % ('yes' if platform.debug else 'no'),
-             args.main_gyp),
+             '-DDEBUG=%s' % ('yes' if platform.debug else 'no')) +
+            processor.extra_gyp_flags() + (args.main_gyp,),
             stdin=subprocess.PIPE)
         gyp.communicate(("""
 {
@@ -293,15 +327,24 @@
         if gyp.returncode:
           print("Running gyp failed!", file=sys.stderr)
           exit(1)
+        if processor.is_crio():
+          subprocess.check_call(
+              ('sed', '-i',
+               's/nm -gD/nm/g', platform.build_ninja()),
+              stdin=open('/dev/null', 'r'))
         print('Done running gyp.', file=sys.stderr)
       else:
         print("Not running gyp.", file=sys.stderr)
 
       try:
+        build_env = dict(processor.build_env())
+        build_env['TERM'] = os.environ['TERM']
+        build_env['PATH'] = os.environ['PATH']
         subprocess.check_call(
             (tools_config['NINJA'],
              '-C', platform.outdir()) + tuple(targets),
-            stdin=open('/dev/null', 'r'))
+            stdin=open('/dev/null', 'r'),
+            env=build_env)
       except subprocess.CalledProcessError as e:
         if unknown_platform_error is not None:
           print(unknown_platform_error, file=sys.stderr)
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index bf8df38..3291088 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+#set -x
 set -e
 
 AOS=$(readlink -f $(dirname $0)/..)
@@ -36,7 +37,7 @@
 
 TMPDIR=/tmp/$$-aos-tmpdir
 mkdir -p ${EXTERNALS}
-mkdir -p ${COMPILED}
+[[ -n "${COMPILED}" ]] && mkdir -p ${COMPILED}
 
 # get and build ninja
 [ -d ${NINJA_DIR} ] || git clone --branch ${NINJA_RELEASE} https://github.com/martine/ninja.git ${NINJA_DIR}
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index 8e4e637..2b82e38 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -131,7 +131,7 @@
       'export_dependent_settings': [
         'gtest_prod',
       ],
-      'conditions': [['OS=="crio"', {
+      'conditions': [['PLATFORM=="crio"', {
             'defines': [
               'GTEST_HAS_TR1_TUPLE=0',
               'GTEST_HAS_STREAM_REDIRECTION=0',
diff --git a/aos/common/common.gyp b/aos/common/common.gyp
index fab82a2..d53b75f 100644
--- a/aos/common/common.gyp
+++ b/aos/common/common.gyp
@@ -117,7 +117,7 @@
         'queue.cc',
       ],
       'conditions': [
-        ['OS=="crio"', {
+        ['PLATFORM=="crio"', {
           'dependencies': [
             '<(EXTERNALS):WPILib',
           ],
@@ -247,7 +247,7 @@
       'target_name': 'mutex',
       'type': 'static_library',
       'conditions': [
-        ['OS=="crio"', {
+        ['PLATFORM=="crio"', {
           'sources': [
             '<(AOS)/crio/shared_libs/mutex.cpp',
           ],
diff --git a/aos/common/util/inet_addr.cc b/aos/common/util/inet_addr.cc
index f202f6e..48bde1d 100644
--- a/aos/common/util/inet_addr.cc
+++ b/aos/common/util/inet_addr.cc
@@ -3,9 +3,17 @@
 #include <stdlib.h>
 #ifndef __VXWORKS__
 #include <string.h>
-#endif
 
 #include "aos/common/byteorder.h"
+#else
+
+template<typename T>
+T hton(T);
+
+template<uint32_t>
+uint32_t hton(uint32_t v) { return v; }
+
+#endif
 
 namespace aos {
 namespace util {
diff --git a/frc971/crio/build.sh b/frc971/crio/build.sh
index 7b4f559..9635a1a 100755
--- a/frc971/crio/build.sh
+++ b/frc971/crio/build.sh
@@ -2,4 +2,4 @@
 
 cd $(dirname $0)
 
-../../aos/build/build.sh crio crio.gyp no crio "$@"
+../../aos/build/build.py --processor crio --main_gyp crio.gyp "$@"
diff --git a/output/.gitignore b/output/.gitignore
index f0ed9a5..776368b 100644
--- a/output/.gitignore
+++ b/output/.gitignore
@@ -7,3 +7,9 @@
 /arm-clang/
 /amd64-gcc/
 /arm-gcc/
+/crio/
+/amd64-clang-debug/
+/arm-clang-debug/
+/amd64-gcc-debug/
+/arm-gcc-debug/
+/crio-debug/