diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index d4a3220..e7c2179 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -28,7 +28,12 @@ class CMockGenerator here = File.dirname __FILE__ unity_path_in_ceedling = "#{here}/../../unity" # path to Unity from within Ceedling unity_path_in_cmock = "#{here}/../vendor/unity" # path to Unity from within CMock - if File.exist? unity_path_in_ceedling + # path to Unity as specified by env var + unity_path_in_env = ENV.has_key?("UNITY_DIR") ? File.expand_path(ENV.fetch("UNITY_DIR")) : nil + + if unity_path_in_env and File.exist? unity_path_in_env + require "#{unity_path_in_env}/auto/type_sanitizer" + elsif File.exist? unity_path_in_ceedling require "#{unity_path_in_ceedling}/auto/type_sanitizer" elsif File.exist? unity_path_in_cmock require "#{unity_path_in_cmock}/auto/type_sanitizer" diff --git a/scripts/create_mock.rb b/scripts/create_mock.rb index 389444e..cc69249 100644 --- a/scripts/create_mock.rb +++ b/scripts/create_mock.rb @@ -4,5 +4,5 @@ raise "Header file to mock must be specified!" unless ARGV.length >= 1 mock_out = ENV.fetch('MOCK_OUT', './build/test/mocks') mock_prefix = ENV.fetch('MOCK_PREFIX', 'mock_') -cmock = CMock.new(plugins: [:ignore, :return_thru_ptr], mock_prefix: 'mock_', mock_path: mock_out) +cmock = CMock.new(plugins: [:ignore, :return_thru_ptr], mock_prefix: mock_prefix, mock_path: mock_out) cmock.setup_mocks(ARGV[0])