1#!/usr/bin/ruby 2# 3# Arm SCP/MCP Software 4# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 5# 6# SPDX-License-Identifier: BSD-3-Clause 7# 8 9GIT_ROOT = `git rev-parse --show-toplevel | tr -d '\n'` 10require "#{GIT_ROOT}/contrib/cmock/git/lib/cmock.rb" 11require 'optparse' 12require 'optparse/time' 13 14files = [] 15cmock_options = {} 16cmock_options[:verbosity] = 3 17 18cmock_option_cfg = "#{GIT_ROOT}/unit_test/cfg.yml" 19 20OptionParser.new do |parser| 21 parser.on('-h', '--help', 'Print this help') do |help| 22 puts "Usage gm.rb [options]" 23 puts parser 24 exit 25 end 26 27 parser.on('-m', '--mock_path=PATH', 'Path where mock files are generated') do |mock_path| 28 cmock_options[:mock_path] = mock_path 29 end 30 parser.on('-f', '--file_name=PATH', "Header file to generate mocks for") do |file_name| 31 files << file_name 32 end 33 parser.on('-o', '--cmock_option_cfg=yaml_file', 'Mock configuration file') do |new_cfg| 34 cmock_option_cfg = new_cfg 35 end 36 parser.on('-s', '--mock_suffix=mock_file_suffix', 'Mock file suffix') do |mock_suffix| 37 cmock_options[:mock_suffix] = mock_suffix 38 end 39 parser.on('-d', '--subdir=mock_subdir', 'subdir') do |subdir| 40 cmock_options[:subdir] = subdir 41 end 42end.parse! 43 44cmock_options.merge! CMockConfig.load_config_file_from_yaml(cmock_option_cfg) 45 46cmock = CMock.new(cmock_options).setup_mocks(files) 47 48# Create .clang_format to exclude mock_path from code styling 49File.open(cmock_options[:mock_path] + "/.clang-format", 'w') do |f| 50 f << "{\n \"DisableFormat\": true,\n \"SortIncludes\": false,\n}\n" 51end 52