SoC common : scripts :refactor the build system. [2/2]

PD#SWPL-174904

Problem:
Refactor the build system.

Solution:
Merge some flow in a same flow which related with compiler.

Verify:
N/A

Change-Id: Id223479fe9be86ab99d408fb68bafe0ae45fed8a
Signed-off-by: xiaohu.huang <xiaohu.huang@amlogic.com>
diff --git a/build_all.sh b/build_all.sh
index 0b0837d..ace80cc 100755
--- a/build_all.sh
+++ b/build_all.sh
@@ -9,6 +9,7 @@
 [ ! -d $OUTPUT_DIR ] && mkdir -p $OUTPUT_DIR
 
 [ -z "$BUILD_LOG" ] && BUILD_LOG="$OUTPUT_DIR/build.log"
+[ -z "$LAST_BUILD_FAILURE" ] && LAST_BUILD_FAILURE="$OUTPUT_DIR/.last_build_failure"
 
 # Clear build.log
 cat <<EOF > $BUILD_LOG
diff --git a/map_analyzer_clang_llvm.py b/map_analyzer_clang+llvm.py
similarity index 100%
rename from map_analyzer_clang_llvm.py
rename to map_analyzer_clang+llvm.py
diff --git a/map_analyzer_gcc_xcc.py b/map_analyzer_gcc.py
similarity index 82%
copy from map_analyzer_gcc_xcc.py
copy to map_analyzer_gcc.py
index 7639cb6..88f53d6 100755
--- a/map_analyzer_gcc_xcc.py
+++ b/map_analyzer_gcc.py
@@ -98,40 +98,6 @@
         else:
             self.add_data_with_rodata(section, size)
 
-    def add_xcc_section(self, section, size):
-        if current_section is None:
-            return;
-        if section.startswith('.comment'):
-            return
-        if section.startswith('.debug'):
-            return
-        if section.startswith('.xt.prop')or section.startswith('.xt.lit'):
-            return
-        if section.startswith('.text') or section.endswith('.text') \
-            or section.startswith('.literal') or section.endswith('.literal') \
-            or section.startswith('.rodata') or section.endswith('.rodata'):
-            #add the .rodata to text in order to match the result of size command with xcc's elf file
-            self.text += size
-            if section.startswith('.rodata') or section.endswith('.rodata'):
-                self.rodata += size
-        elif section.startswith('.rela.dyn'):
-            self.rela_text += size
-        elif section.startswith('.bss') or section.startswith('.common') or section.startswith('.sbss'):
-            self.bss += size
-        elif section.startswith('.data') or section.endswith('.data'):
-            self.data += size
-        elif section.startswith('.heap'):
-            self.heap += size
-            self.bss += size
-        elif section.startswith('.stack'):
-            self.stack += size
-            self.bss += size
-        else:
-            if (size > 0):
-                print("customer section:%s, size:%d" % (section, size))
-                self.customize += size
-        self.rom_usage = (self.text + self.data)
-        self.ram_usage = (self.data + self.bss)
 
 def print_codesize_module_text_with_rodata():
     print('---------------------------------------------------------------------------------------------------')
@@ -209,14 +175,8 @@
 
 size_by_source = {}
 with open(args.map_file) as f:
-    if os.getenv('COMPILER') == "xcc":
-        arch_toolchain = "XCC"
-        toolchain_keyword = "xtensa-elf"
-        is_xtensa = 1
-    else:
-        arch_toolchain = "GCC"
-        toolchain_keyword = "toolchains"
-        is_xtensa = 0
+    arch_toolchain = "GCC"
+    toolchain_keyword = "toolchains"
     print("%s toolchain map analyzer" % arch_toolchain)
 
     lines = iter(f)
@@ -289,22 +249,15 @@
 
                 if source not in size_by_source:
                     size_by_source[source] = SectionSize()
-                if is_xtensa == 1:
-                    size_by_source[source].add_xcc_section(current_section, size)
-                else:
-                    size_by_source[source].add_gcc_section(current_section, size)
+                size_by_source[source].add_gcc_section(current_section, size)
 
 sources = list(size_by_source.keys())
 sources.sort(key = lambda x: size_by_source[x].total())
 sumrom = sumram = sumcode = sumdata = sumbss = sumcustomize = sumrodata = 0
 sys_mem_usage = SectionSize.system_stack  + SectionSize.system_heap
-if os.getenv('COMPILER') == "xcc":
+if os.getenv('ARCH') == "riscv":
     print_codesize_module_text_with_rodata()
     print_codesize_summary_text_with_rodata()
 else:
-    if os.getenv('ARCH') == "riscv":
-        print_codesize_module_text_with_rodata()
-        print_codesize_summary_text_with_rodata()
-    else:
-        print_codesize_module_data_with_rodata()
-        print_codesize_summary_data_with_rodata()
+    print_codesize_module_data_with_rodata()
+    print_codesize_summary_data_with_rodata()
diff --git a/map_analyzer_gcc_xcc.py b/map_analyzer_xcc.py
similarity index 90%
rename from map_analyzer_gcc_xcc.py
rename to map_analyzer_xcc.py
index 7639cb6..1d99cfa 100755
--- a/map_analyzer_gcc_xcc.py
+++ b/map_analyzer_xcc.py
@@ -83,21 +83,6 @@
         self.rom_usage = (self.text + self.data)
         self.ram_usage = (self.data + self.bss - self.rodata)
 
-    def add_gcc_section(self, section, size):
-        if current_section is None:
-            return;
-        if section.startswith('.comment'):
-            return
-        if section.startswith('.debug'):
-            return
-        if section.startswith('.ARM.attributes'):
-            return
-
-        if os.getenv('ARCH') == "riscv":
-            self.add_text_with_rodata(section, size)
-        else:
-            self.add_data_with_rodata(section, size)
-
     def add_xcc_section(self, section, size):
         if current_section is None:
             return;
@@ -209,14 +194,8 @@
 
 size_by_source = {}
 with open(args.map_file) as f:
-    if os.getenv('COMPILER') == "xcc":
-        arch_toolchain = "XCC"
-        toolchain_keyword = "xtensa-elf"
-        is_xtensa = 1
-    else:
-        arch_toolchain = "GCC"
-        toolchain_keyword = "toolchains"
-        is_xtensa = 0
+    arch_toolchain = "XCC"
+    toolchain_keyword = "xtensa-elf"
     print("%s toolchain map analyzer" % arch_toolchain)
 
     lines = iter(f)
@@ -289,22 +268,11 @@
 
                 if source not in size_by_source:
                     size_by_source[source] = SectionSize()
-                if is_xtensa == 1:
-                    size_by_source[source].add_xcc_section(current_section, size)
-                else:
-                    size_by_source[source].add_gcc_section(current_section, size)
+                size_by_source[source].add_xcc_section(current_section, size)
 
 sources = list(size_by_source.keys())
 sources.sort(key = lambda x: size_by_source[x].total())
 sumrom = sumram = sumcode = sumdata = sumbss = sumcustomize = sumrodata = 0
 sys_mem_usage = SectionSize.system_stack  + SectionSize.system_heap
-if os.getenv('COMPILER') == "xcc":
-    print_codesize_module_text_with_rodata()
-    print_codesize_summary_text_with_rodata()
-else:
-    if os.getenv('ARCH') == "riscv":
-        print_codesize_module_text_with_rodata()
-        print_codesize_summary_text_with_rodata()
-    else:
-        print_codesize_module_data_with_rodata()
-        print_codesize_summary_data_with_rodata()
+print_codesize_module_text_with_rodata()
+print_codesize_summary_text_with_rodata()