Skip to content

Commit

Permalink
Merge branch 'test/1_0_0/dependencies_plugin_improvements' into test/…
Browse files Browse the repository at this point in the history
…ceedling_0_32_rc
  • Loading branch information
mkarlesky committed May 31, 2024
2 parents 8cab697 + b1df526 commit a06c3c2
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 115 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
cd ../..
# Run Dependencies Plugin Tests
- name: Run Tests on Dependency Plugin
- name: Run Tests on Dependencies Plugin
run: |
cd plugins/dependencies
rake
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
cd ../..
# Run Dependencies Plugin Tests
- name: Run Tests on Dependency Plugin
- name: Run Tests on Dependencies Plugin
run: |
cd plugins/dependencies
rake
Expand Down
4 changes: 2 additions & 2 deletions assets/project_as_gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
:load_paths: []
:enabled:
#- beep # beeps when finished, so you don't waste time waiting for ceedling
- module_generator # handy for quickly creating source, header, and test templates
- module_generator # handy for quickly creating source, header, and test templates
#- gcov # test coverage using gcov. Requires gcc, gcov, and a coverage analyzer like gcovr
#- bullseye # test coverage using bullseye. Requires bullseye for your platform
#- command_hooks # write custom actions to be called at different points during the build process
#- compile_commands_json_db # generate a compile_commands.json file
#- compile_commands_json_db # generate a compile_commands.json file
#- dependencies # automatically fetch 3rd party libraries, etc.
#- subprojects # managing builds and test for static libraries
#- fake_function_framework # use FFF instead of CMock
Expand Down
24 changes: 10 additions & 14 deletions bin/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,18 @@ def process_stopwatch(tasks:, default_tasks:)


def print_rake_tasks()
Rake.application.standard_exception_handling do
# (This required digging into Rake internals a bit.)
Rake.application.define_singleton_method(:name=) {|n| @name = n}
Rake.application.name = 'ceedling'
Rake.application.options.show_tasks = :tasks
Rake.application.options.show_task_pattern = /^(?!.*build).*$/
Rake.application.display_tasks_and_comments()
end
# (This required digging into Rake internals a bit.)
Rake.application.define_singleton_method(:name=) {|n| @name = n}
Rake.application.name = 'ceedling'
Rake.application.options.show_tasks = :tasks
Rake.application.options.show_task_pattern = /^(?!.*build).*$/
Rake.application.display_tasks_and_comments()
end


def run_rake_tasks(tasks)
Rake.application.standard_exception_handling do
Rake.application.collect_command_line_tasks( tasks )
Rake.application.top_level()
end
Rake.application.collect_command_line_tasks( tasks )
Rake.application.top_level()
end


Expand Down Expand Up @@ -401,10 +397,10 @@ def vendor_tools(ceedling_root, dest)
'vendor/unity',
'vendor/cmock',
'vendor/c_exception',
'vendor/diy'
].each do |src|
# Look up licenses using a Glob as capitalization can be inconsistent
glob = File.join( ceedling_root, src, 'license.txt' )

# Look up licenses (use glob as capitalization can be inconsistent)
listing = @file_wrapper.directory_listing( glob ) # Already case-insensitive

# Safety check on nil references since we explicitly reference first element
Expand Down
14 changes: 5 additions & 9 deletions lib/ceedling/system_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def time_now(format=nil)
return Time.now.strftime( format )
end

# If set, `boom` allows a non-zero exit code in results.
# Otherwise, disabled `boom` forces a success exit code but collects errors.
def shell_capture3(command:, boom:false)
# Beginning with later versions of Ruby2, simple exit codes were replaced
# by the more capable and robust Process::Status.
Expand All @@ -70,16 +72,10 @@ def shell_capture3(command:, boom:false)
stdout, stderr = '' # Safe initialization defaults
status = nil # Safe initialization default

begin
# Run the command but absorb any exceptions and capture error info instead
stdout, stderr, status = Open3.capture3( command )
rescue => err
stderr = err.to_s
exit_code = nil
end
stdout, stderr, status = Open3.capture3( command )

# If boom, then capture the actual exit code, otherwise leave it as zero
# as though execution succeeded
# If boom, then capture the actual exit code.
# Otherwise, leave it as zero as though execution succeeded.
exit_code = status.exitstatus.freeze if boom and !status.nil?

