diff --git a/.github/workflows/projmgr.yml b/.github/workflows/projmgr.yml new file mode 100644 index 000000000..b0929f054 --- /dev/null +++ b/.github/workflows/projmgr.yml @@ -0,0 +1,262 @@ +name: projmgr +on: + pull_request: + paths: + - '.github/workflows/projmgr.yml' + - 'CMakeLists.txt' + - 'libs/crossplatform/**' + - 'libs/rtefsutils/**' + - 'libs/xmlreader/**' + - 'libs/xmltree/**' + - 'libs/xmltreeslim/**' + - 'tools/projmgr/**' + release: + types: [published] + +jobs: + build: + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/projmgr/')) }} + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + strategy: + fail-fast: true + matrix: + os: [ macos-10.15, ubuntu-20.04, windows-2019 ] + include: + - os: macos-10.15 + target: darwin64 + binary: projmgr + - os: ubuntu-20.04 + target: linux64 + binary: projmgr + - os: windows-2019 + target: windows64 + binary: projmgr.exe + + steps: + - name: Install macos deps + if: ${{ startsWith(matrix.os, 'macos') }} + run: | + brew install \ + ninja \ + python \ + swig + + - name: Install linux deps + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt update + sudo apt-get install \ + bc \ + build-essential \ + ninja-build \ + python-dev \ + swig + + - name: Install windows deps + if: ${{ startsWith(matrix.os, 'windows') }} + run: choco install -y ninja python swig + + - name: Checkout devtools + uses: actions/checkout@v2 + with: + submodules: true + + - name: Create build folders + run: | + mkdir build + mkdir buildswig + + - name: Configure windows build for amd64 + if: ${{ startsWith(matrix.os, 'windows') }} + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - uses: ammaraskar/gcc-problem-matcher@master + if: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }} + - uses: ammaraskar/msvc-problem-matcher@master + if: ${{ startsWith(matrix.os, 'windows') }} + + - name: Build projmgr + run: | + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. + cmake --build . --target projmgr + working-directory: ./build + + - name: Archive projmgr + uses: actions/upload-artifact@v2 + with: + name: projmgr-${{ matrix.target }} + path: ./build/tools/projmgr/${{ matrix.target }}/Release/${{ matrix.binary }} + retention-days: 1 + if-no-files-found: error + + - name: Build projmgr swig libs + run: | + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DSWIG_LIBS=ON .. + cmake --build . --target projmgr --config Release + working-directory: ./buildswig + + - name: Archive projmgr swig libs windows + if: ${{ startsWith(matrix.os, 'windows') }} + uses: actions/upload-artifact@v2 + with: + name: projmgr-swig-${{ matrix.target }} + path: | + ./buildswig/tools/projmgr/swig/projmgr.py + ./buildswig/tools/projmgr/swig/_projmgr.pyd + retention-days: 1 + + - name: Archive projmgr swig libs macos ubuntu + if: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }} + uses: actions/upload-artifact@v2 + with: + name: projmgr-swig-${{ matrix.target }} + path: | + ./buildswig/tools/projmgr/swig/projmgr.py + ./buildswig/tools/projmgr/swig/_projmgr.so + retention-days: 1 + + release: + if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/projmgr/') }} + needs: [ build, unittest ] + runs-on: ubuntu-20.04 + timeout-minutes: 15 + + steps: + - name: Checkout devtools + uses: actions/checkout@v2 + + - name: Create distribution folders + run: | + mkdir -p tools/projmgr/distribution/bin tools/projmgr/distribution/lib tools/projmgr/distribution/doc + cp tools/projmgr/docs/LICENSE.txt tools/projmgr/distribution/ + cp tools/projmgr/docs/README.md tools/projmgr/distribution/doc/ + + - name: Download projmgr linux + uses: actions/download-artifact@v2 + with: + name: projmgr-linux64 + path: tools/projmgr/distribution/bin/linux64/ + + - name: Download projmgr macos + uses: actions/download-artifact@v2 + with: + name: projmgr-darwin64 + path: tools/projmgr/distribution/bin/darwin64/ + + - name: Download projmgr windows + uses: actions/download-artifact@v2 + with: + name: projmgr-windows64 + path: tools/projmgr/distribution/bin/windows64/ + + - name: Download projmgr-swig linux + uses: actions/download-artifact@v2 + with: + name: projmgr-swig-linux64 + path: tools/projmgr/distribution/lib/linux64/ + + - name: Download projmgr-swig macos + uses: actions/download-artifact@v2 + with: + name: projmgr-swig-darwin64 + path: tools/projmgr/distribution/lib/darwin64/ + + - name: Download projmgr-swig windows + uses: actions/download-artifact@v2 + with: + name: projmgr-swig-windows64 + path: tools/projmgr/distribution/lib/windows64/ + + - name: Zip distribution folder + run: zip -r projmgr.zip * + working-directory: tools/projmgr/distribution + + - name: Attach zip archive to release assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: tools/projmgr/distribution/projmgr.zip + tag: ${{ github.ref }} + overwrite: true + asset_name: projmgr.zip + + unittest: + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/projmgr/')) }} + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + strategy: + fail-fast: true + matrix: + os: [ macos-10.15, ubuntu-20.04, windows-2019 ] + include: + - os: macos-10.15 + target: darwin64 + - os: ubuntu-20.04 + target: linux64 + - os: windows-2019 + target: windows64 + + steps: + - name: Install macos deps + if: ${{ startsWith(matrix.os, 'macos') }} + run: | + brew install \ + ninja + + - name: Install linux deps + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt update + sudo apt-get install \ + bc \ + build-essential \ + ninja-build + + - name: Install windows deps + if: ${{ startsWith(matrix.os, 'windows') }} + run: choco install -y ninja + + - name: Checkout devtools + uses: actions/checkout@v2 + with: + submodules: true + + - name: Create build folder + run: mkdir build + + - name: Configure windows build for amd64 + if: ${{ startsWith(matrix.os, 'windows') }} + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - uses: ammaraskar/gcc-problem-matcher@master + if: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }} + - uses: ammaraskar/msvc-problem-matcher@master + if: ${{ startsWith(matrix.os, 'windows') }} + + - name: Build and run projmgr unit tests + run: | + cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug .. + cmake --build . --target ProjMgrUnitTests + ctest -C Debug -R ProjMgrUnitTests + working-directory: ./build + + - name: Archive unit tests results + uses: actions/upload-artifact@v2 + with: + name: unittest-${{ matrix.target }} + path: ./build/Testing/Temporary/LastTest.log + retention-days: 1 + if-no-files-found: error + if: ${{ always() }} + + - name: Publish projmgr unit test results + uses: mikepenz/action-junit-report@v2 + with: + check_name: "projmgr unit tests [${{ matrix.target }}]" + report_paths: build/projmgr_unit_test_report.xml + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9d1e8c57..68e9b03b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,7 @@ repos: (?x)^( tools/buildmgr/test/testinput/| tools/packgen/test/data/| + tools/projmgr/test/data/| libs/crossplatform/include/win| tools/buildmgr/cbuildgen/include/Resource.h| libs/crossplatform/test/src/TestProg.cpp) diff --git a/CMakeLists.txt b/CMakeLists.txt index 366ea0197..1a470423c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ cmake_policy(SET CMP0091 NEW) option(COVERAGE "Enable code coverage" OFF) option(LIBS_ONLY "Build only libraries" OFF) +option(SWIG_LIBS "Build SWIG libraries" OFF) if(LIBS_ONLY) message("LIBS_ONLY is active. Build only libraries") @@ -37,6 +38,10 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall") endif() +if(SWIG_LIBS) + message("SWIG_LIBS is active. Build SWIG libraries") + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif(SWIG_LIBS) if(COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") @@ -78,6 +83,7 @@ add_subdirectory(libs/xmltreeslim) if(NOT LIBS_ONLY) add_subdirectory(tools/buildmgr) add_subdirectory(tools/packgen) + add_subdirectory(tools/projmgr) endif() # Google Test Framework diff --git a/tools/buildmgr/cbuild/include/CbuildLayer.h b/tools/buildmgr/cbuild/include/CbuildLayer.h index be5f44268..050575b90 100644 --- a/tools/buildmgr/cbuild/include/CbuildLayer.h +++ b/tools/buildmgr/cbuild/include/CbuildLayer.h @@ -87,7 +87,7 @@ class CbuildLayer { * @param saveBackup if true save the original file with extension '.bak' * @return true if xml file is written successfully, otherwise false */ - bool WriteXmlFile(const std::string &file, XMLTree* tree, const bool saveBackup=false); + static bool WriteXmlFile(const std::string &file, XMLTree* tree, const bool saveBackup=false); /** * @brief initialize header (tool and timestamp) information diff --git a/tools/projmgr/CMakeLists.txt b/tools/projmgr/CMakeLists.txt new file mode 100644 index 000000000..2678f49ca --- /dev/null +++ b/tools/projmgr/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.14) + +include(DumpCMakeProjectVersion) +include(ProjectVersionFromGitTag) +get_version_from_git_tag("tools/projmgr/") + +project(ProjMgr VERSION "${PROJECT_VERSION}") +dump_cmake_project_version() + +configure_file(src/ProductInfo.h.in ProductInfo.h) + +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT projmgr) + +# projmgr library +SET(PROJMGR_SOURCE_FILES ProjMgr.cpp ProjMgrKernel.cpp ProjMgrCallback.cpp) +SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h) + +list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/) +list(TRANSFORM PROJMGR_HEADER_FILES PREPEND include/) + +add_library(projmgrlib OBJECT ${PROJMGR_SOURCE_FILES} ${PROJMGR_HEADER_FILES}) +target_link_libraries(projmgrlib PUBLIC CrossPlatform RteFsUtils RteUtils XmlTree XmlTreeSlim XmlReader RteModel cbuild cxxopts yaml-cpp) +target_include_directories(projmgrlib PRIVATE include ${PROJECT_BINARY_DIR}) + +if(SWIG_LIBS) + # projmgr swig + add_subdirectory(swig) +else() + # projmgr target + add_executable(projmgr src/ProjMgrMain.cpp include/ProjMgr.h) + if(MSVC) + target_link_options(projmgr PUBLIC "$<$:/SAFESEH:NO>") + endif(MSVC) + set_property(TARGET projmgr PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + target_link_libraries(projmgr projmgrlib) + target_include_directories(projmgr PRIVATE include) +endif() + +# projmgr test +enable_testing() +add_subdirectory(test) diff --git a/tools/projmgr/bin/README.md b/tools/projmgr/bin/README.md new file mode 100644 index 000000000..2227f17d1 --- /dev/null +++ b/tools/projmgr/bin/README.md @@ -0,0 +1,2 @@ +Temporary binaries can be found in the following release page: +https://github.com/brondani/devtools/releases/tag/tools%2Fprojmgr%2F0.9.0 \ No newline at end of file diff --git a/tools/projmgr/docs/LICENSE.txt b/tools/projmgr/docs/LICENSE.txt new file mode 100644 index 000000000..9ab72f76a --- /dev/null +++ b/tools/projmgr/docs/LICENSE.txt @@ -0,0 +1,842 @@ +The software is provided under Apache 2.0 license (below). +No contributions to cmsis-build are accepted at this point. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Other Projects: +================ +The installer redistributes and installs GNU Make v4.2 for Windows 64-bit +when installed on Windows (.../bin/make.exe) +Name: GNU Make v4.2 +Summary: GNU Make is a tool which controls the generation of executables + and other non-source files of a program from the program's source + files. +Home-page: https://www.gnu.org/software/make/ +License(s): GNU General Public License v3.0 only (GPL-3.0-only). See later + section for a copy of license text. +Copyright(s): Refer to Source(s): https://ftp.gnu.org/gnu/make/ + +License text (GPL-3.0-only) for 'GNU Make' + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS +================================================================================ diff --git a/tools/projmgr/docs/Manual/Overview.md b/tools/projmgr/docs/Manual/Overview.md new file mode 100644 index 000000000..81f6c04af --- /dev/null +++ b/tools/projmgr/docs/Manual/Overview.md @@ -0,0 +1,1308 @@ +# CMSIS Project Manager + +The **[Open-CMSIS-Pack](https://www.open-cmsis-pack.org/index.html) Project Manager** processes **User Input Files** (in YML format) and **Software Packs** (in Open-CMSIS-Pack format) to create self-contained CMSIS-Build input files that allow to generate independent projects which may be a part of a more complex application. + +The **CMSIS Project Manager** supports the user with the following features: + +- Access to the content of software packs in Open-CMSIS-Pack format to: + - Setup the tool chain based on a *Device* or *Board* that is defined in the CMSIS-Packs. + - Add software components that are provided in the various software packs to the application. +- Organize applications (with a `*.csolution.yml` file) into projects that are independently managed (using `*.cproject.yml` files). +- Manage the resources (memory, peripherals, and user defined) across the entire application to: + - Partition the resources of the system and create related system and linker configuration. + - Support in the configuration of software stacks (such as RTOS threads). + - Hint the user for inclusion of software layers that are pre-configured for typical use cases. +- Organize software layers (with a `*.clayer.yml` file) that enable code reuse across similar applications. +- Manage multiple hardware targets to allow application deployment to different hardware (test board, production hardware, etc.). +- Manage multiple build types to support software verification (debug build, test build, release build, ect.) +- Support multiple compiler toolchains (GCC, LLVM, Arm Compiler 6, IAR, etc.) for project deployment. + +Manual Chapters | Content +:------------------|:------------------------- +Usage | Overall Concept, tool setup, invocation commands, and naming conventions. +YML Input Format | Format of the various input files. + +## Revision History + +Version | Description +:------------------|:------------------------- +Draft | Work in progress + + +# Usage + +The **CMSIS Project Manager** is a command line utility that is available for different operating systems. + +## Overview of Operation + +![Overview](./images/Overview.png "Overview") + +This picture above outlines the operation. The **CMSIS Project Manager** uses the following files. + +Input Files | Used for.... +:------------------------|:--------------------------------- +[Generic Software Packs](https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/cp_PackTutorial.html#cp_SWComponents) | ... provide re-usable software components that are typically configurable towards a user application. +[DFP Software Packs](https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/cp_PackTutorial.html#createPack_DFP) | ... device related information on the tool configuration. May refer an *.rzone file. +[BSP Software Packs](https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/cp_PackTutorial.html#createPackBoard) | ... board specific configuration (i.e. memory). May refer to an *.rzone file that defines board components. +[*.rzone files](https://arm-software.github.io/CMSIS_5/Zone/html/xml_rzone_pg.html) | ... definition of memory and peripheral resources. If it does not exist, content is created from DFP. +*.csettings.yml | ... [1.] setup of an environment (could be an IDE) to pre-define a toolchain or built-types (Debug, Release). +*.csolution.yml | ... [2.] complete scope of the application and the build order of sub-projects. +*.cproject.yml | ... [3.] content of an independent build (linker run) - directly relates to a *.cprj file. +*.clayer.yml | ... [4.] set of source files along with pre-configured components for reuse in different applications. + +**Note**: The values [*n.*] indicate the order of processing of the user input files. + +Output Files | Used for.... +:------------------------|:--------------------------------- +[Project Build Files](https://arm-software.github.io/CMSIS_5/Build/html/cprjFormat_pg.html) | ... project build information for a Open-CMSIS-Pack based tool environment. +Run-Time Environment (RTE) | ... contains the user configured files of a project along with RTE_Components.h inventory file. +[Project Resource Files *.fzone](https://arm-software.github.io/CMSIS_5/Zone/html/GenDataModel.html) | ... resource and partition data structure for template based code generators. + +## Requirements + +The CMSIS Pack repository must be present in the development environment. + +- There are several ways to initialize and configure the pack repository, for example using the +`cpackget` tool available from https://github.com/Open-CMSIS-Pack/cpackget +- Before running `projmgr` the location of the pack repository shall be set via the environment variable +`CMSIS_PACK_ROOT` otherwise its default location (todo what is the default?) will be taken. + +## Usage + +```text +CMSIS Project Manager 0.0.0+gdd33bca (C) 2021 ARM +Usage: + projmgr [] [OPTIONS...] + +Commands: + list packs Print list of installed packs + devices Print list of available device names + components Print list of available components + dependencies Print list of unresolved project dependencies + contexts Print list of contexts in a csolution.yml + convert Convert cproject.yml or csolution.yml in cprj files + help Print usage + +Options: + -p, --project arg Input cproject.yml file + -s, --solution arg Input csolution.yml file + -f, --filter arg Filter words + -o, --output arg Output directory + -h, --help Print usage +``` + +### Commands + +Print list of installed packs. The list can be filtered by words provided with the option `--filter`: + +```text +list packs [--filter ""] +``` + +Print list of available device names. The list can be filtered by words provided with the option `--filter`: + +```text +list devices [--filter ""] +``` + +Print list of available components. The list can be filtered by a selected device in the `cproject.yml` file with the option `--input` and/or by words provided with the option `--filter`: + +```text +list components [--p --filter ""] +``` +todo: this does not work anymore + +Print list of unresolved project dependencies. The device and components selection must be provided in the `cproject.yml` file with the option `--input`. The list can be filtered by words provided with the option `--filter`: + +```text +list dependencies --input [--filter ""] +``` + +Convert cproject.yml in cprj file: + +```text +convert --p +``` + +# Project Examples + +## Minimal Project Setup + +Simple applications require just one self-contained file. + +**Simple Project: `Sample.cproject.yml`** + +```yml +project: + compiler: AC6 # Use Arm Compiler 6 for this project + device: LPC55S69JEV98:cm33_core0 # Device name (exact name as defined in the DFP) optional with Pname for core selection + + optimize: size # Code optimization: emphasis code size + debug: on # Enable debug symbols + + groups: # Define file groups of the project + - group: My files + files: # Add source files + - file: main.c + + - group: HAL + files: + - file: ./hal/driver1.c + + components: # Add software components + - component: Device:Startup +``` + +## Software Layers + +Software layers collect source files and software components along with configuration files for re-use in different projects. +The following diagram shows the various layers that are used to compose the IoT Cloud examples. + +![Software Layers](./images/Layer.png "Target and Build Types") + +The following example is a `Blinky` application that uses a `App`, `Board`, and `RTOS` layer to compose the application for a NUCELO-G474RE board. Note, that the `device:` definition is is the `Board` layer. + +**Example Project: `Blinky.cproject.yml`** + +```yml +project: + compiler: AC6 + + layers: + - layer: .\Layer\App\Blinky.clayer.yml + - layer: .\Layer\RTOS\RTX.clayer.yml + - layer: .\Layer\Board\Nucleo-G474RE.clayer.yml +``` + +**App Layer: `.\Layer\App\Blinky.clayer.yml`** + +```yml +layer: +# type: RTOS + name: RTX + description: Keil RTX5 open-source real-time operating system with CMSIS-RTOS v2 API + + interfaces: + - provides: + - RTOS2: + + components: + - component: CMSIS:RTOS2:Keil RTX5&Source +``` + +**RTOS Layer: `.\Layer\RTOS\RTX.clayer.yml`** + +```yml +layer: +# type: RTOS + name: RTX + description: Keil RTX5 open-source real-time operating system with CMSIS-RTOS v2 API + + interfaces: + - provides: + - RTOS2: + + components: + - component: CMSIS:RTOS2:Keil RTX5&Source +``` + +**Board Layer: `.\Layer+NUCELO-G474RE\Board\Nucleo-G474RE.clayer.yml`** + +```yml +layer: + name: NUCLEO-G474RE +# type: Board + description: Board setup with interfaces + device: STM32G474CBTx + + interfaces: + - consumes: + - RTOS2: + - provides: + - C_VIO: + - A_IO9_I: + - A_IO10_O: + - C_VIO: + - STDOUT: + - STDIN: + - STDERR: + - Heap: 65536 + + components: + - component: CMSIS:CORE + - component: CMSIS Driver:USART:Custom + - component: CMSIS Driver:VIO:Board&NUCLEO-G474RE + - component: Compiler&ARM Compiler:Event Recorder&DAP + - component: Compiler&ARM Compiler:I/O:STDERR&User + - component: Compiler&ARM Compiler:I/O:STDIN&User + - component: Compiler&ARM Compiler:I/O:STDOUT&User + - component: Board Support&NUCLEO-G474RE:Drivers:Basic I/O + - component: Device&STM32CubeMX:STM32Cube Framework:STM32CubeMX + - component: Device&STM32CubeMX:STM32Cube HAL + - component: Device&STM32CubeMX:Startup + + groups: + - group: Board IO + files: + - file: ./Board_IO/arduino.c + - file: ./Board_IO/arduino.h + - file: ./Board_IO/retarget_stdio.c + - group: STM32CubeMX + files: + - file: ./RTE/Device/STM32G474RETx/STCubeGenerated/STCubeGenerated.ioc +``` + +## Project Setup for Multiple Targets and Builds + +Complex examples require frequently slightly different targets and/or modifications during build, i.e. for testing. The picture below shows a setup during software development that supports: + +- Unit/Integration Testing on simulation models (called Virtual Hardware) where Virtual Drivers implement the interface to simulated I/O. +- Unit/Integration Testing the same software setup on a physical board where Hardware Drivers implement the interface to physical I/O. +- System Testing where the software is combined with more software components that compose the final application. + +![Target and Build Types](./images/TargetBuild-Types.png "Target and Build Types") + +As the software may share a large set of common files, provisions are required to manage such projects. The common way in other IDE's is to add: + +- **target-types** that select a target system. In the example this would be: + - `Virtual`: for Simulation Models. + - `Board`: for a physical evaluation board. + - `Production-HW`: for system integration test and the final product delivery. +- **build-types** add the flexibility to configure each target build towards a specific testing. It might be: + - `Debug`: for a full debug build of the software for interactive debug. + - `Test`: for a specific timing test using a test interface with code maximal optimization. + - `Release`: for the final code deployment to the systems. + +It is required to generate reproducible builds that can deployed on independent CI/CD test systems. To achieve that, the CMSIS Project Manager generates *.cprj output files with the following naming conventions: + +`[.][+target-type].cprj` this would generate for example: `Multi.Debug+Production-HW.cprj` + +This enables that each target and/or build type can be identified and independently generated which provides the support for test automation. It is however not required to build every possible combination, this should be under user control. + +**Flexible Builds: `Multi.cproject.yml`** + +```yml +project: + + target-types: # todo move target-types and build-types to csolution.yml + - type: Board + board: NUCLEO-L552ZE-Q + + - type: Production-HW + device: STM32L552XY # specifies device + + - type: Virtual + board: VHT-Corstone-300 # Virtual Hardware platform (appears as board) + + build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on + + - type: Release + optimize: max + debug: off + + groups: + - group: My group1 + files: + - file: file1a.c + - file: file1b.c + - file: file1c.c + + - group: My group2 + files: + - file: file2a.c + + - group: Test-Interface + for-type: .Test + files: + - file: fileTa.c + + layers: + - layer: NUCLEO-L552ZE-Q/Board.clayer.yml # tbd find a better way: i.e. $Board$.clayer.yml + for-type: +Board + + - layer: Production.clayer.yml # added for target type: Production-HW + for-type: +Production-HW + + - layer: Corstone-300/Board.clayer.yml # added for target type: VHT-Corstone-300 + for-type: +VHT-Corstone-300 + + components: + - component: Device:Startup + - component: CMSIS:RTOS2:FreeRTOS + - component: ARM::CMSIS:DSP&Source # not added for build type: Test + not-for-type: .Test +``` + +# Project Setup for Related Projects + +A solution is the software view of the complete system. It combines projects that can be generated independently and therefore manages related projects. It may be also deployed to different targets during development as described in the previous section under [Project Setup for Multiple Targets and Test Builds](#project-setup-for-multiple-targets-and-test-builds). + +The picture below shows a system that is composed of: + +- Project A: that implements a time-critical control algorithm running on a independent processor #2. +- Project B: which is a diagram of a cloud connected IoT application with Machine Learning (ML) functionality. +- Project C: that is the data model of the Machine Learning algorithm and separate to allow independent updates. +- Project D: that implements the device security (for example with TF-M that runs with TrustZone in secure mode). + +In addition such systems may have a boot-loader that can be also viewed as another independent project. + +![Related Projects of an Embedded System](./images/Solution.png "Related Projects of an Embedded System") + +To manage the complexity of such related a projects, the `*.csolution.yml` file is introduced. At this level the `target-types` and `build-types` may be managed, so that a common set is available across the system. However it should be also possible to add project specific `build-types` at project level. (tdb: `target-types` might be only possible at solution level). + +- `target-types` describe a different hardware target system and have therefore different API files for peripherals or a different hardware configuration. + +- `build-types` describe a build variant of the same hardware target. All `build-types` share the same API files for peripherals and the same hardware configuration, but may compile a different variant (i.e. with test I/O enabled) of an application. + +**Related Projects `iot-product.csolution.yml`** + +```yml +solution: + target-types: + - type: Board + board: NUCLEO-L552ZE-Q + + - type: Production-HW + device: STM32U5X # specifies device + + build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on + + projects: + - project: /security/TFM.cproject.yml + type: .Release + - project: /application/MQTT_AWS.cproject.yml + - project: /bootloader/Bootloader.cproject.yml + not-for-type: +Virtual +``` + +# Project Structure + +## Directory Structure + +This section describes how the files of `*.csolution.yml` should be organized to allow the scenarios described above: + +Source Directory | Content +:-----------------------------------|:--------------- +`.` | Contains one or more `*.csolution.yml` files that describes an overall application. +`./` | Each project has its own directory +`.//RTE+` | Configurable files that are specific to a target have a specific directory. +`.//RTE` | Configurable files that are common to all targets may have a common directory. +`.//Layer+/` | `*.clayer.yml` and related source files of a layers that are specific to a target have a specific directory. +`.//Layer/` | `*.clayer.yml` and related source files of a layers that are common to all targets may have a common directory. + +**Notes:** + +- `.//RTE+` contains the *.cprj file that is generated by `projmgr` +- Directory names `RTE` and `Layer` should become configurable. ToDo: analyze impact. + +The `./RTE` directory structure is maintained by tools and has the following structure. You should not modify the structure of this directory. + +`RTE[+]` Directory | Content +:---------------------------------|:--------------- +`.../.` | Contains the file `RTE_Components.h` that is specific to a `build-type`. +`.../` | Configurable files for each component class are stored in sub-folders. The name of this sub-folder is derived from the component class name. +`...//` | Configurable files of the component class that are device specific. It is generated when a component has a condition with a `Dname` attribute. (strictly speaking no longer needed, backward compatiblity to MDK?) +`.../Device/` | Configurable files of the component class Device. This should have always a condition with a `Dname` attribute. + +Output Directory | Content +:---------------------------------------------|:--------------- +`.//Output+` | Contains the final binary and symbol files of a project. Each `build-type` shares the same output directory. +`.//.Interim+/.` | Contains interim files (`*.o`, `*.lst`) fore each `build-type` + +**Note:** +- The content of the `Output` directory is generated by the `CBuild` step. + +## Software Components + +Software components are re-usable library or source files that require no modification in the user application. Optionally, configurable source and header files are provided that allow to set parameters for the software component. + +- Configurable source and header files are copied to the project using the directory structure explained above. +- Libraries, source, and header files that are not configurable (and need no modification) are stored in the directory of the Software Component (typically part of CMSIS_Pack_ROOT) and get included directly from this location into the project. +- An Include Path to the header files of the Software Component is added to the C/C++ Compiler control string. + +### PLM of configuration files + +Configurable source and header files have a version information that is required during Project Lifetime Management (PLM) of a project. The version number is important when the underlying software pack changes and provides a newer configuration file version. + +Depending on the PLM status of the application, the `projmgr` performs for configuration files the following operation: + +1. **Add** a software component for the first time: the related config file is copied twice into the related `RTE` project directory. The first copy can be modified by the user with the parameters for the user application. The second copy is an unmodified hidden backup file that is appended with the version information. + + **Example:** A configuration file `ConfigFile.h` at version `1.2.0` is copied: + + ```c + ./RTE/component_class/ConfigFile.h // user editable configuration file + ./RTE/component_class/.ConfigFile.h-1.2.0 // hidden backup used for version comparison + ``` + + The `projmgr` outputs a user notification to indicate that files are added: + + ```text + ./RTE/component_class/ConfigFile.h - info: component 'name' added configuration file version '1.2.0' + ``` + +2. **Upgrade** (or downgrade) a software component: if the version of the hidden backup is identical, no operation is performed. If the version differs, the new configuration file is copied with appended version information. + + **Example:** after configuration file `ConfigFile.h` to version `1.3.0` the directory contains these files: + + ```c + ./RTE/component_class/ConfigFile.h // user editable configuration file + ./RTE/component_class/ConfigFile.h-1.3.0 // user editable configuration file + ./RTE/component_class/.ConfigFile.h-1.2.0 // hidden backup used for version comparison + ``` + + The `projmgr` outputs a user notification to indicate that configuration files have changed: + + ```text + ./RTE/component_class/ConfigFile.h - warning: component 'name' upgrade for configuration file version '1.3.0' added, but file inactive + ``` + +3. **User action to complete upgrade**: The user has now several options (outside of `projmgr`) to merge the configuration file information. A potential way could be to use a 3-way merge utility. After merging the configuration file, the hidden backup should be deleted and the unmodified new version should become the hidden backup. The previous configuration file may be stored as backup as shown below. + + ```c + ./RTE/component_class/ConfigFile.h // new configuration file with merge configuration + ./RTE/component_class/ConfigFile.h.bak // previous configuration file stored as backup + ./RTE/component_class/.ConfigFile.h-1.3.0 // hidden backup of unmodified config file, used for version comparison + ``` + +## Directory Structure (old) + +ToDo: Impact analysis to legacy products that include CMSIS-Pack management. + +This section describes how Keil MDK and the CMSIS-Eclipse currently organizes the `RTE` directory. + +Software Component are included into the directory structure of the project: + +- Configurable source and header files are copied to the project using the directory structure explained below. +- Libraries, source, and header files that are not configurable (and need no modification) are stored in the directory of the Software Component (typically part of CMSIS_Pack_ROOT) and get included directly from this location into the project. +- An Include Path to the header files of the Software Component is added to the C/C++ Compiler control string. + +The following directory and files are created in the Project Folder: + +Directory | Content +:---------------------------------|:--------------- +`./RTE/` | Contains the file `RTE_Components.h` that is specific to a `target-type`. +`./RTE/` | Configurable files for each component class are stored in sub-folders. The name of this sub-folder is derived from the component class name. +`./RTE//` | Configurable files of the component class that are device specific. It is generated when a component has a condition with a `Dname` attribute. +`./RTE/Device/` | Configurable files of the component class Device. This should have always a condition with a `Dname` attribute. + +The directory `.\RTE` is created in the project root directory when using Software Components. You should not modify the content of this folder. + +## RTE_Components.h + +The file `./RTE/RTE_Components.h` is automatically created by the CMSIS Project Manager (during CONVERT). For each selected Software Component it contains `#define` statements required by the component. These statements are defined in the \*.PDSC file for that component. The following example shows a sample content of a RTE_Components.h file: + +```c +/* Auto generated Run-Time-Environment Component Configuration File *** Do not modify ! *** */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + +/* Define the Device Header File: */ +#define CMSIS_device_header "stm32f10x.h" + +#define RTE_Network_Interface_ETH_0 /* Network Interface ETH 0 */ +#define RTE_Network_Socket_BSD /* Network Socket BSD */ +#define RTE_Network_Socket_TCP /* Network Socket TCP */ +#define RTE_Network_Socket_UDP /* Network Socket UDP */ + +#endif /* RTE_COMPONENTS_H */ +``` + +The typical usage of the `RTE_Components.h` file is in header files to control the inclusion of files that are related to other components of the same Software Pack. +```c +#include "RTE_Components.h" +#include CMSIS_device_header + +#ifdef RTE_Network_Interface_ETH_0 // if component Network Interface ETH 0 is included +#include "Net_Config_ETH_0.h" // add the related configuration file for this component +#endif +``` + + + +# YML Format + +## Name Conventions + +### Component Name Conventions + +The CMSIS Project Manager uses the following syntax to specify the `component:` names in the `*.yml` files. + +```text +[Cvendor::] Cclass [&Cbundle] :Cgroup [:Csub] [&Cvariant] [@[>=]Cversion] +``` + +Element | Description +:----------|:--------------------- +`Cvendor` | is the name of the component vendor defined in `` element of the software pack (optional). +`Cclass` | is the component class name defined in `` element of the software pack (required) +`Cbundle` | is the bundle name of component class defined in `` element of the software pack (optional). +`Cgroup` | is the component group name defined in `` element of the software pack (required). +`Csub` | is the component sub-group name defined in `` element of the software pack (optional). +`Cvariant` | is the component sub-group name defined in `` element of the software pack (optional). +`Cversion` | is the version number of the component, with `@1.2.3` that must exactly match, or `@>=1.2.3` that allows any version higher or equal. + +**Notes:** + +- The unique separator `::` allows to omit `Cvendor` +- When `Cvariant` is omitted, the default `Cvariant` is selected. + +**Examples:** + +```yml +component: ARM::CMSIS:CORE # CMSIS Core component from vendor ARM (any version) +component: ARM::CMSIS:CORE@5.5.0 # CMSIS Core component from vendor ARM (with version 5.5.0) +component: ARM::CMSIS:CORE@>=5.5.0 # CMSIS Core component from vendor ARM (with version 5.5.0 or higher) + +component: Device:Startup # Device Startup component from any vendor + +component: CMSIS:RTOS2:Keil RTX5 # CMSIS RTOS2 Keil RTX5 component with default variant (any version) +component: ARM::CMSIS:RTOS2:Keil RTX5&Source@5.5.3 # CMSIS RTOS2 Keil RTX5 component with variant 'Source' and version 5.5.3 + +component: Keil::USB&MDK-Pro:CORE&Release@6.15.1 # From bundle MDK-Pro, USB CORE component with variant 'Release' and version 6.15.1 +``` + +### Device Name Conventions + +The device specifies multiple attributes about the target that ranges from the processor architecture to Flash algorithms used for device programming. The following syntax is used to specify a `device:` value in the `*.yml` files. + + +```text +[Dvendor:: [device_name] ] [:Pname] +``` + +Element | Description +:-------------|:--------------------- +`Dvendor` | is the name (without enum field) of the device vendor defined in `` element of the software pack (optional). +`device_name` | is the device name (Dname attribute) or when used the variant name (Dvariant attribute) as defined in the \ element. +`Pname` | is the processor identifier (Pname attribute) as defined in the `` element. + +**Notes:** + +- All elements of a device name are optional which allows to supply additional information, such as the `:Pname` at different stages of the project. However the `device_name` itself is a mandatory element and must be specified in context of the various project files. +- `Dvendor::` must be used in combination with the `device_name`. + +**Examples:** + +```yml +device: NXP::LPC1768 # The LPC1788 device from NXP +device: LPC1788 # The LPC1788 device (vendor is evaluated from DFP) +device: LPC55S69JEV98 # Device name (exact name as defined in the DFP) +device: LPC55S69JEV98:cm33_core0 # Device name (exact name as defined in the DFP) with Pname specified +device: :cm33_core0 # Pname added to a previously defined device name (or a device derived from a board) +``` + +### Board Name Conventions + +Evaluation Boards define indirectly a device via the related BSP. The following syntax is used to specify a `board:` value in the `*.yml` files. + +```text +[vendor::] board_name +``` + +Element | Description +:------------|:--------------------- +`vendor` | is the name of the board vendor defined in `` element of the board support pack (BSP) (optional). +`board_name` | is the board name (name attribute) of the as defined in the \ element of the BSP. + +**Note:** + +- When a `board:` is specified, the `device:` specification can be omitted, however it is possible to overwrite the device setting in the BSP with an explicit `device:` setting. + +**Examples:** + +```yml +board: Keil::MCB54110 # The Keil MCB54110 board (with device NXP::LPC54114J256BD64) +board: LPCXpresso55S28 # The LPCXpresso55S28 board +``` + +## Access Sequences + +The following **Access Sequences** allow to use arguments from the CMSIS Project Manager in *key* and *value* arguments of the various `*.yml` files. + +Access Sequence | Description +:---------------------------|:-------------------------------------- +`$Bname$` | Board name of the selected board. +`$Bpack$` | Path to the pack that defines the selected board (BSP). +`$Dname$` | Device name of the selected device. +`$Dpack$` | Path to the pack that defines the selected device (DFP). +`$PackRoot$` | Path to the CMSIS Pack Root directory. +`$Pack(vendor.name)$` | Path to specific pack [with latest version ToDo: revise wording]. Example: `$Pack(NXP.K32L3A60_DFP)$`. +`$Output(project)$` | Output file of a related project that is defined in the `*.csolution.yml` file. + +ToDo: define directory structure; should we use `$Output(project[.build-type][+target-type])$` + +**Examples:** + +```yml +groups: + - group: "Main File Group" + defines: + - $Dname$ # Generate a #define 'device-name' for this file group +``` + +```yml + - execute: Generate Image + os: Windows # on Windows run from + run: $DPack$/bin/gen_image.exe # DFP the get_image tool +``` + +## Overall Structure + + +The table below explains the top-level elements in each of the different `*.yml` input files. + +Keyword | Allowed for following files.. | Description +:----------------|:-----------------------------------------------|:------------------------------------ +`default:` | `[defaults].csettings.yml`, `*.csolution.yml` | Start of the default section with [General Properties](#general-properties) +`solution:` | `*.csolution.yml` | Start of the [Collection of related Projects](#solution-collection-of-related-projects) along with build order. +`project:` | `*.cproject.yml` | Start of a Project along with properties - tbd; used in `*.cproject.yml`. +`layer:` | `*.clayer.yml` | Start of a software layer definition that contains pre-configured software components along with source files. + + +YML structure of a `*.cdefaults.yml` file + +```yml +defaults: # Start of default settings + build-types: # Default list of build-types (i.e. Release, Debug) + compiler: # Default selection of the compiler +``` + +YML structure of a `*.csolution.yml` file + +```yml +target-types: # List of build-types +build-types: # List of build-types + +compiler: # Default selection of the compiler + +solution: # Start of a project list that are related + - project: # Reference to a project file +``` + +YML structure of a `*.cproject.yml` file +```yml +project: + compiler: AC6 + + groups: # List of source file groups along with source files + components: # List of software components used + layers: # List of software layers that belong to the project +``` + +YML structure of a `*.clayer.yml` file + +```yml +layer: # Start of a layer + interfaces: # List of consumed and provided interfaces + groups: # List of source file groups along with source files + components: # List of software components used +``` + + + +## Source Code Content + +Keyword | Allowed for following files.. | Description +:----------------|:-----------------------------------------------|:------------------------------------ +`target-types:` | `*.csolution.yml` | Start of the [Target type declaration list](#target-and-build-types) that allow to switch between [different targets](#project-setup-for-multiple-targets-and-test-builds). +`build-types:` | `[defaults].csettings.yml`, `*.csolution.yml` | Start of the [Build type declaration list](#target-and-build-types) that allow to switch between different build settings such as: Release, Debug, Test. +`groups:` | `*.cproject.yml`, `*.clayer.yml` | Start of a list that adds [source groups and files](#groups-and-files) to a project or layer. +`layers:` | `*.cproject.yml` | Start of a list that adds software layers to a project. +`components:` | `*.cproject.yml`, `*.clayer.yml` | Start of a list that adds software components to a project or layer. + + +## General Properties + +The keywords below can be used at various levels in this file types: `[defaults].csettings.yml`, `*.csolution.yml`, and `*.cproject.yml`. + +Keyword | Description +:---------------|:------------------------------------ +`compiler:` | Selection of the compiler toolchain used for the project, i.e. `GCC`, `AC6`, `IAR`, optional with version, i.e AC6@6.16-LTS +`device:` | [Unique device name](#device-name-conventions), optionally with vendor and core. A device is derived from the `board:` setting, but `device:` overrules this setting. +`board:` | [Unique board name](#board-name-conventions), optionally with vendor. +`optimize:` | Generic optimize levels (max, size, speed, debug), mapped to the toolchain by CMSIS-Build. +`debug:` | Generic control for the generation of debug information (on, off), mapped to the compiler toolchain by CMSIS-Build. +`warnings:` | Control warnings (could be: no, all, Misra, AC5-like), mapped to the toolchain by CMSIS-Build. +`defines:` | [#define symbol settings](#defines) for the compiler toolchain (passed as command-line option). +`undefines:` | [Remove #define symbol settings](#undefines) for the compiler toolchain. +`add-paths:` | [Add include path settings](#add-paths) for the compiler toolchain. +`del-paths:` | [Remove include path settings](#del-paths) for the code generation tools. +`misc:` | [Miscellaneous literal tool-specific controls](#misc) that are passed directly to the compiler toolchain depending on the file type. + +**Notes:** + +- `defines:`, `add-paths:`, `del-paths:` and `misc:` are additive. All other keywords overwrite previous settings. + + + +## Target and Build Types + +The section [Project setup for multiple targets and test builds](#project-setup-for-multiple-targets-and-test-builds) describes the concept of `target-types` and `build-types`. These *types* can be defined in the following files in the following order: + +1. `default.csettings.yml` where it defines global *types*, such as *Debug* and *Release* build. +2. `*.csolution.yml` where it specifies the build and target *types* of the complete system. +3. `*.cproject.yml` where it may add specific *types* for an project (tbd are target types allowed when part of a solution?) + +The *`target-type`* and *`build-type`* definitions are additive, but an attempt to redefine an already existing type results in an error. + +The settings of the *`target-type`* are processed first; then the settings of the *`build-type`* that potentially overwrite the *`target-type`* settings. + +YML structure: + +```yml +target-types: # Start a list of target type declarations + - type: # name of the target type (required) + board: # board specification (optional) + device: # device specification (optional) + processor: # processor specific settings (optional) + compiler: # toolchain specification (optional) + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls + +build-types: # Start a list of build type declarations + - type: # name of the build type (required) + processor: # processor specific settings (optional) + compiler: # toolchain specification (optional) + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls +``` + +**Example:** + +```yml +target-types: + - type: Board + board: NUCLEO-L552ZE-Q # board specifies indirectly also the device + + - type: Production-HW + device: STM32L552RC # specifies device + +build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on +``` + +The `board:`, `device:`, and `processor:` settings are used to configure the code translation for the toolchain. These settings are processed in the following order: + +1. `board:` relates to a BSP software pack that defines board parameters, including the [mounted device](https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_boards_pg.html#element_board_mountedDevice). If `board:` is not specified, a `device:` most be specified. +2. `device:` defines the target device. If `board:` is specified, the `device:` setting can be used to overwrite the device or specify the processor core used. +3. `processor:` overwrites default settings for code generation, such as endianess, TrustZone mode, or disable Floating Point code generation. + +**Examples:** + +```yml +target-types: + - type: Production-HW + board: NUCLEO-L552ZE-Q # hardware is similar to a board (to use related software layers) + device: STM32L552RC # but uses a slightly different device + processor: + trustzone: off # TrustZone disabled for this project +``` + +```yml +target-types: + - type: Production-HW + board: FRDM-K32L3A6 # NXP board with K32L3A6 device + device: :cm0plus # use the Cortex-M0+ processor +``` + +## Build/Target-Type control + +Depending on a *`target-type`* or *`build-type`* selection it is possible to include or exclude *items* in the build process. + +Keyword | Description +:---------------|:------------------------------------ +`for-type:` | A *type list* that adds an *item* for a specific target or build *type* or a list of *types*. +`not-for-type:` | A *type list* that removes an *item* for a specific target or build *type* or a list of *types*. + +It is possible to specify only a ``, only a `` or a combination of `` and ``. It is also possible to provide a list of *build* and *target* types. The *type list syntax* for `for-type:` or `not-for-type:` is: + +`[.][+] [, [.]+[]] [, ...]` + +**Examples:** + +```yml +for-type: .Test # add item for build-type: Test (any target-type) +not-for-type: +Virtual # remove item for target-type: Virtual (any build-type) +not-for-type: .Release+Virtual # remove item for build-type: Release with target-type: Virtual +for-type: .Debug, .Release+Production-HW # add for build-type: Debug and build-type: Release / target-type: Production-HW +``` + +The keyword `for-type:` or `not-for-type:` can be applied to the following list keywords: + +Keyword | Description +:------------|:------------------------------------ +`project:` | At `solution:` level it is possible to control inclusion of project. +`group:` | At `group:` level it is possible to control inclusion of a file group. +`file:` | At `file:` level it is possible to control inclusion of a file. +`layer:` | At `layer:` level it is possible to control inclusion of a software layer. +`component:` | At `component:` level it is possible to control inclusion of a software component. + +## Groups and Files + +YML structure: + +```yml +groups: # Start a list of groups + - group: # name of the group + for-type: # include group for a list of *build* and *target* types. + not-for-type: # exclude group for a list of *build* and *target* types. + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls + groups: # Start a nested list of groups + - group: # name of the group + : + files: # Start a nested list of files + - file: # file name along with path + for-type: # include group for a list of *build* and *target* types. + not-for-type: # exclude group for a list of *build* and *target* types. + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +**Example:** + +Add source files to a project or a software layer. Used in `*.cproject.yml` and `*.clayer.yml` files. + +```yml +groups: + - group: "Main File Group" + not-for-type: .Release+Virtual, .Test-DSP+Virtual, +Board + files: + - file: file1a.c + - file: file1b.c + defines: + - a: 1 + undefines: + - b + optimize: size + + - group: "Other File Group" + files: + - file: file2a.c + for-type: +Virtual + defines: + - test: 2 + - file: file2a.c + not-for-type: +Virtual + - file: file2b.c + + - group: "Nested Group" + groups: + - group: Subgroup1 + files: + - file: file-sub1-1.c + - file: file-sub1-2.c + - group: Subgroup2 + files: + - file: file-sub2-1.c + - file: file-sub2-2.c +``` + +## Layers + +Add a software layer to a project. Used in `*.cproject.yml` files. + +YML structure: + +```yml +layers: # Start a list of layers + - layer: # path to the `*.clayer.yml` file that defines the layer (required). + for-type: # include layer for a list of *build* and *target* types (optional). + not-for-type: # exclude layer for a list of *build* and *target* types (optional). + optimize: # optimize level for code generation (optional). + debug: # generation of debug information (optional). + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +## Components + +Add software components to a project or a software layer. Used in `*.cproject.yml` and `*.clayer.yml` files. + +YML structure: + +```yml +components: # Start a list of layers + - component: # name of the software component. + for-type: # include layer for a list of *build* and *target* types (optional). + not-for-type: # exclude layer for a list of *build* and *target* types (optional). + optimize: # optimize level for code generation (optional). + debug: # generation of debug information (optional). + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +**NOTE:** + +- The name of the software component is specified as described under [Name Conventions - +Component Names](#Component_Names) + +## Defines + +Add symbol #define statements to the command line of the development tools. + +YML structure: + +```yml +defines: # Start a list of define statements + - name: value # add a symbol with optional value. + - name: +``` + +## Undefines + +Remove symbol #define statements from the command line of the development tools. + +YML structure: + +```yml +undefines: # Start a list of undefine statements + - name # remove symbol from the list of define statements. + - name # remove a symbol. +``` + +## Add-Paths + +Add include paths to the command line of the development tools. + +YML structure: +```yml +add-paths: # Start a list path names that should be added to the include file search + - path # add path name + - path +``` + +## Del-Paths + +Remove include paths (that are defined at the cproject level) from the command line of the development tools. + +YML structure: +```yml +del-paths: # Start a list of path names that should be removed from the include file search + - path # remove path name + - * # remove all paths +``` + + + +## Misc + +Add tool specific controls as literal strings that are directly passed to the individual tools. + +YML structure: +```yml +misc: # Start a list of literal control strings that are directly passed to the tools. + - compiler: # select the toolchain that the literal control string applies too (AC6, IAR, GCC). + C: string # applies to *.c files only. + CPP: string # applies to *.cpp files only. + C*: string # applies to *.c and *.cpp files. + ASM: string # applies to assembler source files + Link: string # applies to the linker + Lib: string # applies to the library manager or archiver +``` + + +## Solution: Collection of related Projects + +The section [Project setup for related projects](#project-setup-for-related-projects) describes the collection of related projects. The file `*.csolution.yml` describes the relationship of this projects. This file may also define [Target and Build Types](#target-and-build-types) before the section `solution:`. + +The YML structure of the section `solution:` is: + +```yml +solution: # Start a list of projects. + - project: # path to the project file (required). + for-type: # include project for a list of *build* and *target* types (optional). + not-for-type: # exclude project for a list of *build* and *target* types (optional). + compiler: # specify a specific compiler + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls +``` + +## Project Definition + +Start of a project definition in a `*.cproject.yml` file (optional section) + +The YML structure of the section `project:` is: +```yml +project: # do we need this section at all, perhaps for platform? + compiler: name # specify compiler (AC6, GCC, IAR) + description: # project description (optional) + output-type: lib | exe # generate executable (default) or library + processor: # specify processor attributes + groups: # source files organized in groups + layers: # software layers of pre-configured software components + components: # software components +``` + + +## Processor Attributes + +The `processor:` keyword defines attributes such as TrustZone and FPU register usage. + +```yml + processor: # processor specific settings + trustzone: secure # TrustZone mode: secure | non-secure | off + fpu: on | off # control usage of FPU registers (S-Register for Helium/FPU) (default: on for devices with FPU registers) + endian: little | big # select endianess (only available when devices are configureable) +``` + +**Note:** +- Default for `trustzone:` + - `off` for devices that support this option. + - `non-secure` for devices that have TrustZone enabled. + + +# Pre/Post build steps + +Tbd: potentially map to CMake add_custom_command. + +```yml +- execute: description # execute an external command with description + os: Linux # executed on which operating systems (if omitted it is OS independent) + run: # tool name that should be executed, optionally with path to the tool + args: # tool arguments + stop: # stop on exit code +``` + +Potential usage before/after build + +```yml +solution: + - execute: Generate Keys for TF-M + os: Linux + run: KeyGen.exe + - project: /security/TFM.cproject.yml + - project: /application/MQTT_AWS.cproject.yml + - execute: Copy output files + run: cp *.out .\output +``` + +Potential usage during build steps +```yml +groups: + - group: "Main File Group" + files: + - execute: Generate file1a.c + run: xyz.exe + .... + - file: file1a.c +``` + +# Layer + +Start of a layer definition in a `*.clayer.yml` file. + + +**Example:** + + + +```yml +project: + compiler: AC6 + + layers: + - layer: ..\layer\App\Blinky.clayer.yml + - layer: ..\layer\Board+NUCELO-G474RE\Nucelo-G474RE.clayer.yml # 'NUCLEO-G474RE' is target-type + - layer: ..\layer\RTOS\RTX.clayer.yml +``` + + + +```yml +layer: App +# name: Blinky +# description: Simple example + +# interfaces: +# consumes: +# - C_VIO: +# - RTOS2: + + groups: + - group: App + files: + - file: "./Blinky.c" + - group: Documentation + files: + - file: name="./README.md" +``` + +```yml +layer: + type: RTOS + description: Keil RTX5 open-source real-time operating system with CMSIS-RTOS v2 API + +interface: + provides: + - RTOS2: + +components: + component: CMSIS:RTOS2:Keil RTX5&Source +# open how do we capture versions of config files? +``` + +```yml +layer: Board + name: NUCLEO-G474RE + description: Board setup with interfaces + +interfaces: + consumes: + - RTOS2: + provides: + - C_VIO: + - A_IO9_I: + - A_IO10_O: + - C_VIO: + - STDOUT: + - STDIN: + - STDERR: + - Heap: 65536 + +target-types: + - type: NUCLEO-G474RE + board:NUCLEO-G474RE + +components: + component: CMSIS:CORE + component: CMSIS Driver:USART:Custom + component: CMSIS Driver:VIO:Board&NUCLEO-G474RE + component: Compiler&ARM Compiler:Event Recorder&DAP + # Config/EventRecorderConf.h version="1.1.0" + component: Compiler&ARM Compiler:I/O:STDERR&User + component: Compiler&ARM Compiler:I/O:STDIN&User + component: Compiler&ARM Compiler:I/O:STDOUT&User + component: Board Support&NUCLEO-G474RE:Drivers:Basic I/O + # Drivers/Config/stm32g4xx_nucleo_conf.h version="1.0.0" + component: Device&STM32CubeMX:STM32Cube Framework:STM32CubeMX + component: Device&STM32CubeMX:STM32Cube HAL + component: Device&STM32CubeMX:Startup + +groups: + - group: Board IO + files: + - file: ./Board_IO/arduino.c + - file: ./Board_IO/arduino.h + - file: ./Board_IO/retarget_stdio.c + - group: STM32CubeMX + files: + - file: ./RTE/Device/STM32G474RETx/STCubeGenerated/STCubeGenerated.ioc +``` + + + +Todo: work on this + +The YML structure of the section `layer:` is: +```yml +layer: + description: + .... +``` + + +# Proposals + + +## Output versions to *.cprj + +The ProjMgr should always generate *.cprj files that contain version information about the used software packs. + +## CMSIS-Zone Integration + +Add to the project the possiblity to specify. The issue might be that the project files become overwhelming, alternative is to keep partitioning in separate files. + +```yml +memories: # specifies the required memory + - split: SRAM_NS + into: + - region: DATA_NS + size: 128k + permission: n + +peripherals: # specifies the requried peripherals + - peripheral: I2C0 + permission: rw, s +``` + +## Layer Interface Defintions + +A software layer could specify the interfaces that it provides. The interface specification indicates also the configuration of the layer. Issue might be that a standardization across the industry is required. + +```yml +interfaces: + consumes: + - RTOS2: # requires CMSIS-RTOS2 features + provides: + - C_VIO: # provides CMSIS-VIO interface for LEDs + - A_IO9_I: # provides Audrino connector pin I09 configured as input + - A_IO10_O: # provides Audrino connector pin I10 configured as output + - STDOUT: # redirects STDIO + - STDIN: + - STDERR: + - Heap: 65536 # provides 64K heap +``` + +## CMSIS-Pack extensions + +### Board condition + +It should be possible to use conditions to filter against a selected board name. + +### Layers in packs + +A layer is a set of pre-configured software components. It should be possible to store a layer in a pack and apply filter conditions to it. In combination with interfaces specifications, an interactive IDE should be able to display suitable layers that could be added to an application. diff --git a/tools/projmgr/docs/Manual/images/Layer.png b/tools/projmgr/docs/Manual/images/Layer.png new file mode 100644 index 000000000..bc36540fb Binary files /dev/null and b/tools/projmgr/docs/Manual/images/Layer.png differ diff --git a/tools/projmgr/docs/Manual/images/Overview.png b/tools/projmgr/docs/Manual/images/Overview.png new file mode 100644 index 000000000..0fdc646d9 Binary files /dev/null and b/tools/projmgr/docs/Manual/images/Overview.png differ diff --git a/tools/projmgr/docs/Manual/images/Solution.png b/tools/projmgr/docs/Manual/images/Solution.png new file mode 100644 index 000000000..600710267 Binary files /dev/null and b/tools/projmgr/docs/Manual/images/Solution.png differ diff --git a/tools/projmgr/docs/Manual/images/TargetBuild-Types.png b/tools/projmgr/docs/Manual/images/TargetBuild-Types.png new file mode 100644 index 000000000..86aee1ce7 Binary files /dev/null and b/tools/projmgr/docs/Manual/images/TargetBuild-Types.png differ diff --git a/tools/projmgr/docs/Manual/images/overview.pptx b/tools/projmgr/docs/Manual/images/overview.pptx new file mode 100644 index 000000000..2777f1f09 Binary files /dev/null and b/tools/projmgr/docs/Manual/images/overview.pptx differ diff --git a/tools/projmgr/docs/Overview.md b/tools/projmgr/docs/Overview.md new file mode 100644 index 000000000..fde2ab625 --- /dev/null +++ b/tools/projmgr/docs/Overview.md @@ -0,0 +1,743 @@ +# [DRAFT] Overview + +![Overview](./images/Overview.png "Overview") + +The **[Open-CMSIS-Pack](https://www.open-cmsis-pack.org/index.html) Project Manager** essentially uses **Project Files** and **CMSIS-Packs** to create self-contained +CMSIS-Build input files. + +The software packs in *CMSIS-Pack Format* shown on the left side provide device setup (via Device Family Pack (DFP)), board configuration (via Board Support Pack (BSP)), and other reusable software components. It should be investigated if the CMSIS-Zone concept can be integrated into the CMSIS Project Manager. The CMSIS-Pack files are typically not modified by an application programmer as they are provided by silicon vendors, board manufacturers, or the software industry. + +The project setup uses YML Format. A schema file can add validation and "intellisense" during editing. + +Project Files | Order of processing and description +:-----------------|:--------------------------------------------------------------------------------- +`*.csettings.yml` | 1. Default setup for project creation. For example, could provide build-types and a default board. +`*.csolution.yml` | 2. Container for related projects or image. +`*.cproject.yml` | 3. Build description of an project that creates an independent image. +`*.clayer.yml` | 4. Set of source files along with pre-configured components for reuse in different context. + +The **CMSIS Project Manager** uses these *Project Files* along with the software packs in *CMSIS-Pack Format* to generate: + - `*.cproject.yml` output files that contain the effective setting. When comparing to a previous generated version, this file shows the effective changes done by a user compared to the previous setup. + - `*.cprj` files for CMSIS-Build where a reproducible build can be deployed to different host computers, for example a CI system. It lists all packs, software components, etc. to recreate this project. + - `script files` that are generated by a template engine (CMSIS-Zone concept) to setup linker and other application parameters (to be investigated). + + +# Project Examples + +## Minimal Project Setup + +Simple applications require just one self-contained file. + +**Simple Project: `Sample.cproject.yml`** +```yml +project: + compiler: AC6 # Use Arm Compiler 6 for this project + device: LPC55S69 # Device name + optimize: size # Code optimization: emphasis code size + debug: on # Enable debug symbols + + groups: # Define file groups of theproject + - group: My files + files: # Add source files + - file: main.c + + - group: HAL + files: + - file: ./hal/driver1.c + + components: # Add software components + - component: Device:Startup +``` + +## Project Setup for Multiple Targets and Test Builds + +Complex examples require frequently slightly different targets and/or modifications during build, i.e. for testing. The picture below shows a setup during software development that supports: + - Unit/Integration Testing on simulation models (call Virtual Hardware) where Virtual Drivers implement the interface to simulated I/O. + - Unit/Integration Testing the same software setup on a physical board where Hardware Drivers implement the interface to physical I/O. + - System Testing where the software is combined with more software components that compose the final application. + + ![Target and Build Types](./images/TargetBuild-Types.png "Target and Build Types") + +As the software may share a large set of common files, provisions are required to manage such projects. The common way in other IDE's is to add: + - **target-types** that select a target system. In the example this would be: + - `Virtual`: for Simulation Models. + - `Board`: for a physical evaluation board. + - `Production-HW`: for system integration test and the final product delivery. + - **build-types** add the flexibility to configure each target build towards a specific testing. It might be: + - `Debug`: for a full debug build of the software for interactive debug. + - `Test`: for a specific timing test using a test interface with code maximal optimization. + - `Release`: for the final code deployment to the systems. + +It is required to generate reproducible builds that can deployed on independent CI/CD test systems. To achieve that, *.the CMSIS Project Manager generates *.cprj output files with the following naming conventions: + +`[.][+target-type].cprj` this would generate for example: `Multi.Debug+Production-HW.cprj` + +This enables that each target and/or build type can be identified and independently generated which provides the support for test automation. It is however not required to build every possible combination, this should be under user control. + +**Flexible Builds: `Multi.cproject.yml`** + +```yml +target-types: + - type: Board + board: NUCLEO-L552ZE-Q + + - type: Production-HW + device: STM32L552XY # specifies device + + - type: Virtual + board: VHT-Corstone-300 # Virtual Hardware platform (appears as board) + +build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on + + - type: Release + optimize: max + debug: off + +groups: + - group: My group1 + files: + - file: file1a.c + - file: file1b.c + - file: file1c.c + + - group: My group2 + - file: file2a.c + + - group: Test-Interface + for-type: .Test + - file: fileTa.c + +layers: + - layer: NUCLEO-L552ZE-Q/Board.clayer.yml # tbd find a better way: i.e. $Board$.clayer.yml + for-type: +Board + + - layer: Production.clayer.yml # added for target type: Production-HW + for-type: +Production-HW + + - layer: Corstone-300/Board.clayer.yml # added for target type: VHT-Corstone-300 + for-type: +VHT-Corstone-300 + +components: + - component: Device:Startup + - component: CMSIS:RTOS2:FreeRTOS + - component: ARM::CMSIS:DSP&Source # not added for build type: Test + not-for-type: .Test +``` + +## Project Setup for Related Projects + +A solution is the software view of the complete system. It combines projects that can be generated independently and therefore manages related projects. It may be also deployed to different targets during development as described in the previous section under [Project Setup for Multiple Targets and Test Builds](#project-setup-for-multiple-targets-and-test-builds). + +The picture below shows a system that is composed of: + - Project A: that implements a time-critical control algorithm running on a independent processor #2. + - Project B: which is a diagram of a cloud connected IoT application with Machine Learning (ML) functionality. + - Project C: that is the data model of the Machine Learning algorithm and separate to allow independent updates. + - Project D: that implements the device security (for example with TF-M that runs with TrustZone in secure mode). + +In addition such systems may have a boot-loader that can be also viewed as another independent project. + +![Related Projects of an Embedded System](./images/Solution.png "Related Projects of an Embedded System") + +To manage the complexity of such related a projects, the `*.csolution.yml` file is introduced. At this level the `target-types` and `build-types` may be managed, so that a common set is available across the system. However it should be also possible to add project specific `build-types` at project level. (tdb: `target-types` might be only possible at solution level). + +**Related Projects `iot-product.csolution.yml`** + +```yml +target-types: + - type: Board + board: NUCLEO-L552ZE-Q + + - type: Production-HW + device: STM32U5X # specifies device + +build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on + +solution: + - project: /security/TFM.cproject.yml + type: .Release + - project: /application/MQTT_AWS.cproject.yml + - project: /bootloader/Bootloader.cproject.yml + not-for-type: +Virtual +``` + +# Name Conventions + +## Component Names + +The CMSIS Project Manager uses the following syntax to specify component names: + +``` +[Cvendor::] Cclass [&Cbundle] :Cgroup [:Csub] [&Cvariant] [@[>=]Cversion] +``` + +Element | Description +:----------|:--------------------- +`Cvendor` | is the name of the component vendor defined in element of the software pack (optional). +`Cclass` | is the component class name defined in element of the software pack (required) +`Cbundle` | is the bundle name of component class defined in element of the software pack (optional). +`Cgroup` | is the component group name defined in element of the software pack (required). +`Csub` | is the component sub-group name defined in element of the software pack (optional). +`Cvariant` | is the component sub-group name defined in element of the software pack (optional). +`Cversion` | is the version number of the component, with @1.2.3 that must exactly match, or @>=1.2.3 that allows any version higher or equal. + +**Notes:** + + - The unique separator `::` allows it to omit `Cvendor` + - When `Cvariant` is omitted, the default `Cvariant` is selected. + + +**Examples:** + +```yml +ARM::CMSIS:CORE # CMSIS Core component from vendor ARM (any version) +ARM::CMSIS:CORE@5.5.0 # CMSIS Core component from vendor ARM (with version 5.5.0) +ARM::CMSIS:CORE@>=5.5.0 # CMSIS Core component from vendor ARM (with version 5.5.0 or higher) + +Device:Startup # Device Startup component from any vendor + +CMSIS:RTOS2:Keil RTX5 # CMSIS RTOS2 Keil RTX5 component with default variant (any version) +ARM::CMSIS:RTOS2:Keil RTX5&Source@5.5.3 # CMSIS RTOS2 Keil RTX5 component with variant 'Source' and version 5.5.3 + +Keil::USB&MDK-Pro:CORE&Release@6.15.1 # From bundle MDK-Pro, USB CORE component with variant 'Release' and version 6.15.1 + +``` + +## Access Sequences + +The following **Access Sequences** allow to use arguments from the CMSIS Project Manager in *key* and *value* arguments of the various `*.yml` files. + + +Access Sequence | Description +:---------------------------|:-------------------------------------- +`$Bname$` | Board name of the selected board. +`$Bpack$` | Path to the pack that defines the selected board (BSP). +`$Dname$` | Device name of the selected device. +`$Dpack$` | Path to the pack that defines the selected device (DFP). +`$Pack$` | Path to the CMSIS Pack Root directory. +`$Pack(vendor.name)$` | Path to specific pack with latest version. Example: `$Pack(NXP.K32L3A60_DFP)$`. +`$Output(project)$` | Output file of a related project that is defined in the `*.csolution.yml` file. + +ToDo: define directory structure; should we use `$Output(project[.build-type][+target-type])$` + +**Examples:** + +```yml +groups: + - group: "Main File Group" + defines: + - $Dname$ # Generate a #define 'device-name' for this file group +``` +```yml + - execute: Generate Image + os: Windows # on Windows run from + run: $DPack$/bin/gen_image.exe # DFP the get_image tool +``` + + + +# YML Syntax + +## Overall Structure + +Keyword | Allowed for following files.. | Description +:----------------|:-----------------------------------------------|:------------------------------------ +`default:` | `[defaults].csettings.yml`, `*.csolution.yml` | Start of the default section with [General Properties](#general-properties) +`target-types:` | `*.csolution.yml` | Start of the [Target type declaration list](#target-and-build-types) that allow to switch between [different targets](#project-setup-for-multiple-targets-and-test-builds). +`build-types:` | `[defaults].csettings.yml`, `*.csolution.yml` | Start of the [Build type declaration list](#target-and-build-types) that allow to switch between different build settings such as: Release, Debug, Test. +`solution:` | `*.csolution.yml` | Start of the [Collection of related Projects](#solution-collection-of-related-projects) along with build order. +`project:` | `*.cproject.yml` | Start of a Project along with properties - tbd; used in `*.cproject.yml`. +`layer:` | `*.clayer.yml` | Start of a software layer definition that contains pre-configured software components along with source files. +`groups:` | `*.cproject.yml`, `*.clayer.yml` | Start of a list that adds [source groups and files](#groups-and-files) to a project or layer. +`layers:` | `*.cproject.yml` | Start of a list that adds software layers to a project. +`components:` | `*.cproject.yml`, `*.clayer.yml` | Start of a list that adds software components to a project or layer. + +**Note:** For stand-alone `*.cproject.yml` files that do not required a `*.csolution.yml` it is possible to use the *Keywords* that are allowed at `*.csolution.yml` file level. + +## General Properties + +The keywords below can be used at various levels in this file types: `[defaults].csettings.yml`, `*.csolution.yml`, and `*.cproject.yml`. + +Keyword | Description +:---------------|:------------------------------------ +`compiler:` | Selection of the toolchain used for the project, i.e. `GCC`, `AC6`, `IAR`, optional with version, i.e AC6@6.16-LTS +`device:` | Unique device name, optionally with vendor and core. Format: `[::][:]`. When `device:` is null the device is derived from the `board:` device setting, but `device:` overrules the `board:` device setting. +`board:` | Unique board name, optionally with vendor. Format: `[::]`. Examples: `NXP::LPCxpresso55S69` or `NUCLEO-L552ZE-Q`. +`optimize:` | Generic optimize levels (max, size, speed, debug), mapped to the toolchain by CMSIS-Build. +`debug:` | Generic control for the generation of debug information (on, off), mapped to the toolchain by CMSIS-Build. +`warnings:` | Control warnings (could be: no, all, Misra, AC5-like), mapped to the toolchain by CMSIS-Build. +`defines:` | [#define symbol settings](#defines) for the code generation tools. +`undefines:` | [Remove #define symbol settings](#undefines) for the code generation tools. +`add-paths:` | [Add include path settings](#add-paths) for the code generation tools. +`del-paths:` | [Remove include path settings](#del-paths) for the code generation tools. +`misc:` | [Miscellaneous literal tool-specific controls](#misc) that are passed directly to the tools depending on the file type. + +**Notes:** + - `defines:`, `add-paths:` and `misc:` are additive. All other keywords overwrite previous settings. + +## Target and Build Types + +The section [Project setup for multiple targets and test builds](#project-setup-for-multiple-targets-and-test-builds) describes the concept of `target-types` and `build-types`. These *types* can be defined in the following files in the following order: + 1. `default.csettings.yml` where it defines global *types*, such as *Debug* and *Release* build. + 2. `*.csolution.yml` where it specifies the build and target *types* of the complete system. + 3. `*.cproject.yml` where it may add specific *types* for an project (tbd are target types allowed when part of a solution?) + +The *`target-type`* and *`build-type`* definitions are additive, but an attempt to redefine an already existing type results in an error. + +The settings of the *`target-type`* are processed first; then the settings of the *`build-type`* that potentially overwrite the *`target-type`* settings. + + +YML structure: +```yml +target-types: # Start a list of target type declarations + - type: # name of the target type (required) + board: # board specification (optional) + device: # device specification (optional) + processor: # processor specific settings (optional) + compiler: # toolchain specification (optional) + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls + +build-types: # Start a list of build type declarations + - type: # name of the build type (required) + processor: # processor specific settings (optional) + compiler: # toolchain specification (optional) + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls +``` + + +**Example:** +```yml +target-types: + - type: Board + board: NUCLEO-L552ZE-Q + + - type: Production-HW + device: STM32U5X # specifies device + +build-types: + - type: Debug + optimize: debug + debug: on + + - type: Test + optimize: max + debug: on +``` + +The `board:`, `device:`, and `processor:` settings are used to configure the code translation for the toolchain. These settings are processed in the following order: + +1. `board:` relates to a BSP software pack that defines board parameters, including the [mounted device](https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_boards_pg.html#element_board_mountedDevice). If `board:` is not specified, a `device:` most be specified. +2. `device:` defines the target device. If `board:` is specified, the `device:` setting can be used to overwrite the device or specify the processor core used. +3. `processor:` overwrites default settings for code generation, such as endianess, TrustZone mode, or disable Floating Point code generation. + +**Examples:** +```yml +target-types: + - type: Production-HW + board: NUCLEO-L552ZE-Q # hardware is similar to a board + device: STM32L552RC # but uses a slightly different device + processor: + trustzone: off # TrustZone disabled for this project +``` + +```yml +target-types: + - type: Production-HW + board: FRDM-K32L3A6 # NXP board with K32L3A6 device + device: :cm0plus # use the Cortex-M0+ processor +``` + + + +## Build/Target-Type control + +Depending on a *`target-type`* or *`build-type`* selection it is possible to include or exclude *items* in the build process. + +Keyword | Description +:---------------|:------------------------------------ +`for-type:` | A *type list* that adds an *item* for a specific target or build *type* or a list of *types*. +`not-for-type:` | A *type list* that removes an *item* for a specific target or build *type* or a list of *types*. + +It is possible to specify only a ``, only a `` or a combination of `` and ``. It is also possible to provide a list of *build* and *target* types. The *type list syntax* for `for-type:` or `not-for-type:` is: + +`[.][+] [, [.]+[]] [, ...]` + +**Examples:** +```yml +for-type: .Test # add item for build-type: Test (any target-type) +not-for-type: +Virtual # remove item for target-type: Virtual (any build-type) +not-for-type: .Release+Virtual # remove item for build-type: Release with target-type: Virtual +for-type: .Debug, .Release+Production-HW # add for build-type: Debug and build-type: Release / target-type: Production-HW +``` + +The keyword `for-type:` or `not-for-type:` can be applied to the following list keywords: + +Keyword | Description +:------------|:------------------------------------ +`project:` | At `solution:` level it is possible to control inclusion of project. +`group:` | At `group:` level it is possible to control inclusion of a file group. +`file:` | At `file:` level it is possible to control inclusion of a file. +`layer:` | At `layer:` level it is possible to control inclusion of a software layer. +`component:` | At `component:` level it is possible to control inclusion of a software component. + + +## Groups and Files + +YML structure: +```yml +groups: # Start a list of groups + - group: # name of the group + for-type: # include group for a list of *build* and *target* types. + not-for-type: # exclude group for a list of *build* and *target* types. + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls + groups: # Start a nested list of groups + - group: # name of the group + : + files: # Start a nested list of files + - file: # file name along with path + for-type: # include group for a list of *build* and *target* types. + not-for-type: # exclude group for a list of *build* and *target* types. + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +**Example:** + +Add source files to a project or a software layer. Used in `*.cproject.yml` and `*.clayer.yml` files. + +```yml +groups: + - group: "Main File Group" + not-for-type: .Release+Virtual, .Test-DSP+Virtual, +Board + files: + - file: file1a.c + - file: file1b.c + defines: + - a: 1 + undefines: + - b + optimize: size + + - group: "Other File Group" + files: + - file: file2a.c + for-type: +Virtual + defines: + - test: 2 + - file: file2a.c + not-for-type: +Virtual + - file: file2b.c + + - group: "Nested Group" + groups: + - group: Subgroup1 + files: + - file: file-sub1-1.c + - file: file-sub1-2.c + - group: Subgroup2 + files: + - file: file-sub2-1.c + - file: file-sub2-2.c +``` + +## Layers + +Add a software layer to a project. Used in `*.cproject.yml` files. + +YML structure: +```yml +layers: # Start a list of layers + - layer: # path to the `*.clayer.yml` file that defines the layer (required). + for-type: # include layer for a list of *build* and *target* types (optional). + not-for-type: # exclude layer for a list of *build* and *target* types (optional). + optimize: # optimize level for code generation (optional). + debug: # generation of debug information (optional). + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +## Components + +Add software components to a project or a software layer. Used in `*.cproject.yml` and `*.clayer.yml` files. + +YML structure: +```yml +components: # Start a list of layers + - component: # name of the software component. + for-type: # include layer for a list of *build* and *target* types (optional). + not-for-type: # exclude layer for a list of *build* and *target* types (optional). + optimize: # optimize level for code generation (optional). + debug: # generation of debug information (optional). + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls. +``` + +**NOTE:** + - The name of the software component is specified as described under [Name Conventions - +Component Names](#Component_Names) + + +## Defines + +Add symbol #define statements to the command line of the development tools. + +YML structure: +```yml +defines: # Start a list of define statements + - name: value # add a symbol with optional value. + - name: +``` + +## Undefines + +Remove symbol #define statements from the command line of the development tools. + +YML structure: +```yml +undefines: # Start a list of undefine statements + - name # remove symbol from the list of define statements. + - name # remove a symbol. +``` + +## Add-Paths + +Add include paths to the command line of the development tools. + +YML structure: +```yml +add-paths: # Start a list path names that should be added to the include file search + - path # add path name + - path +``` + +## Del-Paths + +Remove include paths (that are defined at the cproject level) from the command line of the development tools. + +YML structure: +```yml +del-paths: # Start a list of path names that should be removed from the include file search + - path # remove path name + - * # remove all paths +``` + + + +## Misc + +Add tool specific controls as literal strings that are directly passed to the individual tools. + +YML structure: +```yml +misc: # Start a list of literal control strings that are directly passed to the tools. + - compiler: # select the toolchain that the literal control string applies too (AC6, IAR, GCC). + C: string # applies to *.c files only. + CPP: string # applies to *.cpp files only. + C*: string # applies to *.c and *.cpp files. + ASM: string # applies to assembler source files + Link: string # applies to the linker + Lib: string # applies to the library manager or archiver +``` + + +## Solution: Collection of related Projects + +The section [Project setup for related projects](#project-setup-for-related-projects) describes the collection of related projects. The file `*.csolution.yml` describes the relationship of this projects. This file may also define [Target and Build Types](#target-and-build-types) before the section `solution:`. + +The YML structure of the section `solution:` is: + +```yml +solution: # Start a list of projects. + - project: # path to the project file (required). + for-type: # include project for a list of *build* and *target* types (optional). + not-for-type: # exclude project for a list of *build* and *target* types (optional). + compiler: # specify a specific compiler + optimize: # optimize level for code generation (optional) + debug: # generation of debug information (optional) + defines: # define symbol settings for code generation (optional). + undefines: # remove define symbol settings for code generation (optional). + add-paths: # additional include file paths (optional). + del-paths: # remove specific include file paths (optional). + misc: # Literal tool-specific controls +``` + +## Project Definition + +Start of a project definition in a `*.cproject.yml` file (optional section) + +The YML structure of the section `project:` is: +```yml +project: # do we need this section at all, perhaps for platform? + compiler: name # specify compiler (AC6, GCC, IAR) + description: # project description (optional) + processor: # specify processor ?? + .... +``` + + +## Processor + +The `processor:` keyword defines: + - for multi-processor systems: the core that is used to execute the program part. + - attributes such as trustzone and fpu register usage. + +```yml + processor: # processor specific settings + trustzone: secure # TrustZone mode: secure | non-secure | off + fpu: off # control usage of FPU registers (S-Registers that are used for Helium and FPU hardware): on | off + endian: little | big # select endianess +``` + +todo - where can `processor:` used? + + +# Pre/Post build steps + +Tbd: potentially map to CMake add_custom_command. + +```yml +- execute: description # execute an external command with description + os: Linux # executed on which operating systems (if omitted it is OS independent) + run: # tool name that should be executed, optionally with path to the tool + args: # tool arguments + stop: # stop on exit code +``` + +Potential usage before/after build + +```yml +solution: + - execute: Generate Keys for TF-M + os: Linux + run: KeyGen.exe + - project: /security/TFM.cproject.yml + - project: /application/MQTT_AWS.cproject.yml + - execute: Copy output files + run: cp *.out .\output +``` + +Potential usage during build steps +```yml +groups: + - group: "Main File Group" + files: + - execute: Generate file1a.c + run: xyz.exe + .... + - file: file1a.c +``` + + + +## Layer Definition + +Start of a layer definition in a `*.clayer.yml` file. + +Todo: work on this + +The YML structure of the section `layer:` is: +```yml +layer: + description: + .... +``` + + +# CMSIS-Zone Integration +Todo: + + + +# Project Structure + +## Directory Structure + +This section describes how files of Software Component are included into the directory structure of the project: + + - Configurable source and header files are copied to the project using the directory structure explained below. + - Libraries, source, and header files that are not configurable (and need no modification) are stored in the directory of the Software Component (typically part of CMSIS_Pack_ROOT) and get included directly from this location into the project. + - An Include Path to the header files of the Software Component is added to the C/C++ Compiler control string. + +The following directory and files are created in the Project Folder: + +Directory | Content +:---------------------------------|:--------------- +`./RTE/` | Contains the file `RTE_Components.h` that is specific to a `target-type`. +`./RTE/` | Configurable files for each component class are stored in sub-folders. The name of this sub-folder is derived from the component class name. +`./RTE//` | Configurable files of the component class that are device specific. It is generated when a component has a condition with a `Dname` attribute. +`./RTE/Device/` | Configurable files of the component class Device. This should have always a condition with a `Dname` attribute. + +The directory `.\RTE` is created in the project root directory when using Software Components. You should not modify the content of this folder. + +## RTE_Components.h + +The file `./RTE/RTE_Components.h` is automatically created by the CMSIS Project Manager (during CONVERT). For each selected Software Component it contains `#define` statements required by the component. These statements are defined in the \*.PDSC file for that component. The following example shows a sample content of a RTE_Components.h file: + +``` +/* Auto generated Run-Time-Environment Component Configuration File *** Do not modify ! *** */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + +/* Define the Device Header File: */ +#define CMSIS_device_header "stm32f10x.h" + +#define RTE_Network_Interface_ETH_0 /* Network Interface ETH 0 */ +#define RTE_Network_Socket_BSD /* Network Socket BSD */ +#define RTE_Network_Socket_TCP /* Network Socket TCP */ +#define RTE_Network_Socket_UDP /* Network Socket UDP */ + +#endif /* RTE_COMPONENTS_H */ +``` + +The typical usage of the `RTE_Components.h` file is in header files to control the inclusion of files that are related to other components of the same Software Pack. +``` +#include "RTE_Components.h" +#include CMSIS_device_header + +#ifdef RTE_Network_Interface_ETH_0 // if component Network Interface ETH 0 is included +#include "Net_Config_ETH_0.h" // add the related configuration file for this component +#endif +``` diff --git a/tools/projmgr/docs/README.md b/tools/projmgr/docs/README.md new file mode 100644 index 000000000..d1fc0b125 --- /dev/null +++ b/tools/projmgr/docs/README.md @@ -0,0 +1,169 @@ +# CMSIS Project Manager - MVP Prototype + +The utility `projmgr` assists the generation of a CMSIS Project Description file +according to the standard +[CPRJ format](https://arm-software.github.io/CMSIS_5/Build/html/cprjFormat_pg.html) +and provides commands to search packs, devices and components from installed packs +as well as unresolved component dependencies. + +## Overview +[Overview](Overview.md) explains the top-level concept and the project file formats. + +## Prototype +The initial MVP prototype proposal can be found in the following Open-CMSIS-Pack forked branch: +
+https://github.com/brondani/devtools/tree/mvp-prototype + +## Requirements + +The CMSIS Pack repository must be present in the environment. + +There are several ways to initialize and configure the pack repository, for example using the +`cpackget` tool: +
+https://github.com/Open-CMSIS-Pack/cpackget + +## Quick Start + +The `projmgr` binaries as well as python interfaces for all supported platforms can be downloaded +from the releases page: +
+https://github.com/brondani/devtools/releases/tag/tools%2Fprojmgr%2F0.9.0 + +Before running `projmgr` the location of the pack repository shall be set via the environment variable +`CMSIS_PACK_ROOT` otherwise its default location will be taken. + +## Usage + +``` +CMSIS Project Manager 0.9.0 (C) 2021 ARM +Usage: + projmgr [] [OPTIONS...] + +Commands: + list packs Print list of installed packs + devices Print list of available device names + components Print list of available components + dependencies Print list of unresolved project dependencies + convert Convert cproject.yml in cprj file + help Print usage + +Options: + -i, --input arg Input YAML file + -f, --filter arg Filter words + -h, --help Print usage +``` + +## Commands + +- Print list of installed packs. The list can be filtered by words provided with the option `--filter`: +``` +list packs [--filter ""] +``` + +- Print list of available device names. The list can be filtered by words provided with the option `--filter`: +``` +list devices [--filter ""] +``` + +- Print list of available components. The list can be filtered by a selected device in the `cproject.yml` file with the option `--input` and/or by words provided with the option `--filter`: +``` +list components [--input --filter ""] +``` + +- Print list of unresolved project dependencies. The device and components selection must be provided in the `cproject.yml` file with the option `--input`. The list can be filtered by words provided with the option `--filter`: +``` +list dependencies --input [--filter ""] +``` + +Convert cproject.yml in cprj file: +``` +convert --input +``` + + +## Input .cproject.yml file + +The YAML structure is described below. + +``` yml +project: + device: + attributes: {} + type: + output: + +compiler: + name: + version: + +components: + - filter: + attributes: {} + +files: + - file: + category: + - group: + files: + - file: + category: +``` + +### project +| Argument | Description +|:----------------|:---------------------------------------- +| device | Device name +| attributes | Device attributes: [Dfpu](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DfpuEnum), [Dmpu](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DmpuEnum), [Dendian](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DendianEnum), [Dsecure](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DsecureEnum), [Dmve](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DmveEnum) +| type | Output type: `exe` or `lib` +| output | Output build folder +
+ +### compiler +| Argument | Description +|:----------------|:---------------------------------------- +| name | Compiler name +| version | Compiler version +
+ +### components +| Argument | Description +|:----------------|:---------------------------------------- +| filter | Filter words +| attributes | Components attributes +
+ +### files +| Argument | Description +|:----------------|:---------------------------------------- +| file | File path and type according to [file category](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#FileCategoryEnum) +| group | Child group name. It accepts nested `files` nodes +
+ +## Public functions +``` + static int RunProjMgr(int argc, char **argv); + void PrintUsage(); + bool LoadPacks(); + bool CheckRteErrors(); + bool ListPacks(set& packs); + bool ListDevices(set& devices); + bool ListComponents(set& components); + bool ListDependencies(set& dependencies); + bool ParseInput(); + bool ProcessProject(); + bool GenerateCprj(); + bool ProcessDevice(); + bool ProcessComponents(); + bool ProcessDependencies(); +``` + +## Python interface + +Python library interfaces are generated with SWIG and can be found among the release artifacts. +A Python CLI wrapper is also provided as an example: [projmgr-cli.py](https://github.com/brondani/devtools/blob/mvp-prototype/tools/projmgr/swig/projmgr-cli.py). + +## Revision History +| Version | Description +|:---------|:---------------------------------------- +| 0.9.0 | Release for alpha review diff --git a/tools/projmgr/docs/SDD.md b/tools/projmgr/docs/SDD.md new file mode 100644 index 000000000..6eb9db11f --- /dev/null +++ b/tools/projmgr/docs/SDD.md @@ -0,0 +1,466 @@ +# [DRAFT] CMSIS Project Manager - Software Design + +## Table of Contents + +[Introduction](#introduction) + +[Design Overview](#design-overview) + +[Use cases](#use-cases) +- [ Use Case 1](#use-case-1) +- [ Use Case 2](#use-case-2) + +[System Architecture](#system-architecture) + +[System Interfaces](#system-interfaces) + +[Input YAML Files](#input-yaml-files) + + +## Introduction + +The CMSIS Project Manager is a C++ utility provided as binary and as library with interfaces for the most common programming languages and platforms. +It leverages open source C++ libraries available in the [Open-CMSIS-Pack devtools](https://github.com/Open-CMSIS-Pack/devtools) repository.
+The tool assists the embedded software developer in the project creation by exposing available features +from installed CMSIS Packs such as devices and components, allowing to search them using free text filters in addition to standard PDSC attributes. It also validates input files that are written in a +human friendly YAML format following pre-defined schemas and it checks the correctness of components selection and unresolved missing dependencies.
+ +It accepts several input files: +| File | Description +|:-----------------|:--------------------------------------------------------------------------------- +| `.csolution.yml` | Defines the complete scope of the application and the build order of sub-projects +| `.cproject.yml` | Defines the content of an independent build - directly relates to a `cprj` file +| `.clayer.yml` | Defines pre-configured files and components for reusing in different solutions +| `.rzone` | Defines memory and peripheral resources. + + +## Design Overview + +The following diagram illustrates inputs and outputs of the `projmgr` processing: +

