ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
586 stars 246 forks source link

Issues compiling with Ceedling for AVR target #209

Open twilco opened 7 years ago

twilco commented 7 years ago

Running Windows 10 targeting an ATMega328p and having issues compiling basic tests for AVR - it won't seem to use avr-gcc over gcc, no matter what I change. I have avr-gcc installed and available on the command line. I installed WinAVR and avrdude as well.

What am I doing wrong?

Here's my terminal output:

PS C:\Users\Tyler\projects\rc-car> ceedling

Test 'test_general_util.c'
--------------------------
In file included from test/test_general_util.c:2:0:
src/util/general_util.h:8:20: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
                    ^
compilation terminated.
ERROR: Shell command failed.
> Shell executed command:
'gcc.exe -E -I"test" -I"test/built" -I"test/support" -I"src" -I"src/constants" -I"src/protocols" -I"src/remotes" -I"src/types" -I"src/util" -I"C:/Users/Tyler/projects/rc-car/vendor
/ceedling/vendor/unity/src" -I"C:/Users/Tyler/projects/rc-car/vendor/ceedling/vendor/cmock/src" -I"test/built/test/mocks" -DTEST -DTEST -DGNU_COMPILER "test/test_general_util.c" -o
 "test/built/test/preprocess/files/test_general_util.c"'
> And exited with status: [1].

rake aborted!
ShellExecutionException: ShellExecutionException
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/tool_executor.rb:78:in `exec'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/preprocessinator_file_handler.rb:12:in `preprocess_file'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/preprocessinator.rb:40:in `preprocess_file'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/preprocessinator.rb:12:in `block in setup'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/preprocessinator_helper.rb:33:in `preprocess_test_file'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/preprocessinator.rb:25:in `preprocess_test_and_invoke_test_mocks'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/test_invoker.rb:73:in `block in setup_and_invoke'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/test_invoker.rb:63:in `setup_and_invoke'
C:/Users/Tyler/projects/rc-car/vendor/ceedling/lib/ceedling/tasks_tests.rake:11:in `block (2 levels) in <top (required)>'
C:/Ruby24-x64/bin/ceedling:22:in `load'
C:/Ruby24-x64/bin/ceedling:22:in `<main>'
Tasks: TOP => default => test:all
(See full trace by running task with --trace)
ERROR: Ceedling Failed

project.yml

---
:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: test/built
  :test_file_prefix: test_
  :which_ceedling: vendor/ceedling
  :default_tasks:
    - test:all

:environment:
  - :mcu: atmega328p
  - :f_cpu: 16000000UL
  - :objcopy: avr-objcopy
  - :path:
    - C:\MinGW64\bin
    - C:\WinAVR-20100110\bin
    - C:\WinAVR-20100110\utils\bin
    - #{ENV['PATH']}

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support

:defines:
  :commmon: &common_defines []
  :test:
    - *common_defines
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8

:gcov:
    :html_report_type: basic

:compiler:
  :executable: avr-gcc
  :arguments:
    - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE               #expands to -I search paths
    - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR   #expands to -I search paths
    - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR  #expands to all -D defined symbols
    - --network-license             #simple command line argument
    - -optimize-level 4             #simple command line argument
    - "#{`args.exe -m acme.prj`}"   #in-line ruby sub to shell out & build string of arguments
    - -c ${1}                       #source code input file (Ruby method call param list sub)
    - -o ${2}                       #object file output (Ruby method call param list sub)

:libraries:
  :placement: :end
  :flag: "${1}"  # or "-L ${1}" for example
  :common: &common_libraries []
  :test:
    - *common_libraries
  :release:
    - *common_libraries

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
...

Also tried using this block in place of the :compiler: section:

:tools:
  :test_compiler:
     :executable: avr-gcc             #exists in system search path
     :name: 'avr-gcc'
     :arguments:
        - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE               #expands to -I search paths
        - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR   #expands to -I search paths
        - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR  #expands to all -D defined symbols
        - --network-license             #simple command line argument
        - -optimize-level 4             #simple command line argument
        - "#{`args.exe -m acme.prj`}"   #in-line ruby sub to shell out & build string of arguments
        - -c ${1}                       #source code input file (Ruby method call param list sub)
        - -o ${2}                       #object file output (Ruby method call param list sub)
  :test_linker:
     :executable: C:/WinAVR-20100110\bin    #absolute file path
     :name: 'this probably isn't the right thing but I have no idea what to put here either...'
     :arguments:
        - ${1}               #list of object files to link (Ruby method call param list sub)
        - -l$-lib:           #inline yaml array substitution to link in foo-lib and bar-lib
           - foo
           - bar
        - -o ${2}            #executable file output (Ruby method call param list sub)
Letme commented 7 years ago

Compiling tests or release?

I would skip name, but for sure you should use a

:tools:
  :compiler:
     :executable: avr-gcc
  :test_compiler:
     :executable: avr-gcc