From 533d636b09d89f482d872a11cd1cff29c3cf56dc Mon Sep 17 00:00:00 2001 From: Michael Karlesky Date: Wed, 11 Sep 2024 22:26:44 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Do=20not=20compile=20cmock?= =?UTF-8?q?.c=20if=20no=20mocks=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a particular test executable does not include mocks, there’s no reason to compile and link cmock.c. This small improvement will almost certainly have quite little impact, but it’s just more better, dangit. --- lib/ceedling/test_invoker.rb | 2 +- lib/ceedling/test_invoker_helper.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ceedling/test_invoker.rb b/lib/ceedling/test_invoker.rb index 63a29d4a..7dd7490b 100644 --- a/lib/ceedling/test_invoker.rb +++ b/lib/ceedling/test_invoker.rb @@ -305,7 +305,7 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) end # CMock + Unity + CException - test_frameworks = @helper.collect_test_framework_sources + test_frameworks = @helper.collect_test_framework_sources( details[:mock_list] ) # Extra suport source files (e.g. microcontroller startup code needed by simulator) test_support = @configurator.collection_all_support diff --git a/lib/ceedling/test_invoker_helper.rb b/lib/ceedling/test_invoker_helper.rb index 395de3ff..051eeba5 100644 --- a/lib/ceedling/test_invoker_helper.rb +++ b/lib/ceedling/test_invoker_helper.rb @@ -167,18 +167,18 @@ def flags(context:, operation:, filepath:) return @flaginator.flag_down( context:context, operation:operation, filepath:filepath ) end - def collect_test_framework_sources + def collect_test_framework_sources(mocks) sources = [] sources << File.join(PROJECT_BUILD_VENDOR_UNITY_PATH, UNITY_C_FILE) - sources << File.join(PROJECT_BUILD_VENDOR_CMOCK_PATH, CMOCK_C_FILE) if @configurator.project_use_mocks + sources << File.join(PROJECT_BUILD_VENDOR_CMOCK_PATH, CMOCK_C_FILE) if @configurator.project_use_mocks and !mocks.empty? sources << File.join(PROJECT_BUILD_VENDOR_CEXCEPTION_PATH, CEXCEPTION_C_FILE) if @configurator.project_use_exceptions # If we're (a) using mocks (b) a Unity helper is defined and (c) that unity helper includes a source file component, # then link in the unity_helper object file too. if @configurator.project_use_mocks @configurator.cmock_unity_helper_path.each do |helper| - if @file_wrapper.exist?( helper.ext(EXTENSION_SOURCE) ) + if @file_wrapper.exist?( helper.ext( EXTENSION_SOURCE ) ) sources << helper end end