Skip to content

Commit

Permalink
⚡️ Do not compile cmock.c if no mocks used
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mkarlesky committed Sep 12, 2024
1 parent 4190c33 commit 533d636
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ceedling/test_invoker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/ceedling/test_invoker_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 533d636

Please sign in to comment.