Skip to content

Commit

Permalink
Merge branch 'test/0_32/install_path_improvements' into test/ceedling…
Browse files Browse the repository at this point in the history
…_0_32_rc
  • Loading branch information
mkarlesky committed Apr 22, 2024
2 parents 78e208b + f5b3f70 commit 097912c
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 158 deletions.
Empty file modified bin/actions_wrapper.rb
100755 → 100644
Empty file.
27 changes: 19 additions & 8 deletions bin/app_cfg.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
class CeedlingAppConfig

def initialize()
# Installation location determined from the location of this file
ceedling_root_path = File.expand_path( File.join( File.dirname( __FILE__ ), '..' ) )
# Default installation location determined from the location of this file
ceedling_root_path = File.join( File.dirname( __FILE__ ), '..' )

# Create internal hash of needed values
@app_cfg = {
Expand All @@ -27,12 +27,18 @@ def initialize()
# Ceedling installation base path + /lib/ceedling
:ceedling_lib_path => '',

# Ceedling installation base path + /plugins
:ceedling_plugins_path => '',

# Ceedling installation base path + /vendor
:ceedling_vendor_path => '',

# Ceedling installation base path + /examples
:ceedling_examples_path => '',

# Ceedling lib path + lib/ceedling/rakefile.rb
:ceedling_rakefile_filepath => '',

# Blank initial value for completeness
:project_config => {},

Expand Down Expand Up @@ -62,7 +68,7 @@ def initialize()
begin
@app_cfg[:terminal_width] = (IO.console.winsize)[1]
rescue
# Do nothing; allow default value already set to stand
# Do nothing; allow value already set to stand as default
end
end

Expand Down Expand Up @@ -91,13 +97,18 @@ def set_tests_graceful_fail(enable)
end

def set_paths(root_path)
lib_base_path = File.join( root_path, 'lib' )
_root_path = File.expand_path( root_path )
lib_base_path = File.join( _root_path, 'lib' )
lib_path = File.join( lib_base_path, 'ceedling' )

@app_cfg[:ceedling_root_path] = root_path
@app_cfg[:ceedling_root_path] = _root_path
@app_cfg[:ceedling_lib_base_path] = lib_base_path
@app_cfg[:ceedling_lib_path] = File.join( lib_base_path, 'ceedling' )
@app_cfg[:ceedling_vendor_path] = File.join( root_path, 'vendor' )
@app_cfg[:ceedling_examples_path] = File.join( root_path, 'examples' )
@app_cfg[:ceedling_lib_path] = lib_path
@app_cfg[:ceedling_vendor_path] = File.join( _root_path, 'vendor' )
@app_cfg[:ceedling_plugins_path] = File.join( _root_path, 'plugins' )
@app_cfg[:ceedling_examples_path] = File.join( _root_path, 'examples' )

@app_cfg[:ceedling_rakefile_filepath] = File.join( lib_path, 'rakefile.rb' )
end

# External accessor to preserve hash-like read accesses
Expand Down
Empty file modified bin/cli.rb
100755 → 100644
Empty file.
40 changes: 27 additions & 13 deletions bin/cli_handler.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ def new_project(env, app_cfg, options, name, dest)
raise msg
end unless options[:force]

# Update app_cfg paths (ignore return value)
# Update app_cfg paths (ignore return values)
@helper.which_ceedling?( env:env, app_cfg:app_cfg )

# Thor Actions for project tasks use paths in relation to this path
ActionsWrapper.source_root( app_cfg[:ceedling_root_path] )

# Blow away any existing directories and contents if --force
Expand All @@ -94,12 +95,12 @@ def new_project(env, app_cfg, options, name, dest)
@helper.copy_docs( app_cfg[:ceedling_root_path], dest ) if options[:docs]

# Copy / set up project file
@helper.create_project_file( app_cfg[:ceedling_root_path], dest, options[:local] ) if options[:configs]
@helper.create_project_file( dest, options[:local] ) if options[:configs]

# Copy Git Ignore file
if options[:gitsupport]
@actions._copy_file(
File.join( app_cfg[:ceedling_root_path], 'assets', 'default_gitignore' ),
File.join( 'assets', 'default_gitignore' ),
File.join( dest, '.gitignore' ),
:force => true
)
Expand All @@ -111,19 +112,23 @@ def new_project(env, app_cfg, options, name, dest)


def upgrade_project(env, app_cfg, options, path)
@helper.set_verbosity( options[:verbosity] )

@path_validator.standardize_paths( path, options[:project] )

# Check for existing project
if !@helper.project_exists?( path, :&, options[:project], 'vendor/ceedling/lib/ceedling.rb' )
if !@helper.project_exists?( path, :&, options[:project], 'vendor/ceedling/lib/ceedling/version.rb' )
msg = "Could not find an existing project at #{path}/."
raise msg
end

if (@helper.which_ceedling?( env:env, app_cfg:app_cfg ) == :gem)
msg = "Project configuration specifies the Ceedling gem, not vendored Ceedling"
raise msg
which, _ = @helper.which_ceedling?( env:env, app_cfg:app_cfg )
if (which == :gem)
msg = "NOTICE: Project configuration specifies the Ceedling gem, not vendored Ceedling"
@streaminator.stream_puts( msg, Verbosity::NORMAL )
end

# Thor Actions for project tasks use paths in relation to this path
ActionsWrapper.source_root( app_cfg[:ceedling_root_path] )

# Recreate vendored tools
Expand Down Expand Up @@ -191,9 +196,11 @@ def build(env:, app_cfg:, options:{}, tasks:)
# Enable setup / operations duration logging in Rake context
app_cfg.set_stopwatch( @helper.process_stopwatch( tasks:tasks, default_tasks:default_tasks ) )

_, path = @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg )

