From de1cd7e344d0ccf0a720fc99373e06ca4f7d98c0 Mon Sep 17 00:00:00 2001
From: Thomas Barabosch <thomas.barabosch@fkie.fraunhofer.de>
Date: Mon, 15 Apr 2019 10:43:35 +0200
Subject: [PATCH] Exchanged Travis CI badge, fixed SCONS to work with dockcross x86

---
 README.md                          |  2 +-
 test/artificial_samples/SConstruct | 32 ++++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 7b2e985..46c46bb 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # cwe_checker #
 [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9dbf158110de427d893b40ba397b94bc)](https://www.codacy.com/app/weidenba/cwe_checker?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=fkie-cad/cwe_checker&amp;utm_campaign=Badge_Grade)
-[![Build Status](https://travis-ci.com/fkie-cad/cwe_checker.svg?branch=master)](https://travis-ci.com/fkie-cad/cwe_checker)
+[![Build Status](https://travis-ci.org/fkie-cad/cwe_checker.svg?branch=master)](https://travis-ci.org/fkie-cad/cwe_checker)
 ![Docker-Pulls](https://img.shields.io/docker/pulls/fkiecad/cwe_checker.svg)
 ## What is cwe_checker? ##
 *cwe_checker* detects common bug classes such as use of dangerous functions and simple integer overflows. These bug classes are formally known as [Common Weakness Enumerations](https://cwe.mitre.org/) (CWEs). Its main goal is to aid analysts to quickly find vulnerable code paths.
diff --git a/test/artificial_samples/SConstruct b/test/artificial_samples/SConstruct
index 765d801..fba27b9 100644
--- a/test/artificial_samples/SConstruct
+++ b/test/artificial_samples/SConstruct
@@ -10,6 +10,8 @@ c_compilers = {'x64': 'gcc',
                'mips': 'mips-linux-gnu-gcc',
                'ppc': 'powerpc-linux-gnu-gcc'}
 
+c_linkers =   {'x86': './dockcross-linux-x86 gcc -m32'}
+
 cpp_compilers = {'x64': 'g++',
                  'x86': './dockcross-linux-x86 g++',
                  'arm': 'arm-linux-gnueabi-g++-5',
@@ -28,10 +30,15 @@ cpp_flags = {'x64': '-g -fno-stack-protector',
              'mips': '-g -fno-stack-protector',
              'ppc': '-g -fno-stack-protector'}
 
+cpp_linkers =   {'x86': './dockcross-linux-x86 g++ -m32'}
+
 def which(pgm):
-    path=os.getenv('PATH')
+    # TODO: check if dockcross containers are installed
+    if pgm.startswith('.'):
+        return pgm
+    path = os.getenv('PATH')
     for p in path.split(os.path.pathsep):
-        p=os.path.join(p,pgm)
+        p = os.path.join(p,pgm)
         if os.path.exists(p) and os.access(p,os.X_OK):
             return p
 
@@ -53,9 +60,13 @@ def build_c(arch):
             if compile_only_on_x64(str(p), arch):
                 print('Skipping architecture %s for %s' % (arch, str(p)))
                 continue
-            env = Environment(CC = c_compilers[arch],
-                          CCFLAGS = c_flags[arch] + optimize(str(p)))
-            print(str(p))
+
+            env = Environment()
+            env['CC'] = c_compilers[arch]
+            env['CCFLAGS'] = c_flags[arch] + optimize(str(p))
+            if arch in c_linkers:
+                env['LINK'] = c_linkers[arch]
+
             env.Program('%s/%s_%s.out' % (build_path, str(p).split('.')[0], arch),
                         env.Object(target='%s/%s_%s.o' % (build_path, str(p), arch),
                                    source='%s/%s' % (build_path, str(p))))
@@ -67,10 +78,15 @@ def build_cpp(arch):
     if which(cpp_compilers[arch]) is not None:
         cpp_programs = Glob('*.cpp')
         for p in cpp_programs:
-            env = Environment(CC = cpp_compilers[arch],
-                              CCFLAGS = cpp_flags[arch] + optimize(str(p)))
+            env = Environment()
+            env['CCP'] = cpp_compilers[arch]
+            env['CCPFLAGS'] = cpp_flags[arch] + optimize(str(p))
+            if arch in c_linkers:
+                env['CPPLINK'] = cpp_linkers[arch]
+
             env.Program('%s/%s_%s.out' % (build_path, str(p).split('.')[0], arch),
-                        '%s/%s' % (build_path, str(p)))
+                        env.Object(target='%s/%s_%s.o' % (build_path, str(p), arch),
+                                   source='%s/%s' % (build_path, str(p))))
     else:
         print('Compiler %s for architecture %s is not installed!' % (cpp_compilers[arch], arch))
 
--
libgit2 0.26.0