update ceedling to 0.29.0

This commit is contained in:
hathach
2019-11-01 17:48:59 +07:00
parent 774a9f63ab
commit b25faa97c2
59 changed files with 1962 additions and 736 deletions
+77 -56
View File
@@ -31,95 +31,111 @@ unless (project_found)
include Thor::Actions
desc "new PROJECT_NAME", "create a new ceedling project"
method_option :no_docs, :type => :boolean, :default => false, :desc => "No docs in vendor directory"
method_option :nodocs, :type => :boolean, :default => false
method_option :as_gem, :type => :boolean, :default => false, :desc => "Create the scaffold using Ceedling as a gem instead of filling in the vendor directory. Implies --no-docs."
method_option :asgem, :type => :boolean, :default => false
method_option :with_ignore, :type => :boolean, :default => false, :desc => "Create a gitignore file for ignoring ceedling generated files."
method_option :withignore, :type => :boolean, :default => false
method_option :no_configs, :type => :boolean, :default => false, :desc => "Don't install starter configuration files."
method_option :docs, :type => :boolean, :default => false, :desc => "Add docs in project vendor directory"
method_option :local, :type => :boolean, :default => false, :desc => "Create a copy of Ceedling in the project vendor directory"
method_option :gitignore, :type => :boolean, :default => false, :desc => "Create a gitignore file for ignoring ceedling generated files"
method_option :no_configs, :type => :boolean, :default => false, :desc => "Don't install starter configuration files"
method_option :noconfigs, :type => :boolean, :default => false
#deprecated:
method_option :no_docs, :type => :boolean, :default => false
method_option :nodocs, :type => :boolean, :default => false
method_option :as_gem, :type => :boolean, :default => false
method_option :asgem, :type => :boolean, :default => false
method_option :with_ignore, :type => :boolean, :default => false
method_option :withignore, :type => :boolean, :default => false
def new(name, silent = false)
copy_assets_and_create_structure(name, silent, false, options)
end
desc "upgrade PROJECT_NAME", "upgrade ceedling for a project (not req'd if gem used)"
method_option :no_docs, :type => :boolean, :default => false, :desc => "No docs in vendor directory"
method_option :nodocs, :type => :boolean, :default => false
method_option :no_configs, :type => :boolean, :default => true, :desc => "Don't install starter configuration files."
method_option :docs, :type => :boolean, :default => false, :desc => "Add docs in project vendor directory"
method_option :local, :type => :boolean, :default => false, :desc => "Create a copy of Ceedling in the project vendor directory"
method_option :no_configs, :type => :boolean, :default => false, :desc => "Don't install starter configuration files"
method_option :noconfigs, :type => :boolean, :default => false
#deprecated:
method_option :no_docs, :type => :boolean, :default => false
method_option :nodocs, :type => :boolean, :default => false
def upgrade(name, silent = false)
copy_assets_and_create_structure(name, silent, true, options)
copy_assets_and_create_structure(name, silent, true, options || {:upgrade => true})
end
no_commands do
def copy_assets_and_create_structure(name, silent=false, force=false, options = {})
no_docs = options[:no_docs] || options[:nodocs] || false
no_configs = options[:no_configs] || options[:noconfigs] || false
as_gem = options[:as_gem] || options[:asgem] || false
with_ignore = options[:with_ignore] || options[:withignore] || false
puts "WARNING: --no_docs deprecated. It is now the default. Specify -docs if you want docs installed." if (options[:no_docs] || options[:nodocs])
puts "WARNING: --as_gem deprecated. It is now the default. Specify -local if you want ceedling installed to this project." if (options[:as_gem] || options[:asgem])
puts "WARNING: --with_ignore deprecated. It is now called -gitignore" if (options[:with_ignore] || options[:with_ignore])
use_docs = options[:docs] || false
use_configs = !(options[:no_configs] || options[:noconfigs] || false)
use_gem = !(options[:local])
use_ignore = options[:gitignore] || false
is_upgrade = options[:upgrade] || false
ceedling_path = File.join(name, 'vendor', 'ceedling')
source_path = File.join(name, 'src')
test_path = File.join(name, 'test')
test_support_path = File.join(name, 'test/support')
[source_path, test_path, test_support_path].each do |d|
FileUtils.mkdir_p d
# If it's not an upgrade, make sure we have the paths we expect
if (!is_upgrade)
[source_path, test_path, test_support_path].each do |d|
FileUtils.mkdir_p d
end
end
unless as_gem
# Genarate gitkeep in test support path
FileUtils.touch(File.join(test_support_path, '.gitkeep'))
# If documentation requested, create a place to dump them and do so
if use_docs
doc_path = File.join(ceedling_path, 'docs')
FileUtils.mkdir_p doc_path
in_doc_path = lambda {|f| File.join(doc_path, f)}
doc_files = [
'docs/CeedlingPacket.md',
'vendor/c_exception/docs/CException.md',
'vendor/cmock/docs/CMock_Summary.md',
'vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf',
'vendor/unity/docs/UnityAssertionsReference.md',
'vendor/unity/docs/UnityConfigurationGuide.md',
'vendor/unity/docs/UnityGettingStartedGuide.md',
'vendor/unity/docs/UnityHelperScriptsGuide.md',
'vendor/unity/docs/ThrowTheSwitchCodingStandard.md',
]
doc_files.each do |f|
copy_file(f, in_doc_path.call(File.basename(f)), :force => force)
end
end
# If installed locally to project, copy ceedling, unity, cmock, & supports to vendor
unless use_gem
FileUtils.mkdir_p ceedling_path
unless no_docs
doc_path = File.join(ceedling_path, 'docs')
FileUtils.mkdir_p doc_path
in_doc_path = lambda {|f| File.join(doc_path, f)}
doc_files = [
'docs/CeedlingPacket.md',
'vendor/c_exception/docs/CException.md',
'vendor/cmock/docs/CMock_Summary.md',
'vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf',
'vendor/unity/docs/UnityAssertionsReference.md',
'vendor/unity/docs/UnityConfigurationGuide.md',
'vendor/unity/docs/UnityGettingStartedGuide.md',
'vendor/unity/docs/UnityHelperScriptsGuide.md',
'vendor/unity/docs/ThrowTheSwitchCodingStandard.md',
]
doc_files.each do |f|
copy_file(f, in_doc_path.call(File.basename(f)), :force => force)
end
end
folders = if as_gem
%w{plugins lib}
else
%w{plugins lib bin}
end
#copy full folders from ceedling gem into project
folders.map do |f|
%w{plugins lib bin}.map do |f|
{:src => f, :dst => File.join(ceedling_path, f)}
end.each do |f|
directory(f[:src], f[:dst], :force => force)
end
# mark ceedling as an executable
File.chmod(0755, File.join(ceedling_path, 'bin', 'ceedling')) unless is_windows?
#copy necessary subcomponents from ceedling gem into project
sub_components = [
{:src => 'vendor/c_exception/lib/', :dst => 'vendor/c_exception/lib'},
{:src => 'vendor/c_exception/release/', :dst => 'vendor/c_exception/release'},
{:src => 'vendor/cmock/config/', :dst => 'vendor/cmock/config'},
{:src => 'vendor/cmock/lib/', :dst => 'vendor/cmock/lib'},
{:src => 'vendor/cmock/release/', :dst => 'vendor/cmock/release'},
{:src => 'vendor/cmock/src/', :dst => 'vendor/cmock/src'},
{:src => 'vendor/deep_merge/lib/', :dst => 'vendor/deep_merge/lib'},
{:src => 'vendor/diy/lib', :dst => 'vendor/diy/lib'},
{:src => 'vendor/unity/auto/', :dst => 'vendor/unity/auto'},
{:src => 'vendor/unity/release/', :dst => 'vendor/unity/release'},
{:src => 'vendor/unity/src/', :dst => 'vendor/unity/src'},
]
@@ -128,8 +144,9 @@ unless (project_found)
end
end
unless (no_configs)
if as_gem
# We're copying in a configuration file if we haven't said not to
if (use_configs)
if use_gem
copy_file(File.join('assets', 'project_as_gem.yml'), File.join(name, 'project.yml'), :force => force)
else
copy_file(File.join('assets', 'project_with_guts.yml'), File.join(name, 'project.yml'), :force => force)
@@ -137,18 +154,20 @@ unless (project_found)
copy_file(File.join('assets', 'ceedling.cmd'), File.join(name, 'ceedling.cmd'), :force => force)
else
copy_file(File.join('assets', 'ceedling'), File.join(name, 'ceedling'), :force => force)
File.chmod(0755, File.join(name, 'ceedling'))
end
end
end
if (with_ignore)
# Copy the gitignore file if requested
if (use_ignore)
copy_file(File.join('assets', 'default_gitignore'), File.join(name, '.gitignore'), :force => force)
end
unless silent
puts "\n"
puts "Project '#{name}' #{force ? "upgraded" : "created"}!"
puts " - Tool documentation is located in vendor/ceedling/docs" if (not no_docs) and (not as_gem)
puts " - Tool documentation is located in vendor/ceedling/docs" if use_docs
puts " - Execute 'ceedling help' to view available test & build tasks"
puts ''
end
@@ -167,7 +186,7 @@ unless (project_found)
def example(proj_name, dest=nil)
if dest.nil? then dest = proj_name end
invoke :new, [dest, true]
copy_assets_and_create_structure(dest, true, false, {:local=>true, :docs=>true})
dest_src = File.join(dest,'src')
dest_test = File.join(dest,'test')
@@ -266,6 +285,8 @@ else
abort
when /^help$/
options[:list_tasks] = true
when /^-T$/
options[:list_tasks] = true
when /^project:(\w+)/
ENV['CEEDLING_USER_PROJECT_FILE'] = "#{$1}.yml"
else