@helper.load_ceedling(
config: config,
which: @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg ),
rakefile_path: path,
default_tasks: default_tasks
)

Expand All @@ -218,9 +225,11 @@ def dumpconfig(env, app_cfg, options, filepath, sections)
# Save references
app_cfg.set_project_config( config )

_, path = @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg )

config = @helper.load_ceedling(
config: config,
which: @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg ),
rakefile_path: path,
default_tasks: default_tasks
)
else
Expand All @@ -243,9 +252,11 @@ def environment(env, app_cfg, options)
# Save references
app_cfg.set_project_config( config )

_, path = @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg )

config = @helper.load_ceedling(
config: config,
which: @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg )
rakefile_path: path
)

env_list = []
Expand Down Expand Up @@ -276,7 +287,7 @@ def environment(env, app_cfg, options)


def list_examples(env, app_cfg)
# Process which_ceedling for app_cfg but ignore return
# Process which_ceedling for app_cfg modifications but ignore return values
@helper.which_ceedling?( env:env, app_cfg:app_cfg )

examples = @helper.lookup_example_projects( app_cfg[:ceedling_examples_path] )
Expand All @@ -296,7 +307,7 @@ def create_example(env, app_cfg, options, name, dest)

@path_validator.standardize_paths( dest )

# Process which_ceedling for app_cfg but ignore return
# Process which_ceedling for app_cfg modifications but ignore return values
@helper.which_ceedling?( env:env, app_cfg:app_cfg )

examples = @helper.lookup_example_projects( app_cfg[:ceedling_examples_path] )
Expand All @@ -313,6 +324,7 @@ def create_example(env, app_cfg, options, name, dest)
dest_test = File.join( dest, 'test' )
dest_project = File.join( dest, DEFAULT_PROJECT_FILENAME )

# Thor Actions for project tasks use paths in relation to this path
ActionsWrapper.source_root( app_cfg[:ceedling_root_path] )

@actions._directory( "examples/#{name}/src", dest_src, :force => true )
Expand Down Expand Up @@ -356,9 +368,11 @@ def list_rake_tasks(env:, app_cfg:, filepath:nil, mixins:[])
# Save reference to loaded configuration
app_cfg.set_project_config( config )

_, path = @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg )

@helper.load_ceedling(
config: config,
which: @helper.which_ceedling?( env:env, config:config, app_cfg:app_cfg ),
rakefile_path: path,
default_tasks: app_cfg[:default_tasks]
)

Expand Down
68 changes: 32 additions & 36 deletions bin/cli_helper.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def project_exists?( path, op, *components )
end


def create_project_file(ceedling_root, dest, local)
def create_project_file(dest, local)
project_filepath = File.join( dest, DEFAULT_PROJECT_FILENAME )
source_filepath = ''

if local
source_filepath = File.join( ceedling_root, 'assets', 'project_with_guts.yml' )
source_filepath = File.join( 'assets', 'project_with_guts.yml' )
else
source_filepath = File.join( ceedling_root, 'assets', 'project_as_gem.yml' )
source_filepath = File.join( 'assets', 'project_as_gem.yml' )
end

# Clone the project file and update internal version
Expand All @@ -50,6 +50,7 @@ def create_project_file(ceedling_root, dest, local)
end


# Returns two value: (1) symbol :gem or :path and (2) path for Ceedling installation
def which_ceedling?(env:, config:{}, app_cfg:)
# Determine which Ceedling we're running (in priority)
# 1. If there's an environment variable set, validate it, and return :gem or a path
Expand All @@ -72,8 +73,8 @@ def which_ceedling?(env:, config:{}, app_cfg:)
if which_ceedling.nil?
walked = @config_walkinator.fetch_value( config, :project, :which_ceedling )
if !walked[:value].nil?
@streaminator.stream_puts( " > Set which Ceedling from config entry :project -> :which_ceedling", Verbosity::OBNOXIOUS )
which_ceedling = walked[:value].strip()
@streaminator.stream_puts( " > Set which Ceedling from config :project -> :which_ceedling => #{which_ceedling}", Verbosity::OBNOXIOUS )
which_ceedling = :gem if (which_ceedling.casecmp( 'gem' ) == 0)
end
end
Expand All @@ -92,45 +93,41 @@ def which_ceedling?(env:, config:{}, app_cfg:)
@streaminator.stream_puts( " > Defaulting to running Ceedling from Gem", Verbosity::OBNOXIOUS )
end

