add support for FIRST's compiler for the roboRIO

Change-Id: Ib20ebe014ed6d84fe90654c20163c57173441b44
diff --git a/aos/build/aos.gypi b/aos/build/aos.gypi
index 046d59b..5a9119d 100644
--- a/aos/build/aos.gypi
+++ b/aos/build/aos.gypi
@@ -28,6 +28,12 @@
           ['CXX', '<!(readlink -f <(AOS)/build/crio_cxx)'],
         ],
       }
+    ], ['PLATFORM=="linux-arm-gcc_frc"', {
+        'make_global_settings': [
+          ['CC', '<(ccache)<!(which arm-frc-linux-gnueabi-gcc-4.9)'],
+          ['CXX', '<(ccache)<!(which arm-frc-linux-gnueabi-g++-4.9)'],
+        ],
+      },
     ], ['PLATFORM=="linux-arm-gcc"', {
         'make_global_settings': [
           ['CC', '<(ccache)<!(which arm-linux-gnueabihf-gcc-4.7)'],
@@ -228,7 +234,7 @@
           ],
         }
       ],
-      ['ARCHITECTURE=="arm"', {
+      ['ARCHITECTURE=="arm" and FULL_COMPILER!="gcc_frc"', {
         'cflags': [
           '-mcpu=cortex-a8',
           '-mfpu=neon',
@@ -238,6 +244,18 @@
           '-mfpu=neon',
         ],
       }],
+      ['ARCHITECTURE=="arm" and FULL_COMPILER=="gcc_frc"', {
+        'cflags': [
+          '-mcpu=cortex-a9',
+          '-mfpu=neon',
+          '-mfloat-abi=softfp',
+        ],
+        'ldflags': [
+          '-mcpu=cortex-a9',
+          '-mfpu=neon',
+          '-mfloat-abi=softfp',
+        ],
+      }],
       ['PLATFORM=="crio"', {
           'target_conditions': [
             ['_type=="shared_library"', {
diff --git a/aos/build/build.py b/aos/build/build.py
index 6dea832..faa6fe1 100755
--- a/aos/build/build.py
+++ b/aos/build/build.py
@@ -553,7 +553,7 @@
       return r
 
   ARCHITECTURES = ('arm', 'amd64')
-  COMPILERS = ('clang', 'gcc', 'gcc_4.8')
+  COMPILERS = ('clang', 'gcc', 'gcc_4.8', 'gcc_frc')
   SANITIZERS = ('address', 'undefined', 'integer', 'memory', 'thread', 'none')
   SANITIZER_TEST_WARNINGS = {
       'memory': (True,
@@ -570,7 +570,8 @@
     for architecture in PrimeProcessor.ARCHITECTURES:
       for compiler in PrimeProcessor.COMPILERS:
         for debug in [True, False]:
-          if architecture == 'arm' and compiler == 'gcc_4.8':
+          if ((architecture == 'arm' and compiler == 'gcc_4.8') or
+              (architecture == 'amd64' and compiler == 'gcc_frc')):
             # We don't have a compiler to use here.
             continue
           platforms.append(
@@ -618,7 +619,12 @@
       if platforms & pie_sanitizers:
         to_download.add(architecture + '-fPIE')
 
-      if platforms & (self.platforms() - pie_sanitizers):
+      frc_platforms = self.select_platforms(architecture=architecture,
+                                            compiler='gcc_frc')
+      if platforms & frc_platforms:
+        to_download.add(architecture + '_frc')
+
+      if platforms & (self.platforms() - pie_sanitizers - frc_platforms):
         to_download.add(architecture)
 
     for download_target in to_download:
@@ -698,6 +704,9 @@
       if platform.compiler() == 'gcc' and platform.architecture() == 'amd64':
         packages.add('gcc-4.7')
         packages.add('g++-4.7')
+      elif platform.compiler() == 'gcc_frc':
+        packages.add('gcc-4.9-arm-frc-linux-gnueabi')
+        packages.add('g++-4.9-arm-frc-linux-gnueabi')
 
     self.do_check_installed(tuple(packages))
 
@@ -960,7 +969,7 @@
              '-DSANITIZER=%s' % platform.sanitizer(),
              '-DEXTERNALS_EXTRA=%s' %
              ('-fPIE' if platform.sanitizer() in PrimeProcessor.PIE_SANITIZERS
-              else '')) +
+              else ('_frc' if platform.compiler() == 'gcc_frc' else ''))) +
             processor.extra_gyp_flags() + (args.main_gyp,),
             stdin=subprocess.PIPE)
         gyp.communicate(("""
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index 106e2db..ecd1b01 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -10,6 +10,11 @@
 # the value from CONFIGURE_FLAGS has to get overriden in some places.
 ALL_LDFLAGS=""
 
+# Flags that should get passed to all configure scripts.
+# Some of them need to set LDFLAGS separately to work around stupid configure
+# scripts, so we can't just set that here.
+CONFIGURE_FLAGS=""
+
 if [ "$1" == "arm" ]; then
   COMPILED=${EXTERNALS}/../compiled-arm
 
@@ -20,11 +25,19 @@
   export CFLAGS="-mcpu=cortex-a8 -mfpu=neon"
   export CXXFLAGS="-mcpu=cortex-a8 -mfpu=neon"
   export OBJDUMP=${CROSS_COMPILE}objdump
-  # Flags that should get passed to all configure scripts.
-  # Some of them need to set LDFLAGS separately to work around stupid configure
-  # scripts, so we can't just set that here.
   CONFIGURE_FLAGS="--host=arm-linux-gnueabihf CC=${CC} CXX=${CXX} CFLAGS=\"${CFLAGS}\" CXXFLAGS=\"${CXXFLAGS}\" OBJDUMP=${OBJDUMP}"
   IS_CRIO=0
+elif [ "$1" == "arm_frc" ]; then
+  COMPILED=${EXTERNALS}/../compiled-arm_frc
+
+  CROSS_COMPILE=arm-frc-linux-gnueabi-
+
+  export CC=${CROSS_COMPILE}gcc-4.9
+  export CXX=${CROSS_COMPILE}g++-4.9
+  export CFLAGS="-mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp"
+  export CXXFLAGS="-mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp"
+  export OBJDUMP=${CROSS_COMPILE}objdump
+  CONFIGURE_FLAGS="--host=arm-frc-linux-gnueabi CC=${CC} CXX=${CXX} CFLAGS=\"${CFLAGS}\" CXXFLAGS=\"${CXXFLAGS}\" OBJDUMP=${OBJDUMP}"
 elif [ "$1" == "amd64" ]; then
   COMPILED=${EXTERNALS}/../compiled-amd64
   IS_CRIO=0