Skip to content

Commit

Permalink
Moved loading of vendored DIY to bin/
Browse files Browse the repository at this point in the history
Proper handling of vendored gems and covers edge cases for gem installation scenarios
  • Loading branch information
mkarlesky committed Apr 10, 2024
1 parent a635450 commit 98ec1b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bin/ceedling
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ CEEDLING_ROOT = File.expand_path( File.join( File.dirname( __FILE__ ), ".."
CEEDLING_BIN = File.join( CEEDLING_ROOT, 'bin' )
CEEDLING_LIB_BASE = File.join( CEEDLING_ROOT, 'lib' )
CEEDLING_LIB = File.join( CEEDLING_LIB_BASE, 'ceedling' )
CEEDLING_VENDOR = File.join( CEEDLING_ROOT, 'vendor' )

# Add load path for `require 'ceedling/*'` statements + bin/ DIY
# Add load path for `require 'ceedling/*'` statements and bin/ code
$LOAD_PATH.unshift( CEEDLING_BIN, CEEDLING_LIB_BASE )

# Load "bootloader" / command line handling in bin/
Expand Down
17 changes: 11 additions & 6 deletions bin/main.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'cli'
require 'diy'
require 'constructor'
require 'app_cfg'
require 'cli' # Located alongside this file in CEEDLING_BIN
require 'constructor' # Assumed installed via Ceedling gem dependencies
require 'app_cfg' # Located alongside this file in CEEDLING_BIN

CEEDLING_APPCFG = get_app_cfg()

Expand All @@ -10,11 +9,17 @@
begin
# Construct all bootloader objects
# 1. Add full path to $LOAD_PATH to simplify objects.yml
# 2. Perform object construction + dependency injection from bin/objects.yml
# 3. Remove paths from $LOAD_PATH
# 2. Add vendored DIY to $LOAD_PATH so we can use it
# 3. Require DIY (used by Ceedling application too)
# 4. Perform object construction + dependency injection from bin/objects.yml
# 5. Remove unneeded / potentially problematic paths from $LOAD_PATH
$LOAD_PATH.unshift( CEEDLING_LIB )
$LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'diy/lib') )

require 'diy'
objects = DIY::Context.from_yaml( File.read( File.join( CEEDLING_BIN, 'objects.yml' ) ) )
objects.build_everything()

$LOAD_PATH.delete( CEEDLING_BIN ) # Loaded in top-level `ceedling` script
$LOAD_PATH.delete( CEEDLING_LIB )

Expand Down
4 changes: 0 additions & 4 deletions lib/ceedling/rakefile.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require 'fileutils'

# CEEDLING_ROOT defined at startup
CEEDLING_VENDOR = File.join(CEEDLING_ROOT, 'vendor')

$LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'unity/auto') )
$LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'diy/lib') )
$LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'cmock/lib') )

require 'rake'
Expand Down

0 comments on commit 98ec1b9

Please sign in to comment.