Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Conversation

@MrPointer
Copy link
Member

This is a somewhat large PR, including many changes, mostly internal (Thus called refactoring).

However, it allows affects some public APIs:

  • There's no more need to pass the library_root_directory as an argument to the add_arduino_library function - The new code infers it automatically from passed sources.
  • Sources passed to libraries through the add_arduino_library API, as well as the header-only API - Are no longer suffering from the Unable to use more than one source file in a program #26 bug that affected program/executable targets.
    Moreover, it's perfectly valid to pass options and single-value options to these functions, such as LIB_PROPS_FILE that hints the path to the library's properties file (This is not necessary).
    This is possible thanks to a new argument-parsing mechanism implemented to parse what's considered "unlimited" arguments, or in this case sources.

The framework has been further "modulerized", but it doesn't affect the public API.

Most of the changes occurred originally in the 'header-only-lib' branch, but are moved here since they don't belong there.
It also came with a cost of requiring the library's root directory in the `add_library` API.
It failed when there were no included headers found, so a matching guard-check has been added.
# Conflicts:
#	cmake/Platform/Targets/ArduinoCMakeLibraryTarget.cmake
#	cmake/Platform/Targets/ArduinoLibraryTarget.cmake
#	examples/3rd-party-library/CMakeLists.txt
#	examples/3rd-party-library/NeoPixelTest.cpp
Also modified `add_arduino_header_only_library` API to accept unlimited source files (headers) as unparsed arguments, as is done with the 'Executable' API.
Separated target architecture definition to a function under the 'TargetFlagsManager' module.
Updated code across all framework to use this function.
It allows functions to accept practically unlimited sources (or any other arbitrary value) as long as any reserved arguments/options aren't encountered.
When at least one is encountered, processing stops and the already-parsed arguments are returned.
The `add_arduino_library` function has been updated to use this function in order to remove the inconvenient 'library_root_dir' argument it used to accept. As such, updated all other code using this API.
Everything related to the library properties file is now passed using the 'LIB_PROPS_FILE' optional argument.
Also added utility function to get a library's properties file based on a given root directory - It simply appends the properties file name (which is now stored as a default cache variable) and checks for existence before returning.
… now 1st.

Updated usages accordingly.
Also updated the `link_library_flags` function to use the scope parsing function, it was somehow missed until now.
…rsing "unlimited" arguments, such as sources.
@MrPointer MrPointer merged commit 67307b6 into develop Sep 26, 2018
@MrPointer MrPointer deleted the feature/lib-refactor branch September 26, 2018 13:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants