Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Integrated various fixes and improvements to comply with refactored version #23

Merged
merged 12 commits into from
Dec 1, 2017

Conversation

MrPointer
Copy link
Member

Bug Fixes

Most of the bugs fixed in this PR are @noseglasses's fixes introduced in #17 and #19.
To integrate his changes, which were made directly on the master branch, a few things changed:

Library Blacklist

The cached variable holding the list of blacklisted libraries is created during the initialization.

6-digit SDK version

Aimed to solve a scenario where the arduino compiler's ARDUINO flag must be assigned a 6-digit version (major.minor.patch), redundant code has been discovered.
Instead of validating SDK's version and returning it in a normalized form in every call to the set_board_flags function, the version could be simply normalized by concatenating the version's artifacts, which are major, minor and patch. One little thing though: Those weren't properly set at the initialization level, when the SDK's version was set. Solving this bug allowed to simply read those cached variable to create a normalized version. This change doesn't affect others, for your concern @noseglasses .

Register Custom Hardware Platform

As pointed by @noseglasses in #19, the only platform that could be registered was the Arduino platform having the avr architecture.
Since the refactored version supports the script-driven model, a function that supports custom platform parameters couldn't be implemented, yet it could be integrated into its' own script.
A separate script named RegisterSpecificHardwarePlatform.cmake was created, and it does the same as the proposed register_hardware_platform_bva function should've done.
To resolve the custom parameters, users should declare variables BEFORE including the Arduino-CMake toolchain file in their script. The possible variables are:

  • PLATFORM_PATH - Full path to the hardware platform's directory. Defaults to Arduino's.
  • PLATFORM_ARCHITECTURE - Platform's architecture ID, Defaults to avr.

Features

Added SDK Version Revision

@noseglasses suggested to treat SDK version as a 6-digit number, while using the word revision in his description. In an effort to integrate his changes, I misunderstood his true meaning of the word revision, as he simply meant patch, yet added a feature to actually parse the version revision.
This is done in the initialization stage, in the version-detecting script.
The revisions.txt file is read to parse the revision that matches the current version (detected earlier), which currently is just a release date. This revision is later stored in cache.

Added Ability to Use Custom Platform Registration Scripts

To make the platform registration process completely extensive, a variable named CUSTOM_PLATFORM_REGISTRATION_SCRIPT can be set BEFORE including the Arduino-CMake toolchain file. This variable should hold a path to a script used to register a hardware platform somehow.

noseglasses and others added 11 commits November 18, 2017 16:17
…lusion.

Solution was to remove duplicates if those exist.
Also set recurse libraries to have a custom-defined default value - Up till now is has been always 'False', but this change allows users to set the 'ARDUINO_CMAKE_RECURSION_DEFAULT' variable to 'True'. It's possible since this variable is stored in CMake's cache.
…on search.

Those libraries are constantly removed in the 'find_arudino_libraries' function.
Solution was to change the return variable of the '_remove_blacklisted_libraries' function, as it was incorrect and always returned an empty string.
Added feature to detect SDK's revision (Currently represented as a date) by reading the 'revisions.txt' file and parsing the revision that matches the current version from it.
Stored revision in cache.
…mpty.

Solution was to set their cached variables the variables holding the split artifacts instead of themselves.
For example: ARDUINO_SDK_VERSION_MAJOR has been assigned itself before existing, thus resulting in an empty string. Instead, set it to SPLIT_VERSION_MAJOR, which currently resolves to "1".
…ables.

Up to this commit every call to the 'set_flags' function would result in validating the SDK's version, then extracting it's artifacts to form a normalized version - This is no longer needed due to the bug fix in the last commit, where the artifacts are properly stored in cache.
It's more a bug-fix combined with a feature, since the function to register a platform simply been inlined, defaulting 'Arduino' and 'avr' as platform and architecture.
This commit allows developers to specify their own platform and architecture by setting the `PLATFORM_PATH` and `PLATFORM_ARCHITECTURE` variables BEFORE including the Arduino-CMake toolchain.
This commit complements the last one, allowing even further customization to the platform-registration process.
…e/refactoring-extra

# Conflicts:
#	cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake
@fraillt
Copy link

fraillt commented Nov 26, 2017

