]> granicus.if.org Git - esp-idf/commitdiff
cmake: Add a compatible old GCC flag, fix the cmake example building
authorAnton Maklakov <anton@espressif.com>
Tue, 18 Sep 2018 05:07:21 +0000 (13:07 +0800)
committerAnton Maklakov <anton@espressif.com>
Thu, 20 Sep 2018 10:53:15 +0000 (18:53 +0800)
tools/ci/build_examples.sh
tools/ci/build_examples_cmake.sh
tools/cmake/crosstool_version_check.cmake
tools/cmake/idf_functions.cmake

index be3e558f58ef28e83fb07aa4eabb718438fbfb3d..81576bf553bdfa6908a7de269aeddc92a69dc942 100755 (executable)
@@ -157,10 +157,11 @@ echo -e "\nFound issues:"
 #       Ignore the next messages:
 # "error.o" or "-Werror" in compiler's command line
 # "reassigning to symbol" or "changes choice state" in sdkconfig
-# Compiler and toochain versions is not supported from make/project.mk
+# 'Compiler and toochain versions is not supported' from make/project.mk
 IGNORE_WARNS="\
 library/error\.o\
-\|\ -Werror\|error\.d\
+\|\ -Werror\
+\|error\.d\
 \|reassigning to symbol\
 \|changes choice state\
 \|Compiler version is not supported\
index 39840a38568622da5aa08306c4e0b64fce9d176d..849943b938aba6b3e783a366c5850774a9dbb50e 100755 (executable)
@@ -160,8 +160,17 @@ echo -e "\nFound issues:"
 #       Ignore the next messages:
 # "error.o" or "-Werror" in compiler's command line
 # "reassigning to symbol" or "changes choice state" in sdkconfig
-sort -u "${LOG_SUSPECTED}" | \
-grep -v "library/error.o\|\ -Werror\|reassigning to symbol\|changes choice state" \
+# 'Compiler and toochain versions is not supported' from crosstool_version_check.cmake
+IGNORE_WARNS="\
+library/error\.o\
+\|\ -Werror\
+\|error\.d\
+\|reassigning to symbol\
+\|changes choice state\
+\|crosstool_version_check\.cmake\
+"
+
+sort -u "${LOG_SUSPECTED}" | grep -v "${IGNORE_WARNS}" \
     && RESULT=$RESULT_ISSUES \
     || echo -e "\tNone"
 
index d572a82a7f75a8045d7c2fdf9bbd51eac891a349..1180fc029a41bf41f4d9e73b74dcf95b3de6c3de 100644 (file)
@@ -17,7 +17,6 @@ function(crosstool_version_check expected_ctng_version)
         OUTPUT_QUIET)
 
     string(REGEX MATCH "crosstool-ng-[0-9a-g\\.-]+" ctng_version "${toolchain_stderr}")
-    string(REPLACE "crosstool-ng-" "" ctng_version "${ctng_version}")
     # We use FIND to match version instead of STREQUAL because some toolchains are built
     # with longer git hash strings than others. This will match any version which starts with
     # the expected version string.
@@ -30,3 +29,21 @@ function(crosstool_version_check expected_ctng_version)
             "doesn't match supported version ${expected_ctng_version}. ${ctng_version_warning}")
     endif()
 endfunction()
+
+function(get_expected_ctng_version _toolchain_ver _gcc_ver)
+    file(STRINGS ${IDF_PATH}/tools/toolchain_versions.mk config_contents)
+    foreach(name_and_value ${config_contents})
+        # Strip spaces
+        string(REPLACE " " "" name_and_value ${name_and_value})
+        # Find variable name
+        string(REGEX MATCH "^[^=]+" name ${name_and_value})
+        # Find the value
+        string(REPLACE "${name}=" "" value ${name_and_value})
+        # Getting values
+        if("${name}" STREQUAL "SUPPORTED_TOOLCHAIN_COMMIT_DESC")
+            set("${_toolchain_ver}" "${value}" PARENT_SCOPE)
+        elseif("${name}" STREQUAL "SUPPORTED_TOOLCHAIN_GCC_VERSIONS")
+            set(${_gcc_ver} "${value}" PARENT_SCOPE)
+        endif()
+    endforeach()
+endfunction()
index d68eabf628087d436184dba4fcea29bdac2353db..f84deb70a06c1db4c815f91e7611400cf1a1fec6 100644 (file)
@@ -40,6 +40,13 @@ macro(idf_set_global_variables)
 
     # path to idf.py tool
     set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
+
+    # Temporary trick to support both gcc5 and gcc8 builds
+    if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 5.2.0)
+        set(GCC_NOT_5_2_0 0)
+    else()
+        set(GCC_NOT_5_2_0 1)
+    endif()
 endmacro()
 
 # Add all the IDF global compiler & preprocessor options
@@ -86,6 +93,30 @@ function(idf_set_global_compiler_options)
         -Wno-old-style-declaration
         )
 
+    if(CONFIG_DISABLE_GCC8_WARNINGS)
+        add_compile_options(
+            -Wno-parentheses
+            -Wno-sizeof-pointer-memaccess
+            -Wno-clobbered
+        )
+
+        # doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
+        if(NOT CMAKE_C_COMPILER_VERSION VERSION_EQUAL 5.2.0)
+            add_compile_options(
+                -Wno-format-overflow
+                -Wno-stringop-truncation
+                -Wno-misleading-indentation
+                -Wno-cast-function-type
+                -Wno-implicit-fallthrough
+                -Wno-unused-const-variable
+                -Wno-switch-unreachable
+                -Wno-format-truncation
+                -Wno-memset-elt-size
+                -Wno-int-in-bool-context
+            )
+        endif()
+    endif()
+
     # Stack protection
     if(NOT BOOTLOADER_BUILD)
         if(CONFIG_STACK_CHECK_NORM)
@@ -114,6 +145,8 @@ function(idf_set_global_compiler_options)
         endif()
     endif()
 
+    # Temporary trick to support both gcc5 and gcc8 builds
+    add_definitions(-DGCC_NOT_5_2_0=${GCC_NOT_5_2_0})
 endfunction()
 
 
@@ -134,8 +167,9 @@ function(idf_verify_environment)
     # Warn if the toolchain version doesn't match
     #
     # TODO: make these platform-specific for diff toolchains
-    gcc_version_check("5.2.0")
-    crosstool_version_check("1.22.0-80-g6c4433a")
+    get_expected_ctng_version(expected_toolchain expected_gcc)
+    gcc_version_check("${expected_gcc}")
+    crosstool_version_check("${expected_toolchain}")
 
 endfunction()