Mbed-cli: Compiler paths should come from environment variables

Created on 9 May 2016  路  10Comments  路  Source: ARMmbed/mbed-cli

Currently the compiler paths are defined by hardcoding them into mbed_settings.py. Unfortunately this means re-creating or a keeping a local copy of this file and copying into any new application/module that you create. It would make more sense to require the user to define specific environment variables for the compilers which are then just read from the python script.

enhancement

Most helpful comment

I'm sorry I think I was confusing with my ordering, let me rearrange. 1 is now the highest priority and 3 is the lowest:

  1. Use the compilers overridden by environment variables:
    MBED_ARM_PATH=... MBED_GCC_ARM_PATH=... MBED_IAR_PATH=...
  2. Use the compilers specified in mbed_settings.py
  3. Default to using compilers in the PATH if no settings file specified.

    • This is not the current behavior, the default paths are in the settings.py file

So if you start a new project, you don't have specific environment variables set, and you don't have an mbed_settings.py, it will search in the PATH to find the compilers.

If you then add an mbed_settings.py file, it will use these settings. If it can't find the compiler at the path you specified in the file, it will fallback to searching the PATH variable

If you then set an environment variable for the compiler, it will try to use that. If it can't find the compiler there, it will fallback to mbed_settings.py if it exists, then fallback to searching the PATH variable.

All 10 comments

I think it makes sense to implement a hierarchy here (listed here from lowest to highest priority):

  1. Default to using compilers in the PATH if no settings file specified.

    • This is not the current behavior, the default paths are in the settings.py file

  2. Use the compilers specified in mbed_settings.py
  3. Use the compilers overridden by environment variables:
    MBED_ARM_PATH=... MBED_GCC_ARM_PATH=... MBED_IAR_PATH=...

I think I would order it as:

1 Use the PATH

  1. Use specific environment variables if they exist
  2. Use mbed_settings.py
  3. Use default_settings.py

There is even an argument to making the environment variables the first choice as these would have to have been specifically set which would imply conscious decision to override other options

I'm sorry I think I was confusing with my ordering, let me rearrange. 1 is now the highest priority and 3 is the lowest:

  1. Use the compilers overridden by environment variables:
    MBED_ARM_PATH=... MBED_GCC_ARM_PATH=... MBED_IAR_PATH=...
  2. Use the compilers specified in mbed_settings.py
  3. Default to using compilers in the PATH if no settings file specified.

    • This is not the current behavior, the default paths are in the settings.py file

So if you start a new project, you don't have specific environment variables set, and you don't have an mbed_settings.py, it will search in the PATH to find the compilers.

If you then add an mbed_settings.py file, it will use these settings. If it can't find the compiler at the path you specified in the file, it will fallback to searching the PATH variable

If you then set an environment variable for the compiler, it will try to use that. If it can't find the compiler there, it will fallback to mbed_settings.py if it exists, then fallback to searching the PATH variable.

My rationale behind this is it gives the most priority to the settings that are the most deliberately set.

  • PATH is lowest because this is often set upon compiler installation (usually not controlled by the user)
  • mbed_settings.py is the next highest because this can be set at a project level, but you usually don't want to change it once its been set, even across sessions and logins
  • Environment variables can be changed after every command, so these should take the highest priority.

This makes the most sense to me, but I'm open to other options :)

That sounds good to me

@bridadan isn't this against the tools? mbed CLI does nothing special for make.py/build.py?

@screamerbg You're right, this discussion is related to mbed tools, not mbed-cli. Would you like @adbridge or me to take the conclusion from this thread over to the other repo?

@bridadan yes, that would be more clean to track.

Created an issue on mbed-os: https://github.com/ARMmbed/mbed-os/issues/125

Closing the issue here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevew817 picture stevew817  路  7Comments

sg- picture sg-  路  8Comments

bremoran picture bremoran  路  4Comments

masoudr picture masoudr  路  3Comments

wdwalker picture wdwalker  路  10Comments