ARMmbed / mbed-cli

Arm Mbed Command Line Interface
https://os.mbed.com
Apache License 2.0
333 stars 176 forks source link

Suggestion: allow use of git submodules for libraries #622

Closed drewcassidy closed 6 years ago

drewcassidy commented 6 years ago

Supporting the use of git submodules could help with the use of mbed with libraries, since it would show an easy link to the submodule repository at the referenced commit, and would remove the clutter of the .lib files that mbed uses currently. .lib files would be kept for backwards compatability and use with other SCMs.

currently, attempting to use git submodules in addition to the .lib files causes mbed to throw errors about not being able to find a valid repository

theotherjimmy commented 6 years ago

@drewcassidy Are you just suggesting that we pass the --recursive option to clone? If so, I think that would be a reasonable change.

theotherjimmy commented 6 years ago

@screamerbg Do you have thoughts on this?

drewcassidy commented 6 years ago

@drewcassidy Are you just suggesting that we pass the --recursive option to clone? If so, I think that would be a reasonable change.

that, plus allowing submodules in place of the folder + .lib files. currently mbed throws errors when both are present, and without the .lib files it wont update. running commands like mbed update should also call the appropriate git submodule commands

0Grit commented 6 years ago

@screamerbg I believe using submodules was another reason our projects were exploding

screamerbg commented 6 years ago

@drewcassidy @loverdeg-ep A core Mbed CLI requirement is support Mercurial and Git, and potentially other SCMs. Mbed CLI has to handle these seamlessly, regardless of how they are used, including use cases where SCMs are mixed in a code tree - e.g. a program on os.mbed.com uses Mercurial, pulls in Mercurial libraries, but also uses Mbed OS from github.

Git does support submodules, and it comes with some advantages and disadvantages:

Pros:

Cons:

For the reasons above we took the design choice to use unified handling sub-repositories between Mercurial and Git (and other repos in the future) via .lib files that contain all the needed information to reproduce a code tree, and also add certain options and help/tips to recover from a scenario when a sub-repository has been modified or destroyed.

Is it possible to use Mbed CLI .lib references and git submodules? Absolutely. You have ensure the following:

Basically, it's all about synchronizing both git's submodule handling and Mbed CLI dependency handling (via .lib files) before introducing new changes.

Let me know if this doesn't cover your use case.

drewcassidy commented 6 years ago

Ah, thank you for the explanation! It would be nice if that was a bit more automated in the CLI tools, but thats probably a problem for another issue

theotherjimmy commented 6 years ago

@drewcassidy I take it that this issue can be closed then? Is there something else that needs to be done here?

screamerbg commented 6 years ago

@drewcassidy I think that we should explain this better in the documentation. Including working with submodules as library references in parallel