@@ -343,13 +343,13 @@ def _extract_flags(config):
343
343
flags = {}
344
344
for cg in config ["compileGroups" ]:
345
345
flags [cg ["language" ]] = []
346
- for ccfragment in cg ["compileCommandFragments" ]:
347
- fragment = ccfragment .get ("fragment" , "" )
348
- if not fragment .strip () or fragment .startswith ("-D" ):
349
- continue
346
+ for ccfragment in cg ["compileCommandFragments" ]:
347
+ fragment = ccfragment .get ("fragment" , "" )
348
+ if not fragment .strip () or fragment .startswith ("-D" ):
349
+ continue
350
350
flags [cg ["language" ]].extend (
351
- click .parser .split_arg_string (fragment .strip ())
352
- )
351
+ click .parser .split_arg_string (fragment .strip ())
352
+ )
353
353
354
354
return flags
355
355
@@ -391,7 +391,7 @@ def find_framework_service_files(search_path, sdk_config):
391
391
result ["kconfig_files" ].append (join (search_path , d , f ))
392
392
393
393
result ["lf_files" ].extend ([
394
- join (FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32_fragments.lf" ),
394
+ join (FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32_fragments.lf" ),
395
395
join (FRAMEWORK_DIR , "components" , "newlib" , "newlib.lf" )
396
396
])
397
397
@@ -794,13 +794,12 @@ def find_default_component(target_configs):
794
794
795
795
796
796
if env .subst ("$SRC_FILTER" ):
797
- sys . stderr . write (
797
+ print (
798
798
(
799
- "Error : the 'src_filter' option cannot be used with ESP-IDF. Select source "
799
+ "Warning : the 'src_filter' option cannot be used with ESP-IDF. Select source "
800
800
"files to build in the project CMakeLists.txt file.\n "
801
801
)
802
802
)
803
- env .Exit (1 )
804
803
805
804
if isfile (join (env .subst ("$PROJECT_SRC_DIR" ), "sdkconfig.h" )):
806
805
print (
@@ -921,22 +920,47 @@ def find_default_component(target_configs):
921
920
except :
922
921
print ("Warning! Couldn't find the main linker script in the CMake code model." )
923
922
924
- envsafe = env .Clone ()
925
- if project_target_name != "__idf_main" :
926
- # Manually add dependencies to CPPPATH since ESP-IDF build system doesn't generate
927
- # this info if the folder with sources is not named 'main'
928
- # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#rename-main
929
- envsafe .AppendUnique (CPPPATH = app_includes ["plain_includes" ])
923
+ #
924
+ # Process project sources
925
+ #
926
+
927
+ # Remove project source files from following build stages as they're
928
+ # built as part of the framework
929
+ def _skip_prj_source_files (node ):
930
+ if (
931
+ node .srcnode ()
932
+ .get_path ()
933
+ .lower ()
934
+ .startswith (env .subst ("$PROJECT_SRC_DIR" ).lower ())
935
+ ):
936
+ return None
937
+ return node
938
+
939
+
940
+ env .AddBuildMiddleware (_skip_prj_source_files )
941
+
942
+ # Project files should be compiled only when a special
943
+ # option is enabled when running 'test' command
944
+ if "__test" not in COMMAND_LINE_TARGETS or env .GetProjectOption (
945
+ "test_build_project_src"
946
+ ):
947
+ project_env = env .Clone ()
948
+ if project_target_name != "__idf_main" :
949
+ # Manually add dependencies to CPPPATH since ESP-IDF build system doesn't generate
950
+ # this info if the folder with sources is not named 'main'
951
+ # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#rename-main
952
+ project_env .AppendUnique (CPPPATH = app_includes ["plain_includes" ])
930
953
931
954
# Add default include dirs to global CPPPATH so they're visible to PIOBUILDFILES
932
955
envsafe .Append (CPPPATH = ["$PROJECT_INCLUDE_DIR" , "$PROJECT_SRC_DIR" ])
933
956
934
- env .Replace (SRC_FILTER = "-<*>" )
935
- env .Append (
936
- PIOBUILDFILES = compile_source_files (
937
- target_configs .get (project_target_name ), envsafe , envsafe .subst ("$PROJECT_DIR" )
957
+ env .Append (
958
+ PIOBUILDFILES = compile_source_files (
959
+ target_configs .get (project_target_name ),
960
+ project_env ,
961
+ project_env .subst ("$PROJECT_DIR" ),
962
+ )
938
963
)
939
- )
940
964
941
965
project_flags .update (link_args )
942
966
env .MergeFlags (project_flags )
0 commit comments