# (Re)set the global system exit code so everything matches
Expand Down
15 changes: 10 additions & 5 deletions lib/ceedling/tool_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def validate_executable(tool:, name:, extension:, respect_optional:, boom:)
exists = false
error = ''

executable = tool[:executable]
# Get unfrozen copy so we can modify for our processing
executable = tool[:executable].dup()

# Handle a missing :executable
if (executable.nil? or executable.empty?)
Expand Down Expand Up @@ -88,15 +89,15 @@ def validate_executable(tool:, name:, extension:, respect_optional:, boom:)
end

# Construct end of error message
error = "does not exist in system search paths." if not exists
error = "does not exist in system search paths" if not exists

# If there is a path included, check that explicit filepath exists
else
if @file_wrapper.exist?( executable )
exists = true
else
# Construct end of error message
error = "does not exist on disk." if not exists
error = "does not exist on disk" if not exists
end
end

Expand All @@ -121,10 +122,14 @@ def validate_stderr_redirect(tool:, name:, boom:)
error = ''
redirect = tool[:stderr_redirect]

# If no redirect set at all, it's cool
return if redirect.nil?

# Otherwise, process the redirect that's been set
if redirect.class == Symbol
if not StdErrRedirect.constants.map{|constant| constant.to_s}.include?( redirect.to_s.upcase )
options = StdErrRedirect.constants.map{|constant| ':' + constant.to_s.downcase}.join(', ')
error = "#{name} ↳ :stderr_redirect => :#{redirect} is not a recognized option {#{options}}."
error = "#{name} ↳ :stderr_redirect => :#{redirect} is not a recognized option {#{options}}"

# Raise exception if requested
raise CeedlingException.new( error ) if boom
Expand All @@ -134,7 +139,7 @@ def validate_stderr_redirect(tool:, name:, boom:)
return false
end
elsif redirect.class != String
raise CeedlingException.new( "#{name} ↳ :stderr_redirect is neither a recognized value nor custom string." )
raise CeedlingException.new( "#{name} ↳ :stderr_redirect is neither a recognized value nor custom string" )
end

return true
Expand Down
9 changes: 6 additions & 3 deletions plugins/beep/lib/beep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def post_build
command = @ceedling[:tool_executor].build_command_line(
@tools[:beep_on_done],
[],
["ceedling build done"]) # Only used by tools with `${1}` replacement argument
# Only used by tools with `${1}` replacement argument
'ceedling build done'
)


# Verbosity is enabled to allow shell output (primarily for sake of the bell character)
Expand All @@ -72,8 +74,9 @@ def post_error
command = @ceedling[:tool_executor].build_command_line(
@tools[:beep_on_error],
[],
["ceedling build error"]) # Only used by tools with `${1}` replacement argument

# Only used by tools with `${1}` replacement argument
'ceedling build error'
)

# Verbosity is enabled to allow shell output (primarily for sake of the bell character)
@ceedling[:system_wrapper].shell_system( command: command[:line], verbose: true )
Expand Down
54 changes: 33 additions & 21 deletions plugins/dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ containing header files that might want to be included by your release project.

So how does all this magic work?

First, you need to add the `:dependencies` plugin to your list. Then, we'll add a new
section called :dependencies. There, you can list as many dependencies as you desire. Each
has a series of fields which help Ceedling to understand your needs. Many of them are
optional. If you don't need that feature, just don't include it! In the end, it'll look
something like this:
First, you need to add the Dependencies plugin to your list of enabled plugins. Then, we'll
add a new comfiguration section called `:dependencies`. There, you can list as many
dependencies as you desire. Each has a series of fields that help Ceedling to understand
your needs. Many of them are optional. If you don't need that feature, just don't include
it! In the end, it'll look something like this:

