📜 ⬆️ ⬇️

How to embrace the immensity: the .NET Micro Framework build system Part 2

enter image description here


We continue the series of articles devoted to the .Net Micro Framework assembly system. The concept of "Project Build System" always appears in projects, the scale and complexity of which outgrow the standard types available in the IDE . And if it is assumed that the project will be created in several environments or is not tied to any development environment at all, then it will simply be impossible to do without a project building system. A vivid example of such projects is the .Net Micro Framework - the implementation of the Microsoft .NET platform for microcontrollers.


The last article was a review of his build system and its implementation features. Before moving on and exploring the components of the distribution, you need to get acquainted with the tools to do this. This article will review the PKStudio program, which allows you to conveniently explore the components and relationships within the .Net Micro Framework distribution, as well as other interesting features.


PKStuio is the result of .NetMF research over a year long. The program was written by my colleague Igor Kiselev and me in the process of studying the internal structure of the distribution. The goal was to learn how to create .NetMF "ports" for different boards. Documentation for this exists , but it is not very helpful.


At first, PKStudio could only visualize MSBuild components and their connections. But over time, it developed and turned into an IDE that allows you to compile "ports", explore the contents of the distribution, convert "ports" into projects for uVisuon Keil and much more. The program was written back in 2011 for the .NetMF 4.2 version, but even now it has not lost its relevance for version 4.4


What is PKStudio


Anyone who has tried to find out what is inside the .Net Micro Framework knows that this is not for the faint of heart. An interesting and promising technology has many complex internal relationships. In the process of analyzing the repository, an IDE was born that can significantly simplify the process of learning. It is able to visually display components and allows you to collect "ports" from the totality of these components.


In general, the display component looks like this:
enter image description here


By studying the components of the repository, you can move from such abstract concepts as Features and Library Categories to libraries (Library) and source files:
enter image description here


It is possible to build a "port" and find errors in the code, if any:
enter image description here


One of the most important functions is the construction of component dependency graphs:
enter image description here


She allows to see how the separate code gathers together.


Well, another important feature is the converter to Keil uVision projects. It allows you to create a project file for this IDE, which will contain all the necessary sources:
enter image description here


enter image description here


Screenshots of all the functions of PKStudio can be viewed here .


How to build and run PKStudio


PKStudio has many links to the .Net Micro Framework Interpreter. Therefore, before using it, you need to follow a few steps.


Carefully read all the points before you perform them.


  1. Install Visual Studio 2015 (Community, Pro or Ultimate edition)
  2. Download the PKStudio source code any way you want
  3. Download the .Net Micro Framework Interpreter repository. For example, in this way. In addition, various methods for obtaining the .NetMF repository are described here and here .
  4. IMPORTANT: the Netmf-interpreter repository directory and the PKStudio repository directory must have a common parent directory! For example, if you have a D: \ repos folder, then the netmf-interpreter repository will be located in D: \ repos \ netmf-interpreter and PKStudio in D: \ repos \ PKStudio folder
  5. Download binary tools zip file. It contains the executable files needed to build the netmf-interpreter.
  6. Unzip the contents to the parent repository folder. For the example above, the bin and tools directory will be located in the D: \ repos \ folder ( D: \ repos \ bin and D: \ repos \ tools )

Next, you need to build part of the .Net Micro Framework Interpreter repository to get some necessary DLL files.


  1. Open a command prompt and go to the directory containing the .Net Micro Framework Interpreter (for example, cd / d D: \ WORKDIR \ GitHub \ netmf-interpreter )
  2. Set the required environment variables by running the setenv_vs.cmd file
  3. Change to the .Net Micro Framework Interpreter Framework \ Tools directory (for example, cd / d D: \ WORKDIR \ GitHub \ netmf-interpreter \ Framework \ Tools )
  4. Start the build process by running the msbuild BuildTasks.sln / p command : flavor = debug

If everything was done correctly, the assembly will be successfully completed and you can find the file Microsoft.SPOT.Tasks.Internal.dll in the folder BuildOutput \ public \ Debug \ Server \ dll .


Now you can open the project PKStudio. But you need to do this with the same environment variables that are set for the .Net Micro Framework Interpreter.
To do this, in the same command line where the environment variables were set, you need to start Visual Studio 2015 by running devenv.exe (for example, "C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ devenv.exe "together with quotes)


When Visua Studio 2015 is launched, you can open, build and run PKStudio.


For further work it is no longer necessary to repeat all the steps. It is important to understand only that to compile or run PKStudio you need to set environment variables. Therefore, if you want to change something in the source code, you will need to run Visual Studio from the command line with the environment variables set (as indicated above). And if you just need to start PKStudio, then from the command line you can immediately run pkstudio.exe .


What you can see with PKStudio


So, the .NetMF repository consists of several types of components. First of all, it is Features - the components that combine the basic functions of the "port". Features "depend" on Library Caterories — sets of libraries that implement particular parts of the Feature . Library Category can be implemented by one or several Library - libraries containing the source code itself. Moreover, in theory, the Library performs the same functionality, but for different cases. For example, for different processors. It seems everything is simple and logical, but for some reason such connections are not always followed for all components.


PKStudio allows you to generate diagrams that help you understand the nuances of the relationships between components.


The diagram below shows the disclosure of links for the Featue Debugger :


enter image description here


It's all good, except that the two Library Categories do not have implementations in the form of a Library .


Here is the connectivity diagram for Features Hardware and Core


enter image description here


You can see that Core is implemented directly by several Libraries without a Library Category .


In addition to generating diagrams, PKStudio can display the components of the repository in the form of a tree structure and their properties.


Features :
enter image description here


Library Categories :
enter image description here


Libraries :
enter image description here


In addition, the repository contains other types of components.


Assemblies :
enter image description here


Processors :
enter image description here


And of course the "ports" called Solutions . They are a combination of the above components:


enter image description here


Conclusion


In addition to what is described above, PKStudio still has a search by components, verification of the connections between them, a project converter in Keil uVision, the ability to compile a Solution , etc. But they will be discussed at another time.


PKStudio is a great tool for exploring the .NetMF repository. However, it is far from perfect. Therefore, if you encounter any problems while working with it, write comments and create issues on GitHub.


We will deal with .NetMF and improve PKStudio together!


')

Source: https://habr.com/ru/post/395847/


All Articles