[[:start|На главную]], [[:instruments:instrumentarij|Инструментарий]] ---- ====== Настройка Keil uVision для работы с Git ====== {{tag>инструментарий Git Keil uVision}} :!: Страница в **РАЗРАБОТКЕ**! Если вы видите, что можно добавить или изменить, добавляйте без сомнения! :!: Эта заметка написана на основе [[http://www.keil.com/appnotes/docs/apnt_279.asp|Application Note 279: "Using Git for Project Management with uVision"]]. (Можно считать ее вольным переводом "близко к тексту") Все, о чем пойдет речь, проверялось на [[http://y64.info/tbdev/browse.php?search=Keil+RealView+Microcontroller+Development+Kit+v4.72a&incldead=0&cat=0|Keil RealView Microcontroller Development Kit v4.72a]] ===== Предисловие ===== В настоящее время, командная работа стала основной в области разработок для микроконтроллеров. Часто команды, работающие над проектом, являются распределенными географически и в разных часовых поясах. Синхронизация процесса разработки является основной задачей руководителей проектов. Т.к. эта задача не может эффективно решаться с использованием, например, пересылки рабочих файлов по электронной почте, в таких случаях используются [[https://ru.wikipedia.org/wiki/%D0%A1%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D1%83%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F_%D0%B2%D0%B5%D1%80%D1%81%D0%B8%D1%8F%D0%BC%D0%B8|Системы Контроля Версий]] - Software [[https://en.wikipedia.org/wiki/Revision_control|Version Control Systems]] (SVCS). Раньше были популярны централизованные системы Concurrent Versions System ([[https://en.wikipedia.org/wiki/Concurrent_Versions_System|CVS]]) and Subversion ([[https://en.wikipedia.org/wiki/Subversion_(software)|SVN]]) использующие инфраструктуру с центральным выделенным сервером. В настоящее время, все большую популярность набирают распределенные системы контроля версий. Одна из них называется [[https://en.wikipedia.org/wiki/Git_%28software%29|Git]]. В этой заметке описано как интегрировать Git в µVision и как организовать процесс разработки ПО с помощью этой VCS. ===== Введение ===== Revision control is being used for a couple of years now in software development. In the past, centralized server infrastructures have been used to track the changes in the source code of a microcontroller development project. With the release of Git, decentralized VCS have become more and more popular. Git, which is free software distributed under the terms of the GNU General Public License, was developed for maintaining the Linux kernel. It became more and more popular and is now the de-facto standard in source control management (SCM), another term for VCS. This application note assumes that you have installed Git on your PC (refer to [[instruments:git:setup_keil_uvision_for_work_with_git#Appendix A: Software|Appendix A: Software]]) and do know how to use the Windows command shell (cmd.exe). ===== Workflows ===== Using Git, you can make use of various workflows when maintaining a software project: * Centralized workflow as known to users of CVS and SVN * Feature Branch workflow that adds a branch for every feature that is to be developed to the master branch * Gitflow workflow using specific roles to different branches such as develop, feature, and release branch * Forking workflow that is a truly distributed workflow in the sense that every developer has his own fork of the master branch and only one project maintainer is accepting commits to the master branch This application note explains how to use µVision in a centralized workflow environment. Other workflows can be realized as well using a mix of Git commands from within µVision and using the command line/GUI. For more information on workflows, see [[instruments:git:setup_keil_uvision_for_work_with_git#Appendix B: Links|Appendix B: Links]]. ==== Centralized Workflow ==== In a centralized work environment, there is usually a single collaboration model: the centralized workflow. A central repository accepts code changes, and every developer synchronizes his work to it. This is just like using SVN for example. However, using Git has a few advantages over the traditional SVN workflow. First, it gives every developer an own local copy of the entire project. In this local environment, each developer can work independently of all other colleagues. The local repository is used for commits and they can completely forget about the original one until it's convenient for them. Second, all developers can use Git’s robust branching and merging model. Git branches are designed to be failsafe when adding code and sharing changes between repositories. The centralized workflow uses a central repository serving as the entry point for all project changes. The default development branch is called ‘master’ and all changes are committed into this branch. No other branches are required by this workflow: - [[instruments:git:setup_keil_uvision_for_work_with_git#Initialize the Central Repository|Initialize the central repository]] - [[instruments:git:setup_keil_uvision_for_work_with_git#Clone a Repository from a Server|Clone a Repository from a Server]] - [[instruments:git:setup_keil_uvision_for_work_with_git#Feature Work|Feature work (stage/commit/push)]] - [[instruments:git:setup_keil_uvision_for_work_with_git#Manage Conflicts|Manage Conflicts]] ===== Using Git with µVision ===== ==== Project Files under Version Control ==== Before setting up the workflow, the project manager should be absolutely clear about the files that need to be version controlled. Of course all source code files need to be versioned, but there are a couple of files that are special to µVision that need to be monitored as well. * All user generated source files (*.c, *.cpp, *.h, *.inc, *.s) * Project file: //Project//.uvprojx (is used to build the project from scratch) * Project options file: //Project//.uvoptx (contains information about the debugger and trace configuration) * Project file for multi-project workspaces: //Project//.uvmpw * Configuration files for the run-time environment that are copied to the project (all files below .\RTE) * List of #includes created by software components: RTE\RTE_Components.h file * Device configuration file: for example RTE\Device\LPC1857\RTE_Device.h * Linker control file (//Project//.sct) if created manually * All relevant Pack files (for example ARM::CMSIS, Keil::Middleware, Device Family Packs, etc.) ==== Files that do not need to be monitored ==== * Project screen layout file: //Project//.uvguix.//username// * All files that are part of a Pack (the complete Pack will be revision controlled and is available to every user as soon as he is installing it using Pack Installer) * Generated output files in the sub-directories .\Listings and .\Objects * INI files for debug adapters ==== Configure µVision’s SVCS ==== Before using Git for SCM, you need to configure µVision’s software version control menu. µVision 5.15 is providing a SVCS template file for Git. It resides in the installation directory (for example C:\Keil_v5\UV4) and is called GIT.SVCS. For versions previous to 5.15, please use the file as it is provided in this [[http://www.keil.com/download/files/apnt_279.zip|application note’s ZIP]] file and copy it to the µVision installation directory. Или скачать его у нас: {{:instruments:git:git.svcs.rar|}} - Open µVision and go to **SVCS -> Configure Software Version Control…** - Enter the path to the template file: \\ {{:instruments:git:git_keil.png?300|}} - When done, press **OK**. Now, µVision is ready to use Git as the version control system. === Accessing µVision Project Files === When working with the SVCS menu, you can usually access files that are highlighted in the Project window of µVision. For example, if you are clicking on the File Blinky.c in the Project window and you then go to the **SVCS** menu, you will see the SVCS options for the Blinky.c file: \\ {{ :instruments:git:git_keil_2.png?300|}} {{:instruments:git:git_keil_1.png?300}} To catch µVision’s project related files (uvmpw, uvprojx, uvoptx), click on the following (or equivalent): * WorkSpace -> uvmpw * Project -> uvprojx * Target 1 -> uvoptx ==== Version Control of Software Packs ==== ===== Centralized Workflow Example ===== ==== Initialize the Central Repository ==== ==== Clone a Repository from a Server ==== ==== Feature Work ==== ==== Manage Conflicts ==== ===== Conclusion ===== ===== Appendix A: Software ===== To be able to use Git on a Windows PC and from within µVision, you need to install the following software: * Git for Windows: [[https://msysgit.github.io/]] * For MDK versions below 5.15, you need to add the µVision SVCS template file for Git which is part of this application note’s ZIP file: [[http://www.keil.com/appnotes/docs/apnt_279.asp|www.keil.com/appnotes/docs/apnt_279.asp]] Please copy the file to the µVision installation directory, for example C:\Keil_v5\UV4 ===== Appendix B: Links ===== * Git: http://git-scm.com * Git Book: http://git-scm.com/book/en/v2 * Git server space providers: https://github.com/, https://bitbucket.org, https://about.gitlab.com/ * Possible Workflows: www.atlassian.com/git/tutorials/comparing-workflows * Migrate from SVN to Git: www.atlassian.com/git/tutorials/migrating-overview * More information on Git replacing LF with CRLF: http://tinyurl.com/q3y7ohx ---- [[:start|На главную]], [[:instruments:instrumentarij|Инструментарий]] ~~DISCUSSION~~