```yaml
:plugins:
:enabled:
- dependencies

```
:dependencies:
:libraries:
:deps:
- :name: WolfSSL
:paths:
:fetch: third_party/wolfssl/source
Expand Down Expand Up @@ -116,11 +120,11 @@ couple of fields:
- `:git` -- This tells Ceedling that we want to clone a git repo to our source path.
- `:svn` -- This tells Ceedling that we want to checkout a subversion repo to our source path.
- `:custom` -- This tells Ceedling that we want to use a custom command or commands to fetch the code.
- `:source` -- This is the path or url to fetch code when using the zip, gzip or git method.
- `:tag`/`:branch` -- This is the specific tag or branch that you wish to retrieve (git only. optional).
- `:hash` -- This is the specific SHA1 hash you want to fetch (git only. optional, requires a deep clone).
- `:revision` -- This is the specific revision you want to fetch (svn only. optional).
- `:executable` -- This is a list of commands to execute when using the `:custom` method
- `:source` -- This is the path or url to fetch code when using the `:zip`, `:gzip` or `:git` method.
- `:tag`/`:branch` -- This is the specific tag or branch that you wish to retrieve (`:git` only, optional).
- `:hash` -- This is the specific SHA1 hash you want to fetch (`:git` only, optional and triggers a deep clone).
- `:revision` -- This is the specific revision you want to fetch (`:svn` only, optional).
- `:executable` -- This is a YAML list of commands to execute when using the `:custom` method

Some notes:

Expand All @@ -131,16 +135,24 @@ Environment Variables
---------------------

Many build systems support customization through environment variables. By specifying
an array of environment variables, Ceedling will customize the shell environment before
calling the build process.
an array of environment variables, the Dependencies plugin will customize the shell environment
before calling the build process.

Note that Ceedling’s project configuration includes a top-level `:environment` sections itself.
The top-level `:environment` section is for all of Ceedling. The `:environment` section nested
within a specific dependency’s configuration is only for the shell environment used to process
that dependency. The format and abilities of the two `:environment` configuration sections are
also different.

Environment variables may be specified in three ways. Let's look at one of each:

```
:environment:
- ARCHITECTURE=ARM9
- CFLAGS+=-DADD_AWESOMENESS
- CFLAGS-=-DWASTE
```yaml
:dependencies:
<a dependency configuration>:
:environment:
- ARCHITECTURE=ARM9
- CFLAGS+=-DADD_AWESOMENESS
- CFLAGS-=-DWASTE
```

In the first example, you see the most straightforward method. The environment variable
Expand Down Expand Up @@ -260,7 +272,7 @@ Custom Tools

You can optionally specify a compiler, assembler, and linker, just as you would a release build:

```
```yaml
:tools:
:deps_compiler:
:executable: gcc
Expand All @@ -282,7 +294,7 @@ Then, once created, you can reference these tools in your build steps by using t
of a series of strings to explain all the steps. Ceedling will understand that it should build all the specified
source and/or assembly files into the specified library:

```
```yaml
:dependencies:
:deps:
- :name: CaptainCrunch
Expand Down
55 changes: 53 additions & 2 deletions plugins/dependencies/config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,68 @@

:tools:
:deps_compiler:
:executable: gcc
:executable: gcc
:name: 'Dependencies compiler'
:arguments:
- -g
- -I"$": COLLECTION_PATHS_DEPS
- -D$: COLLECTION_DEFINES_DEPS
- -c "${1}"
- -o "${2}"
:deps_linker:

:deps_linker:
:executable: ar
:name: 'Dependencies archiver'
:arguments:
- rcs
- ${2}
- ${1}

:deps_zip:
:executable: unzip
:name: 'Dependencies zip unarchiver'
:optional: true
:arguments:
- -o
- ${1} # Filepath

:deps_targzip:
:executable: tar
:name: 'Dependencies tar gzip unarchiver'
:optional: true
:arguments:
- -xvzf
- ${1} # Filepath
- -C
- ./

:deps_git_clone:
:executable: git
:name: 'Dependencies git clone'
:optional: true
:arguments:
- clone
- ${1} # Optional branch with `-b` flag
- ${2} # Optional depth with `--depth` flag
- ${3} # Repository source
- .

:deps_git_checkout:
:executable: git
:name: 'Dependencies git checkout'
:optional: true
:arguments:
- checkout
- ${1} # Git hash

:deps_subversion:
:executable: svn
:name: 'Dependencies subversion'
:optional: true
:arguments:
- checkout
- ${1} # Optional branch with `--revision` flag
- ${2} # Repository source
- .

...
Loading

0 comments on commit a06c3c2

Please sign in to comment.