# Default gem path
ceedling_path = app_cfg[:ceedling_root_path]
# If we're launching from the gem, return :gem and initial Rakefile path
if which_ceedling == :gem
return which_ceedling, app_cfg[:ceedling_rakefile_filepath]
end

if which_ceedling != :gem
ceedling_path = which_ceedling
@path_validator.standardize_paths( ceedling_path )
if !@file_wrapper.directory?( ceedling_path )
raise "Configured Ceedling launch path #{ceedling_path}/ does not exist"
end
# Otherwise, handle which_ceedling as a base path
ceedling_path = which_ceedling.dup()
@path_validator.standardize_paths( ceedling_path )
if !@file_wrapper.directory?( ceedling_path )
raise "Configured Ceedling launch path #{ceedling_path}/ does not exist"
end

# Update installation paths
app_cfg.set_paths( ceedling_path )
# Update Ceedling installation paths
app_cfg.set_paths( ceedling_path )

# Check updated Ceedling paths
if !@file_wrapper.exist?( app_cfg[:ceedling_rakefile_filepath] )
raise "Configured Ceedling launch path #{ceedling_path}/ contains no Ceedling installation"
end

# Update variable to full application start path
ceedling_path = app_cfg[:ceedling_rakefile_filepath]

@streaminator.stream_puts( " > Launching Ceedling from #{ceedling_path}/", Verbosity::OBNOXIOUS )

return ceedling_path
return :path, ceedling_path
end


def load_ceedling(config:, which:, default_tasks:[])
# Load Ceedling from the gem
if (which == :gem)
require( 'ceedling' )
# Load Ceedling from a path
else
ceedling_path = File.join( File.expand_path( which ), 'lib/ceedling.rb' )
if !@file_wrapper.exist?( ceedling_path )
raise "Configured Ceedling launch path #{which}/ contains no Ceedling installation"
end

require( ceedling_path )
end

def load_ceedling(config:, rakefile_path:, default_tasks:[])
# Set default tasks
Rake::Task.define_task(:default => default_tasks) if !default_tasks.empty?

# Load Ceedling
Ceedling.load_rakefile()
# Load Ceedling application from Rakefile path
require( rakefile_path )

# Loading the Rakefile manipulates the config hash, return it as a convenience
return config
Expand Down Expand Up @@ -358,12 +355,11 @@ def copy_docs(ceedling_root, dest)

def vendor_tools(ceedling_root, dest)
vendor_path = File.join( dest, 'vendor', 'ceedling' )
assets_path = File.join( ceedling_root, 'assets' )

# Copy folders from current Ceedling into project
%w{plugins lib bin}.each do |folder|
@actions._directory(
File.join( ceedling_root, folder ),
folder,
File.join( vendor_path, folder ),
:force => true
)
Expand All @@ -385,7 +381,7 @@ def vendor_tools(ceedling_root, dest)

# Copy necessary subcomponent dirs into project
components.each do |path|
_src = File.join( ceedling_root, path )
_src = path
_dest = File.join( vendor_path, path )
@actions._directory( _src, _dest, :force => true )
end
Expand Down Expand Up @@ -421,15 +417,15 @@ def vendor_tools(ceedling_root, dest)
if windows?
# Windows command prompt launch script
@actions._copy_file(
File.join( assets_path, 'ceedling.cmd'),
File.join( 'assets', 'ceedling.cmd'),
File.join( dest, 'ceedling.cmd'),
:force => true
)
else
# Unix shell launch script
launch = File.join( dest, 'ceedling')
@actions._copy_file(
File.join( assets_path, 'ceedling'),
File.join( 'assets', 'ceedling'),
launch,
:force => true
)
Expand Down
Empty file modified bin/configinator.rb
100755 → 100644
Empty file.
Empty file modified bin/mixinator.rb
100755 → 100644
Empty file.
Empty file modified bin/objects.yml
100755 → 100644
Empty file.
Empty file modified bin/path_validator.rb
100755 → 100644
Empty file.
Empty file modified bin/projectinator.rb
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions ceedling.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ Ceedling projects are created with a YAML configuration file. A variety of conve
s.files += Dir['vendor/unity/auto/**/*.rb']
s.files += Dir['vendor/unity/src/**/*.[ch]']

s.files += Dir['**/*']
s.test_files = Dir['test/**/*', 'spec/**/*', 'features/**/*']
s.executables = ['ceedling'] # bin/ceedling
s.files += Dir['**/*']
s.test_files = Dir['test/**/*', 'spec/**/*', 'features/**/*']
s.executables = ['ceedling'] # bin/ceedling

s.require_paths = ["lib", "vendor/cmock/lib"]
end
Loading

0 comments on commit 097912c

Please sign in to comment.