mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-26 14:34:15 +01:00
Add checks for unsafe configurations
* Fixes #929 * Updated `ci.yml` to define `GITHUB_CI` * Compilation will now error if VSELECT is enabled on hardware versions that don't support it (any version other than HW5). * HW4 and SERIAL might work but are untested. The error message for these versions reflects this. * Erroring when unsafe configurations are defined can be overridden by defining `ALLOW_UNSAFE_CONFIG` which will throw a warning instead. * This should only be done if trying to implement or test on a currently unsupported platform. * If both `GITHUB_CI` and `ALLOW_UNSAFE_CONFIG` are defined an error will be thrown causing the CI tests to fail. This is just in case someone makes a commit with it defined.
This commit is contained in:
parent
740c2698bc
commit
2b01f7fc4d
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -47,4 +47,4 @@ jobs:
|
|||||||
cd Cart_Reader/
|
cd Cart_Reader/
|
||||||
# Select hardware version by uncommenting it (using regular expression)
|
# Select hardware version by uncommenting it (using regular expression)
|
||||||
sed -i 's/^\/\/[\t ]*#define ${{ matrix.hwVersion }}/#define ${{ matrix.hwVersion }}/g' Config.h
|
sed -i 's/^\/\/[\t ]*#define ${{ matrix.hwVersion }}/#define ${{ matrix.hwVersion }}/g' Config.h
|
||||||
arduino-cli compile --fqbn arduino:avr:mega --warnings all
|
arduino-cli compile --fqbn arduino:avr:mega --warnings all --build-property compiler.cpp.extra_flags="-DGITHUB_CI"
|
||||||
|
@ -19,10 +19,54 @@
|
|||||||
# error !!! PLEASE CHOOSE HARDWARE VERSION IN CONFIG.H !!!
|
# error !!! PLEASE CHOOSE HARDWARE VERSION IN CONFIG.H !!!
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
// Let user know unsafe configs are allowed
|
||||||
|
# if defined(ALLOW_UNSAFE_CONFIG)
|
||||||
|
// Error if defined during GitHub CI tests. This should not happen unless someone accidentally committed their Config.h
|
||||||
|
# if defined(GITHUB_CI)
|
||||||
|
# error !! UNSAFE CONFIGURATIONS ARE ALLOWED !! -- This should not be enabled on the repository!
|
||||||
|
# else /* !defined(GITHUB_CI) */
|
||||||
|
# warning !! UNSAFE CONFIGURATIONS ARE ALLOWED !! -- Unless you are a developer this probably is not something you want set.
|
||||||
|
# endif /* GITHUB_CI */
|
||||||
|
# endif /* ALLOW_UNSAFE_CONFIG */
|
||||||
|
|
||||||
# if defined(ENABLE_3V3FIX) && !defined(ENABLE_VSELECT)
|
# if defined(ENABLE_3V3FIX) && !defined(ENABLE_VSELECT)
|
||||||
# warning Using 3V3FIX is best with VSELECT.
|
# warning Using 3V3FIX is best with VSELECT.
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if defined(ENABLE_VSELECT)
|
||||||
|
|
||||||
|
// Error if not a supported hardware version
|
||||||
|
# if !(defined(HW4) || defined(HW5) || defined(SERIAL_MONITOR))
|
||||||
|
# if defined(ALLOW_UNSAFE_CONFIG)
|
||||||
|
# warning Using VSELECT with hardware revisions other than 4 or 5 is not supported.
|
||||||
|
# else /* !defined(ALLOW_UNSAFE_CONFIG) */
|
||||||
|
# error Using VSELECT with hardware revisions other than 4 or 5 is not supported. \
|
||||||
|
If you understand what you are doing you can define ALLOW_UNSAFE_CONFIG in Config.h to allow compiling.
|
||||||
|
# endif /* ALLOW_UNSAFE_CONFIG */
|
||||||
|
# endif /* !(HW4 | HW5 | SERIAL_MONITOR) */
|
||||||
|
|
||||||
|
// HW4 might work but needs tested. Make sure they know it's untested.
|
||||||
|
# if defined(HW4)
|
||||||
|
# if defined(ALLOW_UNSAFE_CONFIG)
|
||||||
|
# warning Using VSELECT with HW4 is untested. Verification with a multimeter before use is strongly recommended. Please remember to report back with your findings.
|
||||||
|
# else /* !defined(ALLOW_UNSAFE_CONFIG) */
|
||||||
|
# error Using VSELECT with HW4 is untested. Verification with a multimeter before use is strongly recommended. \
|
||||||
|
Define ALLOW_UNSAFE_CONFIG in Config.h to allow compiling. Please report back with your findings after testing!
|
||||||
|
# endif /* ALLOW_UNSAFE_CONFIG */
|
||||||
|
# endif /* HW4 */
|
||||||
|
|
||||||
|
// SERIAL might work but needs tested. Make sure they know it's untested.
|
||||||
|
# if defined(SERIAL_MONITOR)
|
||||||
|
# if defined(ALLOW_UNSAFE_CONFIG)
|
||||||
|
# warning Using VSELECT with a serial-only OSCR is untested. Verification with a multimeter before use is strongly recommended. Please remember to report back with your findings.
|
||||||
|
# else /* !defined(ALLOW_UNSAFE_CONFIG) */
|
||||||
|
# error Using VSELECT with a serial-only OSCR is untested. Verification with a multimeter before use is strongly recommended. \
|
||||||
|
Define ALLOW_UNSAFE_CONFIG in Config.h to allow compiling. Please report back with your findings after testing!
|
||||||
|
# endif /* ALLOW_UNSAFE_CONFIG */
|
||||||
|
# endif /* SERIAL_MONITOR */
|
||||||
|
|
||||||
|
# endif /* ENABLE_VSELECT */
|
||||||
|
|
||||||
/*==== CONSTANTS ==================================================*/
|
/*==== CONSTANTS ==================================================*/
|
||||||
/**
|
/**
|
||||||
* String Constants
|
* String Constants
|
||||||
|
Loading…
Reference in New Issue
Block a user