![Overview](images/Overview.svg) + + +## Use Cases + +The CMSIS Project Manager has two main use cases: +- Backend to synchronize YAML and CPRJ files and related resources. +- Utility to discover available resources and evaluate selected items during project conception. + +### Use case 1: +### Synchronize YAML and CPRJ files and related resources + +When used as a backend for other tools, such as an IDE or a Build Manager, the most typical use is to generate CPRJs and configuration/resources files, creating complete projects. + +

![UseCase1](images/UseCase1.svg) + +### Use case 2: +### Discover project resources and evaluate selected items + +

![UseCase2](images/UseCase2.svg) + + +## System Architecture + +According to the typical use cases some workflows can be defined.
+Creating complete projects: +

![GenerateCPRJ](images/GenerateCPRJ.svg) + +Recreating the `cproject.YAML` files: +

![RecreateYAML](images/RecreateYAML.svg) + +Discovering resources (devices, components, dependencies) for assisting the project conception: + +List Devices: +

![ListDevices](images/ListDevices.svg) + +List Components: +

![ListComponents](images/ListComponents.svg) + +List Dependencies: +

![ListDependencies](images/ListDependencies.svg) + + +## System Interfaces + +The CMSIS Project Manager binaries and libraries are pre-compiled for Windows, Linux and MacOS. The core functions are written in C++ to leverage the already available [Open-CMSIS-Pack/devtools](https://github.com/Open-CMSIS-Pack/devtools) code base.
+The library interfaces are generated by the Simplified Wrapper and Interface Generator ([SWIG](http://www.swig.org)). Initially Python interface is provided. SWIG supports several other [scripting languages](http://www.swig.org/compat.html). + + +## Input YAML Files + +The YAML files support the tags listed below. See the YAML schemas for optional/mandatory and data type requirements. + +### csolution.yml + +``` yml +created: + tool: + timestamp: + +info: + name: + title: + description: + doc: + category: + license: + +target: + device: + attributes: {} + +projects: + - path: + "$ref": "/cproject" # Reference to cproject.yml schema + +resources: # TBD (placeholder) + +templates: # TBD (placeholder) +``` + +### cproject.yml + +``` yml +created: + tool: + timestamp: + +info: + name: + title: + description: + doc: + category: + license: + +artifacts: + - label: + pattern: + +packages: + - name: + vendor: + version: + +compiler: + name: + version: + +target: + device: + attributes: {} + output: + name: + type: + outdir: + intdir: + includes: [] + defines: [] + cflags: + add: [] + cxxflags: + add: [] + asflags: + add: [] + ldflags: + add: [] + arflags: + add: [] + +components: + - id: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + instances: + +files: + - file: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + category: + path: + source: + - group: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + files: + "$ref": "#/files" # Recursive items + +layers: + - path: + "$ref": "/clayer" # Reference to clayer.yml schema +``` + +### clayer.yml + +``` yml +created: + tool: + timestamp: + +info: + name: + title: + description: + doc: + category: + license: + +artifacts: + - label: + pattern: + +interfaces: + provides: {} + consumes: {} + +packages: + - name: + vendor: + version: + +compiler: + name: + version: + +target: + device: + attributes: {} + output: + name: + type: + outdir: + intdir: + includes: [] + defines: [] + cflags: + add: [] + cxxflags: + add: [] + asflags: + add: [] + ldflags: + add: [] + arflags: + add: [] + +components: + - id: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + instances: + +files: + - file: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + category: + path: + label: + source: [] + - group: + cflags: + add: [] + remove: [] + cxxflags: + add: [] + remove: [] + asflags: + add: [] + remove: [] + files: + "$ref": "#/files" # Recursive items +``` + +### created +| Argument | Description +|:----------------|:---------------------------------------- +| tool | Name of the tool that has written the file. The string shall include version information +| timestamp | Date and Time information of the last update. Format: YYYY-MM-DDThh:mm:ss with optional fractional seconds and timezone +
+ +### info +| Argument | Description +|:----------------|:---------------------------------------- +| name | Name of the solution, project or layer +| title | Display name for the solution, project or layer +| description | Brief description +| doc | Documentation pointing to *.md file or URL +| category | Predefined categories +| license | License ruling according to [spdx license names](https://spdx.org/licenses/) +
+ +### projects +| Argument | Description +|:----------------|:---------------------------------------- +| path | Path to `cproject.yml` file +| cproject | Accept and merge any child item according to `cproject` schema +
+ +### resources +| Argument | Description +|:----------------|:---------------------------------------- +| TBD (placeholder) +
+ +### templates +| Argument | Description +|:----------------|:---------------------------------------- +| TBD (placeholder) +
+ +### artifacts +| Argument | Description +|:----------------|:---------------------------------------- +| label | Unique identifier of an output shared file in the solution context +| pattern | Free text that unambiguously points to a file in the `outdir` +
+ +### packages +| Argument | Description +|:----------------|:---------------------------------------- +| name | Name of a required CMSIS Software Pack +| vendor | Pack's vendor +| version | Pack's version, which can be a minimum version or a version range +
+ +### compiler +| Argument | Description +|:----------------|:---------------------------------------- +| name | Name of a required compiler +| version | Compiler's version, which can be a minimum version or a version range +
+ +### target +| Argument | Description +|:----------------|:---------------------------------------- +| device | Free text that unambiguously points to device name +| attributes | Device and board attributes Dvendor, Dname, [Dfpu](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DfpuEnum), [Dmpu](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DmpuEnum), [Dendian](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DendianEnum), [Dsecure](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DsecureEnum), [Dmve](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#DmveEnum), Bvendor, Bname, Bversion +| output | Build output directories, output file and type (executable or library) +| includes | List of include paths that are valid for the compilation of all modules in the project +| defines | List of preprocessor definitions that are valid for all project modules undergoing preprocessing +| cflags | C compiler additional command line options +| cxxflags | C++ compiler additional command line options +| asflags | Assembler additional command line options +| ldflags | Linker additional command line options +| arflags | Archiver additional command line options +
+ +### target/output +| Argument | Description +|:----------------|:---------------------------------------- +| name | Name of the main output file +| type | Main build artifact type: `lib` for library or `exe` for executable +| intdir | Relative path of the folder containing intermediate files (such as object files) +| outdir | Relative path of the folder containing the final build artifacts +
+ +### components +| Argument | Description +|:----------------|:---------------------------------------- +| id | Component identifier `Cvendor::Cclass:Cbundle:Cgroup:Csub:Cvariant@Cversion` or a free text that unambiguously points to a component +| cflags | C compiler additional command line options +| cxxflags | C++ compiler additional command line options +| asflags | Assembler additional command line options +| instances | Number of instances, only for components that are multi-instance capable +
+ +### files/file +| Argument | Description +|:----------------|:---------------------------------------- +| file | Path and name of the file, relative to location of the project file +| cflags | C compiler additional command line options +| cxxflags | C++ compiler additional command line options +| asflags | Assembler additional command line options +| category | Type of file according to [File Categories](https://arm-software.github.io/CMSIS_5/Build/html/cprj_types.html#FileCategoryEnum) +| path | Include path for a file with `header` category +| source | Source path(s) to find source files for a library +
+ +### files/group +| Argument | Description +|:----------------|:---------------------------------------- +| group | Unique name of the group of files +| cflags | C compiler additional command line options +| cxxflags | C++ compiler additional command line options +| asflags | Assembler additional command line options +| files | Unlimited recursive `files` children +
+ +### layers +| Argument | Description +|:----------------|:---------------------------------------- +| path | Path to `clayer.yml` file +| clayer | Accept and merge any child item according to `clayer` schema + +### interfaces +| Argument | Description +|:----------------|:---------------------------------------- +| provides | List of interfaces provided by the layer +| consumes | List of interfaces consumed by the layer + +
+ + +YAML files can be associated in different ways. In the +following diagrams some common combinations are illustrated. +Several other combinations are possible. + +

![YAMLAssociations](images/YAMLAssociations.svg) + +### Multi-layer project +Everything is described in layers, there is no info at solution and +project level. This approach can be used to easily interchange parts +of project such as supported board, middleware or application. + +### Multi-context solution +A bootloader, secure and non-secure projects are part of this +solution, as well as resource files for producing memory and +peripheral configuration via templates processing. Output +artifacts in a project can be labeled for easier integration +as input objects in another project. + +### Multi-toolchain solution +In this solution the common parts are described at project level, +while the compiler selection is provided in layers. Any other +toolchain specific project item could be placed in a layer. + +### Multi-configuration solution +In this case the target options are separated in layers, for example +Debug/Release configurations would have different compiler options +for optimization and for inclusion of debug information in the image. As in the previous example, any other specific configuration project item could be shifted to the layer level. diff --git a/tools/projmgr/docs/images/GenerateCPRJ.svg b/tools/projmgr/docs/images/GenerateCPRJ.svg new file mode 100644 index 000000000..b62e74a6d --- /dev/null +++ b/tools/projmgr/docs/images/GenerateCPRJ.svg @@ -0,0 +1,4 @@ + + + +
input parsing
and validation
input parsing...
generate CPRJs
and RTE files
generate CPRJs...
components are not uniquely found
components are not u...
input YAML
and resource files

input YAML...
load relevant
packs

(defined by cprojects and/or clayers)
load relevant...
compose cprojects from clayers
compose cprojects fr...
search components

(defined by cprojects)
search components...
evaluate dependencies
evaluate dependencies
dependencies are not uniquely found
dependencies are not...
missing unambigous dependency,
add it to the project

missing unambigous d...
templates processing
templates processing
generate resources
generate resources
create/update project model
create/update projec...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/ListComponents.svg b/tools/projmgr/docs/images/ListComponents.svg new file mode 100644 index 000000000..e508797c4 --- /dev/null +++ b/tools/projmgr/docs/images/ListComponents.svg @@ -0,0 +1,4 @@ + + + +
input YAML
input YAML
command
list components

command...
input parsing
and validation
input parsing...
load packs

(subset if cproject is provided)
load packs...
filter results
filter results
print results
print results
no component is found
no component is foun...
load components

(subset if cproject is provided)
load components...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/ListDependencies.svg b/tools/projmgr/docs/images/ListDependencies.svg new file mode 100644 index 000000000..8d122e492 --- /dev/null +++ b/tools/projmgr/docs/images/ListDependencies.svg @@ -0,0 +1,4 @@ + + + +
input YAML
input YAML
command
list dependencies

command...
input parsing
and validation
input parsing...
load packs
subset
load packs...
filter results
filter results
print results
print results
no depencency is found
no depencency is fou...
load components subset
load components subs...
create project model and evaluate dependencies
create project model...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/ListDevices.svg b/tools/projmgr/docs/images/ListDevices.svg new file mode 100644 index 000000000..f527f068e --- /dev/null +++ b/tools/projmgr/docs/images/ListDevices.svg @@ -0,0 +1,4 @@ + + + +
input YAML
input YAML
command
list devices

command...
input parsing
and validation
input parsing...
load packs

(subset if cproject is provided)
load packs...
filter results
filter results
print results
print results
no device is found
no device is found
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/Overview.png b/tools/projmgr/docs/images/Overview.png new file mode 100644 index 000000000..7f81d58ff Binary files /dev/null and b/tools/projmgr/docs/images/Overview.png differ diff --git a/tools/projmgr/docs/images/Overview.svg b/tools/projmgr/docs/images/Overview.svg new file mode 100644 index 000000000..faa6a88c5 --- /dev/null +++ b/tools/projmgr/docs/images/Overview.svg @@ -0,0 +1,4 @@ + + + +
                                                                projmgr
                                                                processing
pr...
csolution
































csolution...
cproject 1













cproject 1...
clayer 0
clayer 0
clayer 1%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22clayer%26lt%3Bbr%26gt%3B0%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22350%22%20y%3D%22720%22%20width%3D%2270%22%20height%3D%2270%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
clayer 1%3C...
clayer N%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22clayer%26lt%3Bbr%26gt%3B0%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22350%22%20y%3D%22720%22%20width%3D%2270%22%20height%3D%2270%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
clayer N%3C...
cproject 0
cproject 0
cproject N
cproject N
CPRJ 0
Resources 0

CPRJ 0...
Resources:
- linker script
- memory layout and partition
- memory and peripheral
protection setup
Resources:...
CPRJ 1
Resources 1

CPRJ 1...
CPRJ N
Resources N

CPRJ N...
azone, rzone, templates
azone, rzone, templates
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/RecreateYAML.svg b/tools/projmgr/docs/images/RecreateYAML.svg new file mode 100644 index 000000000..affd7a6ef --- /dev/null +++ b/tools/projmgr/docs/images/RecreateYAML.svg @@ -0,0 +1,4 @@ + + + +
input parsing
and validation
input parsing...
write back differences into cproject.YAML
write back differenc...
CPRJ
CPRJ
load relevant
packs

(defined by CPRJ
and cproject)

load relevant...
load project models and compare
load project models...
original cproject
original cproject
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/Solution.png b/tools/projmgr/docs/images/Solution.png new file mode 100644 index 000000000..600710267 Binary files /dev/null and b/tools/projmgr/docs/images/Solution.png differ diff --git a/tools/projmgr/docs/images/TargetBuild-Types.png b/tools/projmgr/docs/images/TargetBuild-Types.png new file mode 100644 index 000000000..86aee1ce7 Binary files /dev/null and b/tools/projmgr/docs/images/TargetBuild-Types.png differ diff --git a/tools/projmgr/docs/images/UseCase1.svg b/tools/projmgr/docs/images/UseCase1.svg new file mode 100644 index 000000000..bb71bc2ff --- /dev/null +++ b/tools/projmgr/docs/images/UseCase1.svg @@ -0,0 +1,4 @@ + + + +
           IDE scope





























IDE scope...
     Project Manager scope










Project Manager scope...
     Build Manager scope










Build Manager scope...
     Project Manager scope










Project Manager scope...
Build Solution
Build Solution
Project
Developer
Proje...
Generate CPRJ
and related resources
Generate CPRJ...
Build orchestration
Build orchestration
Artifacts
Artifacts
Edit Project
Edit Project
Update CPRJ
Update CPRJ
Recreate YAML files
Recreate YAML files
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/UseCase2.svg b/tools/projmgr/docs/images/UseCase2.svg new file mode 100644 index 000000000..49f5a2edb --- /dev/null +++ b/tools/projmgr/docs/images/UseCase2.svg @@ -0,0 +1,4 @@ + + + +
                                                 Project Manager scope

















































Project Manager scope...
List Devices
List Devices
Project
Developer
Proje...
<include>
<include>
Load Relevant Packs
Search Devices
Load Relevant Packs...
FilterDevices
FilterDevices
<extend>
<extend>
List Components
List Components
Search Components
Search Components
Filter Components
Filter Components
<extend>
<extend>
List Dependencies
List Dependencies
Load Project Model
Search Dependencies
Load Project Model...
Filter Dependencies
Filter Dependencies
<extend>
<extend>
List Packs
List Packs
Search Packs
in the Pack Local Repository
Search Packs...
Filter Packs
Filter Packs
<extend>
<extend>
<include>
<include>
<include>
<include>
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/images/YAMLAssociations.svg b/tools/projmgr/docs/images/YAMLAssociations.svg new file mode 100644 index 000000000..34c8c7eb1 --- /dev/null +++ b/tools/projmgr/docs/images/YAMLAssociations.svg @@ -0,0 +1,4 @@ + + + +
multi-context solution



















multi-context solution...


target options A
components A
files A



target options A...
multi-configuration solution














multi-configuration solution...
multi-toolchain solution














multi-toolchain solution...


target options
components
files







target options...
cproject
cproject
csolution 
csolution 
clayer
clayer
compiler A
compiler A

compiler B
compiler B



compiler
components
files








compiler...
target options A
target options A

target options B
target options B



target options B
components B
files B



output objects






target options B...



target options C
components C
files C


input objects






target options C...
resources
resources
multi-layer project















multi-layer project...
compiler
target options
compiler...
components A
files A
components A...
components B
files B
components B...
containers:
containers:
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/tools/projmgr/docs/overview.pptx b/tools/projmgr/docs/overview.pptx new file mode 100644 index 000000000..932bff8fb Binary files /dev/null and b/tools/projmgr/docs/overview.pptx differ diff --git a/tools/projmgr/include/ProjMgr.h b/tools/projmgr/include/ProjMgr.h new file mode 100644 index 000000000..5abba59cf --- /dev/null +++ b/tools/projmgr/include/ProjMgr.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef PROJMGR_H +#define PROJMGR_H + +#include "ProjMgr.h" +#include "ProjMgrKernel.h" + +#include "XMLTreeSlim.h" +#include "yaml-cpp/yaml.h" +#include + +struct FileInfo { + std::string name; + std::string category; +}; + +struct GroupInfo { + std::string name; + std::set files; + std::set groups; +}; + +inline bool operator<(const FileInfo& lhs, const FileInfo& rhs) +{ + return lhs.name < rhs.name; +} + +inline bool operator<(const GroupInfo& lhs, const GroupInfo& rhs) +{ + return lhs.name < rhs.name; +} + +struct ComponentInfo { + std::string filter; + std::map attributes; +}; + +inline bool operator<(const ComponentInfo& lhs, const ComponentInfo& rhs) +{ + return lhs.filter < rhs.filter; +} + +class ProjMgr { +public: + ProjMgr(void); + ~ProjMgr(void); + static int RunProjMgr(int argc, char **argv); + void PrintUsage(); + bool LoadPacks(); + bool CheckRteErrors(); + bool ListPacks(std::set& packs); + bool ListDevices(std::set& devices); + bool ListComponents(std::set& components); + bool ListDependencies(std::set& dependencies); + bool ParseInput(); + bool ProcessProject(); + bool GenerateCprj(); + bool ProcessDevice(); + bool ProcessComponents(); + bool ProcessDependencies(); + +protected: + ProjMgrKernel* m_kernel = nullptr; + RteGlobalModel* m_model = nullptr; + RteProject* m_project = nullptr; + RteTarget* m_target = nullptr; + std::list m_installedPacks; + std::string m_input; + std::string m_filter; + std::string m_command; + std::string m_args; + + std::string m_projectName; + std::string m_rootFolder; + std::string m_infoDescription; + std::string m_device; + std::map m_deviceAttributes; + std::string m_outputFolder; + std::string m_outputType; + std::set m_packages; + std::string m_toolchain; + std::string m_toolchainVersion; + std::set m_componentDescriptions; + std::set m_components; + std::set m_dependencies; + GroupInfo m_files; + + void ParseFiles(YAML::Node files, GroupInfo& group); + void GenerateCprjGroups(XMLTreeElement* element, const GroupInfo& group); + std::set SplitArgs(const std::string& args); + static void SetAttribute(XMLTreeElement* element, const std::string& name, const std::string& value); + bool SetTargetAttributes(std::map& attributes); + void ApplyFilter(const std::set& origin, const std::set& filter, std::set& result); +}; + +#endif // PROJMGR_H diff --git a/tools/projmgr/include/ProjMgrCallback.h b/tools/projmgr/include/ProjMgrCallback.h new file mode 100644 index 000000000..4f993efd7 --- /dev/null +++ b/tools/projmgr/include/ProjMgrCallback.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef PROJMGRCALLBACK_H +#define PROJMGRCALLBACK_H + +#include "RteCallback.h" + +class ProjMgrCallback; + +/** + * @brief extension to RTE Callback +*/ +class ProjMgrCallback : public RteCallback +{ +public: + ProjMgrCallback(); + ~ProjMgrCallback(); + + /** + * @brief obtain error messages + * @return list of all error messages + */ + const std::list& GetErrorMessages() const { + return m_errorMessages; + } + + /** + * @brief clear all messages + */ + void ClearErrorMessages() { + m_errorMessages.clear(); + } + + /** + * @brief clear all output messages + */ + virtual void ClearOutput() override; + + /** + * @brief add message to output message list + * @param message error message to be added + */ + virtual void OutputErrMessage(const std::string& message) override; + + /** + * @brief create error message string and add it to message list + * @param id error Id + * @param message error message + * @param object file in which error occured + */ + virtual void Err(const std::string& id, const std::string& message, const std::string& object = RteUtils::EMPTY_STRING) override; + +protected: + std::list m_errorMessages; + +}; +#endif // PROJMGRCALLBACK_H diff --git a/tools/projmgr/include/ProjMgrKernel.h b/tools/projmgr/include/ProjMgrKernel.h new file mode 100644 index 000000000..40973afc0 --- /dev/null +++ b/tools/projmgr/include/ProjMgrKernel.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef PROJMGRKERNEL_H +#define PROJMGRKERNEL_H + +#include "ProjMgrCallback.h" +#include "RteKernel.h" + +class ProjMgrKernel : public RteKernel +{ +public: + ProjMgrKernel(RteCallback* callback); + ~ProjMgrKernel(); + + /** + * @brief get kernel + * @return pointer to singleton kernel instance + */ + static ProjMgrKernel *Get(); + + /** + * @brief destroy kernel + */ + static void Destroy(); + + + bool GetInstalledPacks(std::list& packs); + + /** + * @brief get callback + * @return pointer to callback + */ + const ProjMgrCallback* GetCallback() { + return m_callback; + } + +protected: + XMLTree* CreateXmlTree() const; + +private: + ProjMgrCallback *m_callback; +}; + +#endif /* PROJMGRKERNEL_H */ diff --git a/tools/projmgr/schema/clayer.schema.json b/tools/projmgr/schema/clayer.schema.json new file mode 100644 index 000000000..934217885 --- /dev/null +++ b/tools/projmgr/schema/clayer.schema.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "clayer.schema.json", + "title": "CMSIS Project Manager clayer", + "version": "0.9.0", + "type": "object", + "properties": { + "created": { "$ref": "./common.schema.json#/$defs/CreationInfoType" }, + "info": { "$ref": "./common.schema.json#/$defs/InfoType" }, + "artifacts": { "$ref": "./common.schema.json#/$defs/ArtifactsType" }, + "interfaces": { "$ref": "#/$defs/InterfacesType" }, + "packages" : { "$ref": "./common.schema.json#/$defs/PackagesType" }, + "compiler" : { "$ref": "./common.schema.json#/$defs/CompilerType" }, + "target" : { "$ref": "./common.schema.json#/$defs/TargetType" }, + "components": { "$ref": "./common.schema.json#/$defs/ComponentsType" }, + "files": { "$ref": "./common.schema.json#/$defs/FilesType" } + }, + "additionalProperties": false, + "$defs": { + "InterfacesType": { + "type": "object", + "properties": { + "provides": { + "$ref": "#/$defs/InterfaceListType", + "description": "Interfaces provided by the layer" + }, + "consumes": { + "$ref": "#/$defs/InterfaceListType", + "description": "Interfaces consumed by the layer" + } + }, + "additionalProperties": false + }, + "InterfaceListType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/InterfaceType" } + }, + "InterfaceType": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "value": { "type": "string" } + }, + "additionalProperties": false + } + } +} diff --git a/tools/projmgr/schema/common.schema.json b/tools/projmgr/schema/common.schema.json new file mode 100644 index 000000000..37339ac06 --- /dev/null +++ b/tools/projmgr/schema/common.schema.json @@ -0,0 +1,334 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "cproject.schema.json", + "title": "CMSIS Project Manager cproject", + "version": "0.9.0", + "$defs": { + "RestrictedString": { + "type": "string", + "pattern": "^[-_A-Za-z0-9]+$" + }, + "VersionType": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(((\\-|\\+)[0-9A-Za-z\\-\\+\\.]+)|())$" + }, + "VersionRangeType": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(((\\-|\\+)[0-9A-Za-z\\-\\+\\.]+)|())(:[0-9]+\\.[0-9]+\\.[0-9]+(((\\-|\\+)[0-9A-Za-z\\-\\+\\.]+)|())|())$" + }, + "ArtifactsType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/ArtifactType" } + }, + "ArtifactType": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "Unique identifier of an output shared file in the solution context" + }, + "pattern": { + "type": "string", + "description": "Free text that unambiguously points to a file in the outdir" + } + }, + "additionalProperties": false + }, + "OutputType": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of the main output file" + }, + "type": { + "enum": ["lib", "exe"], + "description": "Main build artifact type: lib for library or exe for executable" + }, + "intdir": { + "type": "string", + "description": "Relative path of the folder containing intermediate files (such as object files)" + }, + "outdir": { + "type": "string", + "description": "Relative path of the folder containing the final build artifacts" + } + }, + "required": [ "name" ], + "additionalProperties": false + }, + "FlagsType": { + "type": "object", + "properties": { + "add": { + "type": "array", + "description": "Add command line options", + "uniqueItems": true, + "items": { "type": "string" } + }, + "remove": { + "type": "array", + "description": "Remove command line options", + "uniqueItems": true, + "items": { "type": "string" } + } + }, + "additionalProperties": false + }, + "CreationInfoType": { + "type": "object", + "properties": { + "tool": { + "type": "string", + "description": "Name of the tool that has written the file. The string shall include version information" + }, + "timestamp": { + "type": "string", + "description": "Date and Time information of the last update. Format: YYYY-MM-DDThh:mm:ss with optional fractional seconds and timezone", + "format": "date-time" } + }, + "additionalProperties": false, + "required": [ "tool", "timestamp" ] + }, + "InfoType": { + "type": "object", + "properties": { + "name": { + "$ref": "#/$defs/RestrictedString", + "description": "Name of the solution, project or layer" }, + "title": { + "type": "string", + "description": "Display name for the solution, project or layer" + }, + "description": { + "type": "string", + "description": "Brief description" + }, + "doc": { + "type": "string", + "description": "Documentation pointing to *.md file or URL" + }, + "category": { + "type": "string", + "description": "Predefined categories" + }, + "license": { + "type": "string", + "description": "License ruling according to spdx license names" + } + }, + "additionalProperties": false, + "required": [ "description" ] + }, + "PackagesType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/PackageType" } + }, + "PackageType":{ + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of a required CMSIS Software Pack" + }, + "vendor": { + "type": "string", + "description": "Pack's vendor" + }, + "version": { + "$ref": "#/$defs/VersionRangeType", + "description": "Pack's version, which can be a minimum version or a version range" + } + }, + "additionalProperties": false, + "required": [ "name", "vendor" ] + }, + "CompilerType": { + "type": "object", + "properties": { + "name": { + "enum": [ "GCC", "AC5", "AC6" ], + "description": "Name of a required compiler" + }, + "version": { + "$ref": "#/$defs/VersionRangeType", + "description": "Compiler's version, which can be a minimum version or a version range" + } + }, + "additionalProperties": false, + "required": [ "name" ] + }, + "TargetAttributesType": { + "type": "object", + "properties": { + "Bvendor": { "type": "string" }, + "Bname": { "type": "string" }, + "Bversion": { "type": "string" }, + "Dvendor": { "type": "string" }, + "Dname": { "type": "string" }, + "Dfpu": { "enum": ["FPU", "NO_FPU", "SP_FPU", "DP_FPU"] }, + "Dendian": { "enum": ["Little-endian", "Big-endian"] }, + "Dmpu": { "enum": ["MPU", "NO_MPU"] }, + "Ddsp": { "enum": ["DSP", "NO_DSP"] }, + "Dmve": { "enum": ["NO_MVE", "MVE", "FP_MVE"] }, + "Dtz": { "enum": ["TZ", "NO_TZ"] }, + "Dsecure": { "enum": ["Secure", "Non-secure", "TZ-disabled"] } + }, + "additionalProperties": false + }, + "TargetType": { + "type": "object", + "properties": { + "device": { + "type": "string", + "description": "Free text that unambiguously points to device name" + }, + "attributes": { + "$ref" : "#/$defs/TargetAttributesType", + "description": "Device and board attributes Dvendor, Dname, Dfpu, Dmpu, Dendian, Dsecure, Dmve, Bvendor, Bname, Bversion" + }, + "output": { + "$ref" : "#/$defs/OutputType", + "description": "Build output directories, output file and type (executable or library)" + }, + "includes": { + "type": "array", + "description": "List of include paths that are valid for the compilation of all modules in the project", + "uniqueItems": true, + "items": { "type": "string" } + }, + "defines": { + "type": "array", + "description": "List of preprocessor definitions that are valid for all project modules undergoing preprocessing", + "uniqueItems": true, + "items": { "type": "string" } + }, + "ldflags": { + "$ref": "#/$defs/FlagsType", + "description": "Linker additional command line options" + }, + "cflags": { + "$ref": "#/$defs/FlagsType", + "description": "C compiler additional command line options" + }, + "cxxflags": { + "$ref": "#/$defs/FlagsType", + "description": "C++ compiler additional command line options" + }, + "asflags": { + "$ref": "#/$defs/FlagsType", + "description": "Assembler additional command line options" + }, + "arflags": { + "$ref": "#/$defs/FlagsType", + "description": "Archiver additional command line options" + } + }, + "additionalProperties": false + }, + "ComponentsType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/ComponentType" } + }, + "ComponentType": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Component identifier Cvendor::Cclass:Cbundle:Cgroup:Csub:Cvariant@Cversion or a free text that unambiguously points to a component" + }, + "cflags": { + "$ref": "#/$defs/FlagsType", + "description": "C compiler additional command line options" + }, + "cxxflags": { + "$ref": "#/$defs/FlagsType", + "description": "C++ compiler additional command line options" + }, + "asflags": { + "$ref": "#/$defs/FlagsType", + "description": "Assembler additional command line options" + }, + "instances": { + "type": "string", + "description": "Number of instances, only for components that are multi-instance capable" + } + }, + "additionalProperties": false + }, + "FilesType": { + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/$defs/FileType" }, + { "$ref": "#/$defs/GroupType" } + ] + } + }, + "FileType": { + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Path and name of the file, relative to location of the project file" + }, + "cflags": { + "$ref": "#/$defs/FlagsType", + "description": "C compiler additional command line options" + }, + "cxxflags": { + "$ref": "#/$defs/FlagsType", + "description": "C++ compiler additional command line options" + }, + "asflags": { + "$ref": "#/$defs/FlagsType", + "description": "Assembler additional command line options" + }, + "category": { + "enum": ["doc", "header", "library", "object", "source", "sourceC", "sourceCpp", "sourceAsm", "linkerScript", "utility", "image", "other", "preIncludeGlobal", "preIncludeLocal"], + "description": "Type of file according to File Categories" + }, + "path": { + "type": "string", + "description": "Include path for a file with header category" + }, + "source": { + "type": "string", + "description": "Source path(s) to find source files for a library" + } + }, + "additionalProperties": false, + "required": [ "file" ] + }, + "GroupType": { + "type": "object", + "properties": { + "group": { + "type": "string", + "description": "Unique name of the group of files" + }, + "cflags": { + "$ref": "#/$defs/FlagsType", + "description": "C compiler additional command line options" + }, + "cxxflags": { + "$ref": "#/$defs/FlagsType", + "description": "C++ compiler additional command line options" + }, + "asflags": { + "$ref": "#/$defs/FlagsType", + "description": "Assembler additional command line options" + }, + "files": { + "$ref": "#/$defs/FilesType", + "description": "Unlimited recursive files children" + } + }, + "additionalProperties": false, + "required": [ "group" ] + } + } +} diff --git a/tools/projmgr/schema/cproject.schema.json b/tools/projmgr/schema/cproject.schema.json new file mode 100644 index 000000000..402a2119e --- /dev/null +++ b/tools/projmgr/schema/cproject.schema.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "cproject.schema.json", + "title": "CMSIS Project Manager cproject", + "version": "0.9.0", + "type": "object", + "properties": { + "created": { "$ref": "./common.schema.json#/$defs/CreationInfoType" }, + "info": { "$ref": "./common.schema.json#/$defs/InfoType"}, + "artifacts": { "$ref": "./common.schema.json#/$defs/ArtifactsType" }, + "packages": { "$ref": "./common.schema.json#/$defs/PackagesType" }, + "compiler": { "$ref": "./common.schema.json#/$defs/CompilerType" }, + "target" : { "$ref": "./common.schema.json#/$defs/TargetType" }, + "components": { "$ref": "./common.schema.json#/$defs/ComponentsType" }, + "files": { "$ref": "./common.schema.json#/$defs/FilesType" }, + "layers": { "$ref": "#/$defs/LayersType" } + }, + "additionalProperties": false, + "$defs": { + "LayersType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/LayerType" } + }, + "LayerType": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to clayer.yml file" + }, + "info": { "$ref": "./common.schema.json#/$defs/InfoType" }, + "artifacts": { "$ref": "./common.schema.json#/$defs/ArtifactsType" }, + "interfaces": { "$ref": "./clayer.schema.json#/$defs/InterfacesType" }, + "packages" : { "$ref": "./common.schema.json#/$defs/PackagesType" }, + "compiler" : { "$ref": "./common.schema.json#/$defs/CompilerType" }, + "target" : { "$ref": "./common.schema.json#/$defs/TargetType" }, + "components": { "$ref": "./common.schema.json#/$defs/ComponentsType" }, + "files": { "$ref": "./common.schema.json#/$defs/FilesType" } + }, + "additionalProperties": false + } + } +} diff --git a/tools/projmgr/schema/csolution.schema.json b/tools/projmgr/schema/csolution.schema.json new file mode 100644 index 000000000..b0c60b17d --- /dev/null +++ b/tools/projmgr/schema/csolution.schema.json @@ -0,0 +1,64 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "csolution.schema.json", + "title": "CMSIS Project Manager csolution", + "version": "0.9.0", + "type": "object", + "properties": { + "created": { "$ref": "./common.schema.json#/$defs/CreationInfoType" }, + "info": { "$ref": "./common.schema.json#/$defs/InfoType" }, + "target" : { "$ref": "#/$defs/SolutionTargetType" }, + "projects": { "$ref": "#/$defs/ProjectsType" }, + "resources": { "$ref": "#/$defs/ResourcesType" }, + "templates": { "$ref": "#/$defs/TemplatesType" } + }, + "additionalProperties": false, + "required": [ "info", "projects" ], + "$defs": { + "ProjectsType": { + "type": "array", + "uniqueItems": true, + "items": { "$ref": "#/$defs/ProjectType" } + }, + "SolutionTargetType": { + "type": "object", + "properties": { + "device": { + "type": "string", + "description": "Device valid for all child projects" + }, + "attributes": { + "$ref" : "./common.schema.json#/$defs/TargetAttributesType", + "description": "Device and board attributes valid for all child projects" + } + }, + "additionalProperties": false + }, + "ProjectType": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to cproject.yml file" + }, + "info": { "$ref": "./common.schema.json#/$defs/InfoType" }, + "artifacts": { "$ref": "./common.schema.json#/$defs/ArtifactsType" }, + "packages": { "$ref": "./common.schema.json#/$defs/PackagesType" }, + "compiler": { "$ref": "./common.schema.json#/$defs/CompilerType" }, + "target" : { "$ref": "./common.schema.json#/$defs/TargetType" }, + "components": { "$ref": "./common.schema.json#/$defs/ComponentsType" }, + "files": { "$ref": "./common.schema.json#/$defs/FilesType" }, + "layers": { "$ref": "./cproject.schema.json#/$defs/LayersType" } + }, + "additionalProperties": false + }, + "ResourcesType": { + "type": "object", + "uniqueItems": true + }, + "TemplatesType": { + "type": "object", + "uniqueItems": true + } + } +} diff --git a/tools/projmgr/src/ProductInfo.h.in b/tools/projmgr/src/ProductInfo.h.in new file mode 100644 index 000000000..f61c9e919 --- /dev/null +++ b/tools/projmgr/src/ProductInfo.h.in @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// Product Information + +static constexpr const char* MAJOR_VERSION = "@PROJECT_VERSION_MAJOR@"; +static constexpr const char* MINOR_VERSION = "@PROJECT_VERSION_MINOR@"; +static constexpr const char* PATCH_VERSION = "@PROJECT_VERSION_PATCH@"; +static constexpr const char* BUILD_VERSION = "0"; + +static constexpr const char* COMPANY_NAME = "Arm Ltd."; +static constexpr const char* FILE_DESCRIPTION = "CMSIS Project Manager"; +static constexpr const char* PRODUCT_NAME = "CMSIS Project Manager"; +static constexpr const char* INTERNAL_NAME = "projmgr"; +static constexpr const char* ORIGINAL_FILENAME = "projmgr"; +static constexpr const char* COPYRIGHT_NOTICE = "(C) @PROJECT_VERSION_YEAR@ ARM"; + +static constexpr const char* VERSION_STRING = "@PROJECT_VERSION_FULL@"; +static constexpr const char* VERSION_STRING_RC = "@PROJECT_VERSION_FULL@"; diff --git a/tools/projmgr/src/ProjMgr.cpp b/tools/projmgr/src/ProjMgr.cpp new file mode 100644 index 000000000..4de21d0c8 --- /dev/null +++ b/tools/projmgr/src/ProjMgr.cpp @@ -0,0 +1,702 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgr.h" + +#include "ProductInfo.h" + +#include "CbuildLayer.h" +#include "CbuildUtils.h" + +#include "RteFsUtils.h" +#include "XmlFormatter.h" +#include "CrossPlatformUtils.h" + +#include +#include +#include +#include +#include + +using namespace std; + +static constexpr const char* SCHEMA_FILE = "PACK.xsd"; // XML schema file name +static constexpr const char* SCHEMA_VERSION = "1.7.2"; // XML schema version + +static constexpr const char* USAGE = "\ +Usage:\n\ + projmgr [] [OPTIONS...]\n\n\ +Commands:\n\ + list packs Print list of installed packs\n\ + devices Print list of available device names\n\ + components Print list of available components\n\ + dependencies Print list of unresolved project dependencies\n\ + convert Convert cproject.yml in cprj file\n\ + help Print usage\n\n\ +Options:\n\ + -i, --input arg Input YAML file\n\ + -f, --filter arg Filter words\n\ + -h, --help Print usage\n\ +"; + +ProjMgr::ProjMgr(void) { + // Reserved +} + +ProjMgr::~ProjMgr(void) { + // Reserved +} + +int ProjMgr::RunProjMgr(int argc, char **argv) { + + ProjMgr manager; + + // Command line options + cxxopts::Options options(ORIGINAL_FILENAME); + cxxopts::ParseResult parseResult; + + try { + options.add_options() + ("command", "", cxxopts::value()) + ("args", "", cxxopts::value()) + ("i,input", "", cxxopts::value()) + ("f,filter", "", cxxopts::value()) + ("h,help", "") + ; + options.parse_positional({ "command", "args"}); + + parseResult = options.parse(argc, argv); + + if (parseResult.count("command")) { + manager.m_command = parseResult["command"].as(); + } else { + // No command was given, print usage and return success + manager.PrintUsage(); + return 0; + } + if (parseResult.count("args")) { + manager.m_args = parseResult["args"].as(); + } + if (parseResult.count("input")) { + manager.m_input = parseResult["input"].as(); + error_code ec; + if (!fs::exists(manager.m_input, ec)) { + cerr << "projmgr error: input file " << manager.m_input << " was not found" << endl; + return 1; + } + manager.m_projectName = fs::path(manager.m_input).stem().stem().generic_string(); + manager.m_rootFolder = fs::path(fs::canonical(manager.m_input, ec)).parent_path().generic_string(); + } + if (parseResult.count("filter")) { + manager.m_filter = parseResult["filter"].as(); + } + } catch (cxxopts::OptionException& e) { + cerr << "projmgr error: parsing command line failed!" << endl << e.what() << endl; + return 1; + } + + // Unmatched items in the parse result + if (!parseResult.unmatched().empty()) { + cerr << "projmgr error: too many command line arguments!" << endl; + return 1; + } + + // Parse commands + if ((manager.m_command == "help") || parseResult.count("help")) { + // Print usage + manager.PrintUsage(); + return 0; + } else if (manager.m_command == "list") { + // Process 'list' command + if (manager.m_args.empty()) { + cerr << "projmgr error: list was not specified!" << endl; + return 1; + } + // Load installed packs + if ((!manager.LoadPacks()) || (!manager.CheckRteErrors()) ){ + return 1; + } + // Parse input if present + if (!manager.m_input.empty() && !manager.ParseInput()) { + return 1; + } + // Process argument + if (manager.m_args == "packs") { + setpacks; + if (manager.ListPacks(packs)) { + for (const auto& pack : packs) { + cout << pack << endl; + } + } + } else if (manager.m_args == "devices") { + setdevices; + if (manager.ListDevices(devices)) { + for (const auto& device : devices) { + cout << device << endl; + } + } + } else if (manager.m_args == "components") { + if (manager.ProcessDevice()) { + setcomponents; + if (manager.ListComponents(components)) { + for (const auto& component : components) { + cout << component << endl; + } + } + } + } else if (manager.m_args == "dependencies") { + if (manager.m_input.empty()) { + cerr << "projmgr error: input YAML file was not specified!" << endl; + return 1; + } + if ((manager.ProcessDevice()) && (manager.ProcessComponents()) && (manager.ProcessDependencies())) { + setdependencies; + if (manager.ListDependencies(dependencies)) { + for (const auto& dependency : dependencies) { + cout << dependency << endl; + } + } + } + } else { + cerr << "projmgr error: list was not found!" << endl; + return 1; + } + } else if (manager.m_command == "convert") { + // Process 'convert' command + if (manager.m_input.empty()) { + cerr << "projmgr error: input YAML file was not specified!" << endl; + return 1; + } + if ((!manager.ParseInput()) || !manager.LoadPacks() || + !manager.ProcessProject() || !manager.CheckRteErrors() || !manager.GenerateCprj()) { + return 1; + } + } else { + cerr << "projmgr error: was not found!" << endl; + return 1; + } + return 0; +} + +void ProjMgr::PrintUsage(void) { + cout << PRODUCT_NAME << " " << VERSION_STRING << " " << COPYRIGHT_NOTICE << " " << endl; + cout << USAGE << endl; +} + +bool ProjMgr::LoadPacks() { + string packRoot = CrossPlatformUtils::GetEnv("CMSIS_PACK_ROOT"); + if (packRoot.empty()) { + packRoot = CrossPlatformUtils::GetDefaultCMSISPackRootDir(); + } + m_kernel = ProjMgrKernel::Get(); + m_kernel->SetCmsisPackRoot(packRoot); + // Get installed packs + if (!m_kernel->GetInstalledPacks(m_installedPacks)) { + cerr << "projmgr error: parsing installed packs failed!" << endl; + } + return true; +} + +bool ProjMgr::CheckRteErrors() { + const list& rteErrorMessages = m_kernel->GetCallback()->GetErrorMessages(); + if (!rteErrorMessages.empty()) { + for (const auto& rteErrorMessage : rteErrorMessages) { + cerr << rteErrorMessage << endl; + } + return false; + } + return true; +} + +bool ProjMgr::SetTargetAttributes(map& attributes) { + if (m_project == nullptr) { + m_model = m_kernel->GetGlobalModel(); + m_project = new RteProject(); + m_model->AddProject(0, m_project); + m_model->SetActiveProjectId(m_project->GetProjectId()); + m_project = m_model->GetActiveProject(); + m_project->AddTarget("CMSIS", attributes, true, true); + m_project->SetActiveTarget("CMSIS"); + m_target = m_project->GetActiveTarget(); + } + else { + m_target->SetAttributes(attributes); + m_target->UpdateFilterModel(); + } + return true; +} + +void ProjMgr::ApplyFilter(const set& origin, const set& filter, set& result) { + result.clear(); + for (const auto& word : filter) { + if (result.empty()) { + for (const auto& item : origin) { + if (item.find(word) != string::npos) { + result.insert(item); + } + } + } else { + const auto temp = result; + for (const auto& item : temp) { + if (item.find(word) == string::npos) { + result.erase(result.find(item)); + } + if (result.empty()) { + return; + } + } + } + } +} + +bool ProjMgr::ListPacks(set& packs) { + if (m_installedPacks.empty()) { + cerr << "projmgr error: no installed pack was found" << endl; + return false; + } + for (const auto& pack : m_installedPacks) { + packs.insert(pack->GetPackageID()); + } + if (!m_filter.empty()) { + set filteredPacks; + ApplyFilter(packs, SplitArgs(m_filter), filteredPacks); + if (filteredPacks.empty()) { + cerr << "projmgr error: no pack was found with filter '" << m_filter << "'" << endl; + return false; + } + packs = filteredPacks; + } + return true; +} + +bool ProjMgr::ListDevices(set& devices) { + for (const auto& pack : m_installedPacks) { + list deviceItems; + pack->GetEffectiveDeviceItems(deviceItems); + for (const auto& deviceItem : deviceItems) { + devices.insert(deviceItem->GetFullDeviceName()); + } + } + if (devices.empty()) { + cerr << "projmgr error: no installed device was found" << endl; + return false; + } + if (!m_filter.empty()) { + set filteredDevices; + ApplyFilter(devices, SplitArgs(m_filter), filteredDevices); + if (filteredDevices.empty()) { + cerr << "projmgr error: no device was found with filter '" << m_filter << "'" << endl; + return false; + } + devices = filteredDevices; + } + return true; +} + +bool ProjMgr::ListComponents(set& components) { + if (m_device.empty()) { + for (const auto& pack : m_installedPacks) { + if (pack->GetComponents()) { + const auto& packComponents = pack->GetComponents()->GetChildren(); + for (const auto& packComponent : packComponents) { + components.insert(packComponent->GetComponentUniqueID(true)); + } + } + } + if (components.empty()) { + cerr << "projmgr error: no installed component was found" << endl; + return false; + } + } else { + RteComponentMap componentMap = m_target->GetFilteredComponents(); + for (const auto& component : componentMap) { + components.insert(component.second->GetComponentUniqueID(true)); + } + if (components.empty()) { + cerr << "projmgr error: no filtered component was found for device '" << m_device << "'" << endl; + return false; + } + } + if (!m_filter.empty()) { + set filteredComponents; + ApplyFilter(components, SplitArgs(m_filter), filteredComponents); + if (filteredComponents.empty()) { + cerr << "projmgr error: no component was found with filter '" << m_filter << "'" << endl; + return false; + } + components = filteredComponents; + } + return true; +} + +bool ProjMgr::ListDependencies(set& dependencies) { + for (const auto& dependency : m_dependencies) { + dependencies.insert(dependency->GetComponentAggregateID()); + } + if (!dependencies.empty() && !m_filter.empty()) { + set filteredDependencies; + ApplyFilter(dependencies, SplitArgs(m_filter), filteredDependencies); + if (filteredDependencies.empty()) { + cerr << "projmgr error: no unresolved dependency was found with filter '" << m_filter << "'" << endl; + return false; + } + dependencies = filteredDependencies; + } + return true; +} + +bool ProjMgr::ParseInput() { + try { + YAML::Node input = YAML::LoadFile(m_input); + + YAML::Node project = input["project"]; + + m_device = project["device"].IsDefined() ? project["device"].as() : ""; + if (project["attributes"].IsDefined()) { + // Attributes + map deviceAttributes; + YAML::Node attributes = project["attributes"]; + for (const auto& attr : attributes) { + m_deviceAttributes.insert({ attr.first.as(), attr.second.as() }); + } + } + m_outputType = project["type"].IsDefined() ? project["type"].as() : "exe"; + m_outputFolder = project["output"].IsDefined() ? project["output"].as() : "output"; + + YAML::Node compiler = input["compiler"]; + m_toolchain = compiler["name"].as(); + m_toolchainVersion = compiler["version"].as(); + + YAML::Node components = input["components"]; + for (const auto& item : components) { + ComponentInfo description; + if (item["filter"].IsDefined()) { + description.filter = item["filter"].as(); + } + if (item["attributes"].IsDefined()) { + // Attributes + map deviceAttributes; + YAML::Node attributes = item["attributes"]; + for (const auto& attr : attributes) { + description.attributes.insert({ attr.first.as(), attr.second.as() }); + } + } + m_componentDescriptions.insert(description); + } + + YAML::Node files = input["files"]; + ParseFiles(files, m_files); + + } catch (YAML::Exception& e) { + cerr << "projmgr error: check YAML file!" << endl << e.what() << endl; + return false; + } + + return true; +} + +void ProjMgr::ParseFiles(YAML::Node node, GroupInfo& group) { + for (const auto& item : node) { + // File node + if (item["file"].IsDefined()) { + FileInfo file = { item["file"].as() }; + if (item["category"].IsDefined()) { + file.category = item["category"].as(); + } + group.files.insert(file); + } + + // Group node + if (item["group"].IsDefined()) { + GroupInfo subgroup = { item["group"].as() }; + GroupInfo& reference = const_cast(*(group.groups.insert(subgroup).first)); + + // Parse children recursively + if (item["files"].IsDefined()) { + YAML::Node files = item["files"]; + ParseFiles(files, reference); + } + } + } +} + +bool ProjMgr::ProcessDevice() { + list devices; + for (const auto& pack : m_installedPacks) { + list deviceItems; + pack->GetEffectiveDeviceItems(deviceItems); + devices.insert(devices.end(), deviceItems.begin(), deviceItems.end()); + } + list filteredDevices; + for (const auto& device : devices) { + if (device->GetDeviceName() == m_device) { + filteredDevices.push_back(device); + } + } + RteDeviceItem* filteredDevice = nullptr; + for (const auto& item : filteredDevices) { + if ((!filteredDevice) || (VersionCmp::Compare(filteredDevice->GetPackage()->GetVersionString(), item->GetPackage()->GetVersionString()) < 0)) { + filteredDevice = item; + } + } + if (!filteredDevice) { + cerr << "projmgr error: no device was found" << endl; + return false; + } + + for (const auto& processor : filteredDevice->GetProcessors()) { + const auto& attributes = processor.second->GetAttributes(); + m_deviceAttributes.insert(attributes.begin(), attributes.end()); + // TODO: handle multiple processors + break; + } + m_deviceAttributes["Dvendor"] = filteredDevice->GetEffectiveAttribute("Dvendor"); + m_deviceAttributes["Dname"] = m_device; + + map attributes; + attributes.insert(m_deviceAttributes.begin(), m_deviceAttributes.end()); + if (m_toolchain == "AC6" || m_toolchain == "AC5") { + attributes["Tcompiler"] = "ARMCC"; + attributes["Toptions"] = m_toolchain; + } else { + attributes["Tcompiler"] = m_toolchain; + } + if (!SetTargetAttributes(attributes)) { + return false; + } + + m_packages.insert(filteredDevice->GetPackage()); + + return true; +} + +bool ProjMgr::ProcessComponents() { + RteComponentMap componentMap = m_target->GetFilteredComponents(); + set componentIds, filteredIds; + for (const auto& component : componentMap) { + componentIds.insert(component.first); + } + + for (const auto& description : m_componentDescriptions) { + RteComponentMap filteredComponents, filteredComponentsByAttribute; + + // Filter components by filter words + if (!description.filter.empty()) { + set filteredIds; + ApplyFilter(componentIds, SplitArgs(description.filter), filteredIds); + filteredComponents.clear(); + for (const auto& filteredId : filteredIds) { + filteredComponents[filteredId] = componentMap[filteredId]; + } + } + + // Filter components by attributes + if (!description.attributes.empty()) { + for (const auto& component : (filteredComponents.empty() ? componentMap : filteredComponents)) { + bool match = true; + for (const auto& attribute : description.attributes) { + auto attr = component.second->GetAttribute(attribute.first); + if (component.second->GetAttribute(attribute.first) != attribute.second) { + match = false; + break; + } + } + if (match) { + filteredComponentsByAttribute.insert(component); + } + } + } + + // Evaluate filtered components + RteComponentMap& componentsRef = filteredComponentsByAttribute.empty() ? filteredComponents.empty() ? + componentMap : filteredComponents : filteredComponentsByAttribute; + if (componentsRef.size() == 1) { + // Single match + m_components.insert(componentsRef.begin()->second); + m_packages.insert(componentsRef.begin()->second->GetPackage()); + } else if (componentsRef.empty()) { + // No match + cerr << "projmgr error: no component was found with"; + if (!description.filter.empty()) { + cerr << " filter '" << description.filter << "'"; + } + if (!description.attributes.empty()) { + cerr << " attributes"; + for (const auto& attribute : description.attributes) { + cerr << " '" << attribute.first << ": " << attribute.second << "'"; + } + } + cerr << endl; + return false; + } else { + // Multiple matches + cerr << "projmgr error: multiple components were found:" << endl; + for (const auto& component : componentsRef) { + cerr << component.first << endl; + } + return false; + } + } + + // Add components into RTE + set unresolvedComponents; + const list selItems(begin(m_components), end(m_components)); + m_project->AddCprjComponents(selItems, m_target, unresolvedComponents); + if (!unresolvedComponents.empty()) { + cerr << "projmgr error: unresolved components:" << endl; + for (const auto& component : unresolvedComponents) { + cerr << component->GetComponentUniqueID(true) << endl; + } + return false; + } + return true; +} + +bool ProjMgr::ProcessDependencies() { + m_project->ResolveDependencies(m_target); + const auto& selected = m_target->GetSelectedComponentAggregates(); + for (const auto& component : selected) { + RteComponentContainer* c = component.first; + string componentAggregate = c->GetComponentAggregateID(); + const auto& match = find_if(m_components.begin(), m_components.end(), + [componentAggregate](auto component) { + return component->GetComponentAggregateID() == componentAggregate; + }); + if (match == m_components.end()) { + m_dependencies.insert(c); + } + } + if (selected.size() != (m_components.size() + m_dependencies.size())) { + cerr << "projmgr error: resolving dependencies failed" << endl; + return false; + } + return true; +} + +bool ProjMgr::ProcessProject() { + if ((!ProcessDevice()) || (!ProcessComponents()) || (!ProcessDependencies())) { + return false; + } + if (!m_dependencies.empty()) { + cerr << "projmgr error: missing dependencies:" << endl; + for (const auto& dependency : m_dependencies) { + cerr << dependency->GetComponentAggregateID() << endl; + } + return false; + } + return true; +} + +bool ProjMgr::GenerateCprj() { + // Root + XMLTree* cprjTree = new XMLTreeSlim(); + XMLTreeElement* rootElement; + rootElement = cprjTree->CreateElement("cprj"); + + // Created + const string& tool = string(ORIGINAL_FILENAME) + " " + string(VERSION_STRING); + const string& timestamp = CbuildUtils::GetLocalTimestamp(); + XMLTreeElement* createdElement = rootElement->CreateElement("created"); + createdElement->AddAttribute("tool", tool); + createdElement->AddAttribute("timestamp", string(timestamp)); + + // Info + XMLTreeElement* infoElement = rootElement->CreateElement("info"); + infoElement->AddAttribute("isLayer", "false"); + const string& infoDescription = m_infoDescription.empty() ? "Automatically generated project" : m_infoDescription; + XMLTreeElement* infoDescriptionElement = infoElement->CreateElement("description"); + infoDescriptionElement->SetText(infoDescription); + + // Create first level elements + XMLTreeElement* packagesElement = rootElement->CreateElement("packages"); + XMLTreeElement* compilersElement = rootElement->CreateElement("compilers"); + XMLTreeElement* targetElement = rootElement->CreateElement("target"); + XMLTreeElement* componentsElement = rootElement->CreateElement("components"); + XMLTreeElement* filesElement = rootElement->CreateElement("files"); + + // Packages + for (const auto& package : m_packages) { + XMLTreeElement* packageElement = packagesElement->CreateElement("package"); + packageElement->AddAttribute("name", package->GetName()); + packageElement->AddAttribute("vendor", package->GetVendorName()); + packageElement->AddAttribute("version", package->GetVersionString()); + } + + // Compilers + XMLTreeElement* compilerElement = compilersElement->CreateElement("compiler"); + compilerElement->AddAttribute("name", m_toolchain); + if (!m_toolchainVersion.empty()) { + compilerElement->AddAttribute("version", m_toolchainVersion); + } + + // Target + static constexpr const char* DEVICE_ATTRIBUTES[] = { "Ddsp", "Dfpu", "Dmve", "Dsecure", "Dtz", "Dvendor" }; + for (const auto& name : DEVICE_ATTRIBUTES) { + const string& value = m_deviceAttributes[name]; + SetAttribute(targetElement, name, value); + } + + targetElement->AddAttribute("Dname", m_device); + targetElement->AddAttribute("Dendian", "Little-endian"); + XMLTreeElement* targetOutputElement = targetElement->CreateElement("output"); + targetOutputElement->AddAttribute("name", m_projectName); + targetOutputElement->AddAttribute("type", m_outputType); + targetOutputElement->AddAttribute("outdir", m_outputFolder); + targetOutputElement->AddAttribute("intdir", m_outputFolder); + + // Components + static constexpr const char* COMPONENT_ATTRIBUTES[] = { "Cbundle", "Cclass", "Cgroup", "Csub", "Cvariant", "Cvendor", "Cversion" }; + for (const auto& component : m_components) { + XMLTreeElement* componentElement = componentsElement->CreateElement("component"); + for (const auto& name : COMPONENT_ATTRIBUTES) { + const string& value = component->GetAttribute(name); + SetAttribute(componentElement, name, value); + } + } + + // Files + GenerateCprjGroups(filesElement, m_files); + + // Save CPRJ + const string& filename = m_rootFolder + "/" + m_projectName + ".cprj"; + if (!CbuildLayer::WriteXmlFile(filename, cprjTree)) { + cerr << "projmgr error: " << filename << " file cannot be written!" << endl; + return false; + } + return true; +} + +void ProjMgr::GenerateCprjGroups(XMLTreeElement* element, const GroupInfo& group) { + if (!group.name.empty()) { + element->AddAttribute("name", group.name); + } + for (const auto& file : group.files) { + XMLTreeElement* fileElement = element->CreateElement("file"); + fileElement->AddAttribute("name", file.name); + fileElement->AddAttribute("category", file.category); + } + for (const auto& group : group.groups) { + XMLTreeElement* groupElement = element->CreateElement("group"); + GenerateCprjGroups(groupElement, group); + } +} + +void ProjMgr::SetAttribute(XMLTreeElement* element, const string& name, const string& value) { + if (!value.empty()) { + element->AddAttribute(name, value); + } +} + +set ProjMgr::SplitArgs(const string& args) { + set s; + size_t end = 0, start = 0, len = args.length(); + while (end < len) { + if ((end = args.find(" ", start)) == string::npos) end = len; + s.insert(args.substr(start, end - start)); + start = end + 1; + } + return s; +} diff --git a/tools/projmgr/src/ProjMgrCallback.cpp b/tools/projmgr/src/ProjMgrCallback.cpp new file mode 100644 index 000000000..263d131aa --- /dev/null +++ b/tools/projmgr/src/ProjMgrCallback.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgrCallback.h" +#include "ProjMgrKernel.h" + +using namespace std; + +ProjMgrCallback::ProjMgrCallback() : RteCallback() +{ +} + +ProjMgrCallback::~ProjMgrCallback() +{ + ClearErrorMessages(); +} + +void ProjMgrCallback::ClearOutput() +{ + ClearErrorMessages(); +} + +void ProjMgrCallback::Err(const string& id, const string& message, const string& file) +{ + string msg = "Error " + id; + if (!message.empty()) { + msg += ": " + message; + } + if (!file.empty()) { + msg += ": " + file; + } + OutputErrMessage(msg); +} + +void ProjMgrCallback::OutputErrMessage(const string& message) +{ + if(!message.empty()) { + m_errorMessages.push_back(message); + } +} diff --git a/tools/projmgr/src/ProjMgrKernel.cpp b/tools/projmgr/src/ProjMgrKernel.cpp new file mode 100644 index 000000000..b1111f73c --- /dev/null +++ b/tools/projmgr/src/ProjMgrKernel.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgrKernel.h" +#include "ProjMgrCallback.h" + +#include "RteFsUtils.h" +#include "RteKernel.h" +#include "RteValueAdjuster.h" +#include "XMLTreeSlim.h" + +#include + +using namespace std; + +// Singleton kernel object +static ProjMgrKernel *theProjMgrKernel = 0; + +ProjMgrKernel::ProjMgrKernel(RteCallback* callback) : RteKernel(callback) { + m_callback = dynamic_cast(callback); +} + +ProjMgrKernel::~ProjMgrKernel() { + if (m_callback) + delete m_callback; + m_callback = 0; +} + +ProjMgrKernel *ProjMgrKernel::Get() { + if (!theProjMgrKernel) { + ProjMgrCallback* cb = new ProjMgrCallback(); + theProjMgrKernel = new ProjMgrKernel(cb); + } + return theProjMgrKernel; +} + +void ProjMgrKernel::Destroy() { + if (theProjMgrKernel) + delete theProjMgrKernel; + theProjMgrKernel = 0; +} + +class ProjMgrXmlParser : public XMLTreeSlim +{ +public: + ProjMgrXmlParser() :XMLTreeSlim(0, true) { m_XmlValueAdjuster = new RteValueAdjuster(); } + ~ProjMgrXmlParser() { delete m_XmlValueAdjuster; } +}; + +XMLTree* ProjMgrKernel::CreateXmlTree() const +{ + return new ProjMgrXmlParser(); +} + +bool ProjMgrKernel::GetInstalledPacks(list& packs) { + list pdscFiles; + RteFsUtils::GetPackageDescriptionFiles(pdscFiles, theProjMgrKernel->GetCmsisPackRoot(), 3); + for (const auto& pdscFile : pdscFiles) { + RtePackage* pack = theProjMgrKernel->LoadPack(pdscFile); + if (!pack) { + return false; + } + packs.push_back(pack); + } + theProjMgrKernel->GetGlobalModel()->InsertPacks(packs); + return true; +} diff --git a/tools/projmgr/src/ProjMgrMain.cpp b/tools/projmgr/src/ProjMgrMain.cpp new file mode 100644 index 000000000..edee262dd --- /dev/null +++ b/tools/projmgr/src/ProjMgrMain.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgr.h" + +/* +Main function +*/ +int main(int argc, char **argv) { + + return ProjMgr::RunProjMgr(argc, argv); + +} diff --git a/tools/projmgr/swig/CMakeLists.txt b/tools/projmgr/swig/CMakeLists.txt new file mode 100644 index 000000000..bf8f3d29f --- /dev/null +++ b/tools/projmgr/swig/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.14) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(PythonLibs) +include_directories(projmgr PUBLIC ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../include ${PROJECT_BINARY_DIR}) +set_source_files_properties(projmgr.i PROPERTIES CPLUSPLUS ON) + +swig_add_library(projmgr LANGUAGE python SOURCES projmgr.i) + +swig_link_libraries(projmgr ${PYTHON_LIBRARIES} projmgrlib) diff --git a/tools/projmgr/swig/projmgr-cli.py b/tools/projmgr/swig/projmgr-cli.py new file mode 100644 index 000000000..6e162cc01 --- /dev/null +++ b/tools/projmgr/swig/projmgr-cli.py @@ -0,0 +1,5 @@ +import projmgr +import sys + +manager = projmgr.ProjMgr() +manager.RunProjMgr(sys.argv) diff --git a/tools/projmgr/swig/projmgr.i b/tools/projmgr/swig/projmgr.i new file mode 100644 index 000000000..d20f71d7b --- /dev/null +++ b/tools/projmgr/swig/projmgr.i @@ -0,0 +1,20 @@ +%module projmgr +%include "std_list.i" +%include "std_set.i" +%include "std_map.i" +%include "std_string.i" +%include "argcargv.i" + +%apply (int ARGC, char **ARGV) { (int argc, char **argv) } + +namespace std { + %template(map_string_string) map; +} + +%rename(lt) operator<; + +%{ + #include "../include/ProjMgr.h" +%} + +%include "../include/ProjMgr.h" diff --git a/tools/projmgr/test/CMakeLists.txt b/tools/projmgr/test/CMakeLists.txt new file mode 100644 index 000000000..c15220145 --- /dev/null +++ b/tools/projmgr/test/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(ProjMgrUnitTests src/ProjMgrUnitTests.cpp src/ProjMgrTestEnv.cpp) + +set_property(TARGET ProjMgrUnitTests PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + +target_link_libraries(ProjMgrUnitTests PUBLIC projmgrlib gtest_main) +target_include_directories(ProjMgrUnitTests PUBLIC ../include ./src) + +add_definitions(-DTEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}/") + +add_test(NAME ProjMgrUnitTests + COMMAND ProjMgrUnitTests --gtest_output=xml:projmgr_unit_test_report.xml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/tools/projmgr/test/data/project/main.c b/tools/projmgr/test/data/project/main.c new file mode 100644 index 000000000..2d9749792 --- /dev/null +++ b/tools/projmgr/test/data/project/main.c @@ -0,0 +1,6 @@ +#include "RTE_Components.h" +#include CMSIS_device_header + +int main (void) { + return 1; +} diff --git a/tools/projmgr/test/data/project/test.cproject.yml b/tools/projmgr/test/data/project/test.cproject.yml new file mode 100644 index 000000000..6f632deb9 --- /dev/null +++ b/tools/projmgr/test/data/project/test.cproject.yml @@ -0,0 +1,22 @@ +### CMSIS Project Description ### + +project: + device: ARMCM3 + +compiler: + name: AC6 + version: "6.16.0" + +components: + - attributes: + Cvariant: "C Startup" + - filter: "Keil RTX" + attributes: + Cvariant: "Source" + - filter: "ARM CMSIS CORE" + +files: + - group: "Sources" + files: + - file: "main.c" + category: sourceC diff --git a/tools/projmgr/test/src/ProjMgrTestEnv.cpp b/tools/projmgr/test/src/ProjMgrTestEnv.cpp new file mode 100644 index 000000000..e067beb84 --- /dev/null +++ b/tools/projmgr/test/src/ProjMgrTestEnv.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgrTestEnv.h" +#include "RteFsUtils.h" + +using namespace std; + +string testinput_folder; +string testoutput_folder; + +void ProjMgrTestEnv::SetUp() { + testinput_folder = string(TEST_FOLDER) + "data"; + testoutput_folder = RteFsUtils::GetCurrentFolder() + "output"; + if (RteFsUtils::Exists(testoutput_folder)) { + RteFsUtils::RemoveDir(testoutput_folder); + } + RteFsUtils::CreateDirectories(testoutput_folder); + testinput_folder = fs::canonical(testinput_folder).generic_string(); + testoutput_folder = fs::canonical(testoutput_folder).generic_string(); + ASSERT_FALSE(testinput_folder.empty()); + ASSERT_FALSE(testoutput_folder.empty()); +} + +void ProjMgrTestEnv::TearDown() { + // Reserved +} + +int main(int argc, char **argv) { + try { + testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new ProjMgrTestEnv); + return RUN_ALL_TESTS(); + } + catch (testing::internal::GoogleTestFailureException const& e) { + cout << "runtime_error: " << e.what(); + return 2; + } + catch (...) { + cout << "non-standard exception"; + return 2; + } +} diff --git a/tools/projmgr/test/src/ProjMgrTestEnv.h b/tools/projmgr/test/src/ProjMgrTestEnv.h new file mode 100644 index 000000000..bbe453cca --- /dev/null +++ b/tools/projmgr/test/src/ProjMgrTestEnv.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "gtest/gtest.h" + +extern std::string testoutput_folder; +extern std::string testinput_folder; + +/** + * @brief global test environment for all the test suites +*/ +class ProjMgrTestEnv : public ::testing::Environment { +public: + void SetUp() override; + void TearDown() override; +}; diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp new file mode 100644 index 000000000..0dd7c30ac --- /dev/null +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020-2021 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "ProjMgr.h" +#include "ProjMgrTestEnv.h" + +#include "gtest/gtest.h" + +using namespace std; + +class PackGenUnitTests : public ProjMgr, public ::testing::Test { +public: + PackGenUnitTests() {} + virtual ~PackGenUnitTests() {} +}; + +TEST_F(PackGenUnitTests, RunProjMgr) { + char *argv[1]; + + // Empty options + EXPECT_EQ(0, RunProjMgr(1, argv)); +}