Nice to see a lot of improvements, but i have some questions and observations regarding these changes.

  1. _get_normalized_sdk_version is not accurate. I was working on this too, and in my observations there was 3 different formats throughout -DARDUINO history.
    Here is my implementation, i tested it with various arduino IDE versions to compare my results, so please use my implementation.
function(_get_arduino_version_define OUTPUT_VAR)

    if (ARDUINO_SDK_VERSION MATCHES "([0-9]+)[.]([0-9]+)")
        if (ARDUINO_SDK_VERSION VERSION_GREATER 1.5.8)
            # since 1.6.0 -DARDUINO format changed, e.g for 1.6.5 version -DARDUINO=10605
            set(ARDUINO_VERSION_DEFINE "${ARDUINO_SDK_VERSION_MAJOR}0${ARDUINO_SDK_VERSION_MINOR}0${ARDUINO_SDK_VERSION_PATCH}")
        else()
            #before 1.0.0 version use only minor version for define, e.g. for 0020 version -DARDUINO=20
            if (ARDUINO_SDK_VERSION VERSION_LESS 1.0.0)
                set(ARDUINO_VERSION_DEFINE "${ARDUINO_SDK_VERSION_MINOR}")
            else()
                #for 1.0.0 and above format changed, e.g. for 1.5.3 version -DARDUINO=153
                set(ARDUINO_VERSION_DEFINE "${ARDUINO_SDK_VERSION_MAJOR}${ARDUINO_SDK_VERSION_MINOR}${ARDUINO_SDK_VERSION_PATCH}")
            endif()
        endif()
    else ()
        message(WARNING "Invalid Arduino SDK Version (${ARDUINO_SDK_VERSION})")
    endif ()
    set(${OUTPUT_VAR} ${ARDUINO_VERSION_DEFINE} PARENT_SCOPE)
endfunction()
  1. Can you explain the purpose of ARDUINO_SDK_VERSION_REVISION ? it doesn't seem to be used anywhere.

  2. Regarding library blacklist.
    I think we should talk about this more.
    Although this solves @noseglasses's problem for his Kaleidoscope keyboard project, but I think it shows that current design has a lot of problems.
    I was looking at current implementation and it is mind-blowing how complex and error prone it is.

Although this blacklisting thing solves the problem, I really hate solution like these, because it is not a feature but rather a workaround for real problem.

I think it would be wise to remove this magic of auto-discovering arduino libraries by scanning files, or improve its implementation.
This project is for those who are serious on arduino development, and in my case i have multiple header files for single project, and I have to be extra careful that some arduino library would not be automatically included.

I think this auto-discovery feature only useful for arduino examples, that doesn't have local includes, only libraries.
What do you think? do you have issues with it as well, or it is just me and @noseglasses ?

@noseglasses
Copy link
Collaborator

I do hate workaround solutions like blacklisting libraries, too. On the other hand, I am working on aproject that is supposed to build with arduino-builder and Arduino-CMake. That's why I find the dependency autodetection very useful.

I will report back as soon as I find time to test the redesign. Thank's for the great work so far.

One more thing: Wouldn't it be usefull to inform all those github users that have forked quezy's Arduino-CMake about the redesign? GitHub provides information about the fork history. It be great to catch as many forks as possible to join their work?

@MrPointer
Copy link
Member Author

@fraillt Thanks for your feedback and code contribution, I will make this change before completing this PR.
I've stated in the description that the revision has been added by accident, but I've decided to keep it since it doesn't hurt anybody and may come in handy in the future. If it seems completely unnecessary by the entire dev team, I'll remove it.

@noseglasses I agree with both of you about the complexity of the current solution, and that automatic library detection should be at least covered with a flag to disable it.

…c versions.

The '_get_normalized_sdk_version' function of the `FlagsSetter` has been improved to return different results, depending on the current SDK version, as the '-DARDUINO' flag intended to use it has different accepted formats over the versions.
Also renamed '_get_board_property_if_exists' function to '_try_get_board_property' as a convention.
@MrPointer MrPointer merged commit 8a81916 into feature/refactoring Dec 1, 2017
@MrPointer MrPointer deleted the feature/refactoring-extra branch December 1, 2017 12:25
@MrPointer MrPointer mentioned this pull request Dec 9, 2017
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.

3 participants