Skip to content

Commit

Permalink
Added comment mentionning path of source file to generated files.
Browse files Browse the repository at this point in the history
Related to: #783 cmock of the wrong file is generated.
  • Loading branch information
Pascal Bourguignon committed Jun 26, 2023
1 parent 3c981ce commit fac8708
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cmock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def generate_mock(src, folder)
name = File.basename(src, '.*')
ext = File.extname(src)
puts "Creating mock for #{name}..." unless @silent
@cm_generator.create_mock(name, @cm_parser.parse(name, File.read(src)), ext, folder)
@cm_generator.create_mock(name, @cm_parser.parse(name, File.read(src)), ext, folder,src)
end

def generate_skeleton(src)
Expand Down
7 changes: 5 additions & 2 deletions lib/cmock_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initialize(config, file_writer, utils, plugins)
end
end

def create_mock(module_name, parsed_stuff, module_ext = nil, folder = nil)
def create_mock(module_name, parsed_stuff, module_ext = nil, folder = nil, src = nil)
# determine the name for our new mock
mock_name = @prefix + module_name + @suffix

Expand All @@ -68,7 +68,8 @@ def create_mock(module_name, parsed_stuff, module_ext = nil, folder = nil)
:clean_name => TypeSanitizer.sanitize_c_identifier(mock_name),
:folder => mock_folder,
:parsed_stuff => parsed_stuff,
:skeleton => false
:skeleton => false,
:source => src
}

create_mock_subdir(mock_project)
Expand Down Expand Up @@ -129,6 +130,7 @@ def create_mock_header_file(mock_project)
end

@file_writer.create_file(mock_project[:mock_name] + mock_project[:module_ext], mock_project[:folder]) do |file, filename|
file << "/* Source File: #{mock_project[:source]} */\n" # if mock_project[:source]
create_mock_header_header(file, filename, mock_project)
create_mock_header_service_call_declarations(file, mock_project)
create_typedefs(file, mock_project)
Expand All @@ -142,6 +144,7 @@ def create_mock_header_file(mock_project)

def create_mock_source_file(mock_project)
@file_writer.create_file(mock_project[:mock_name] + '.c', mock_project[:folder]) do |file, filename|
file << "/* Source File: #{mock_project[:source]} */\n" # if mock_project[:source]
create_source_header_section(file, filename, mock_project)
create_instance_structure(file, mock_project)
create_extern_declarations(file)
Expand Down

0 comments on commit fac8708

Please sign in to comment.