How to Use the Unified Vitis IDE with Git

Temp mail SuperHeros
How to Use the Unified Vitis IDE with Git
How to Use the Unified Vitis IDE with Git

Getting Started with Git in Vitis IDE

Compared to the previous Eclipse-based version, using Git with the new "Unified Vitis" IDE—which is based on VSCode—presents different issues. The most recent version lacks the import/export project wizard, which makes it impossible to properly manage version control.

This article attempts to solve the problems that come up when using Git in Vitis, such as how to handle files that are generated with absolute paths and how to facilitate seamless collaboration between various development systems. We'll look at a useful workflow for using Git to effectively manage your Vitis projects.

Command Description
import vitis Imports the Vitis API in order to communicate programmatically with Vitis projects.
client.set_workspace() Establishes the project file management workspace directory for the Vitis client.
client.create_platform_component() Uses predefined hardware and operating system settings to create a new platform component in the Vitis workspace.
platform.build() Initiates the Vitis build process for the designated platform component.
client.create_app_component() Establishes a new application component in Vitis that is connected to the designated platform component.
comp.import_files() Imports the required files into the Vitis application component from the source directory.
os.makedirs() Generates the directory structure that is supplied, together with any parent directories that are required.
vitis -s tools/build_app.py Sets up the project by executing the given Python script through the Vitis command-line interface.
echo "build-vitis/" >> .gitignore Excludes the build directory from version control by adding it to the Git ignore file.
git commit -m Publishes the staged modifications along with a designated commit message to the local Git repository.

Describe the Scripts for Vitis Automation

The first script uses Python to automate the Vitis project setup. Importing the required modules, namely vitis and os, is the first step. Next, it uses os.makedirs() to define the root path and, if it doesn't already exist, to construct the build directory. The script configures the primary source directory and the anticipated paths for the XSA file. It then sets the workspace to the newly formed build directory and generates a Vitis client. Using client.create_platform_component(), the platform component is constructed, indicating the CPU configuration, OS, and hardware. An application component is made and connected to the platform component once the platform component has been constructed. Ultimately, the component is constructed after the required files are imported into the Vitis project.

The Vitis project is initialized and Git integration is set up by the second script, which is a shell script. The build directory and root path are defined, and if the directory doesn't already exist, it is created. After that, the script uses vitis -s tools/build_app.py to run the Python script and automate the project setup. The Python script executes, and then the shell script creates a Git repository by going to the root directory, adding build directories to the .gitignore file, and initializing Git using git init. After staging the pertinent files with git add, git commit -m is used to commit them to the repository. With this method, version control is maintained for the project files that are required, but the build folders are kept out of it.

Using Python to Automate Vitis Project Setup

Python script to manage Git integration and Vitis project setup

import vitis
import os

ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
VITIS_BUILD_DIR_PATH = os.path.join(ROOT_PATH, "build-vitis")
os.makedirs(VITIS_BUILD_DIR_PATH, exist_ok=True)
EXPECTED_XSA_FILE_PATH = os.path.join(ROOT_PATH, "build-vivado", "mydesign.xsa")
COMPONENT_NAME = "MyComponent"
MAIN_SRC_PATH = os.path.join(ROOT_PATH, "src")

client = vitis.create_client()
client.set_workspace(path=VITIS_BUILD_DIR_PATH)

PLATFORM_NAME = "platform_baremetal"
platform = client.create_platform_component(
    name=PLATFORM_NAME,
    hw=EXPECTED_XSA_FILE_PATH,
    os="standalone",
    cpu="mycpu"
)

platform = client.get_platform_component(name=PLATFORM_NAME)
status = platform.build()

comp = client.create_app_component(
    name=COMPONENT_NAME,
    platform=os.path.join(VITIS_BUILD_DIR_PATH, PLATFORM_NAME, "export", PLATFORM_NAME, f"{PLATFORM_NAME}.xpfm"),
    domain="mydomainname"
)

comp = client.get_component(name=COMPONENT_NAME)
status = comp.import_files(
    from_loc=MAIN_SRC_PATH,
    files=["CMakeLists.txt", "UserConfig.cmake", "lscript.ld", "NOTUSED.cpp"],
    dest_dir_in_cmp="src"
)

comp.build()

Controlling Source in Vitis Projects

Using a shell script to expedite source control and project initiation for Vitis

#!/bin/bash

ROOT_PATH=$(pwd)
VITIS_BUILD_DIR_PATH="$ROOT_PATH/build-vitis"
mkdir -p "$VITIS_BUILD_DIR_PATH"
EXPECTED_XSA_FILE_PATH="$ROOT_PATH/build-vivado/mydesign.xsa"
COMPONENT_NAME="MyComponent"
MAIN_SRC_PATH="$ROOT_PATH/src"

vitis -s tools/build_app.py

# After running the Python script, set up Git repository
cd "$ROOT_PATH"
git init
echo "build-vitis/" >> .gitignore
echo "build-vivado/" >> .gitignore
git add src/ tools/ .gitignore
git commit -m "Initial commit with project structure and scripts"

# Script end

Understanding Version Control and the Vitis IDE

Understanding the components and structure of Vitis projects is one of the requirements for using the new "Unified Vitis" IDE with Git. Version management is complicated by the massive number of files generated by the Vitis IDE, many of which have absolute paths. These files contain metadata unique to the IDE, device descriptions, and platform parameters. Without appropriate handling, version control of these files can lead to problems for developers, such as build errors from mismatched paths on various systems.

It's standard practice to remove folders maintained by Vitis from version control in order to lessen these issues. Rather, important configuration files like CMake files, linker scripts, and other project files are manually transferred to the locations Vitis expects them to be. By ensuring that only the files that are required are version-controlled, this method lowers the possibility of errors and conflicts while working with other developers. Furthermore, this procedure can be streamlined by employing automation scripts, such as Python or shell scripts, which provide consistent and repeatable project setup and file management.

Frequently Asked Questions & Answers about Using Git with the Vitis IDE

  1. For a Vitis project, how do I set up a Git repository initially?
  2. git init can be executed to initialize a Git repository by going to the project root. To remove unnecessary files, add the necessary files to .gitignore.
  3. Which files belong in the .gitignore for a project using Vitis?
  4. Incorporate directories particular to the IDE, such as build-vitis/ and build-vivado/, to prevent version-controlling files created automatically.
  5. How can I start up a Vitis project automatically?
  6. To automate processes like building platform components and importing required files, use a Python script. Utilizing vitis -s tools/build_app.py, run the script.
  7. Why must I manually copy the configuration files?
  8. Various configuration files must be in various locations according to Vitis. Making a manual copy of these files or using a script makes sure the IDE locates them properly.
  9. In Vitis, how can I manage the application and platform folders?
  10. To ensure consistency and prevent path conflicts, exclude certain folders from version control and use scripts to handle the relevant files.
  11. Can I use Git and Vitis to directly edit source files?
  12. Yes, but make sure the right source directories are pointed to in your CMake setup. It's possible that Vitis will incorrectly identify names and includes for syntax highlighting.
  13. What are the advantages of setting up projects with scripts?
  14. Scripts make guarantee that projects are set up consistently and repeatedly, which minimizes human mistake and makes cross-environment collaboration easier.
  15. If modifications are made, how can I update my project setup?
  16. Rerun your automation scripts after making the necessary modifications to them. This guarantees that all required updates are implemented accurately.
  17. What should I do in the event that path problems cause build errors?
  18. Verify the project setup scripts to make sure all paths are set up appropriately. When at all possible, use relative paths to prevent conflicts.

Crucial Elements of Effective Version Control in the Vitis IDE

There are a few essential steps involved in implementing version control with the new Unified Vitis IDE. To start preventing conflicts and mistakes, start by removing directories created by Vitis from version control. Rather, concentrate on maintaining track of CMake files, linker scripts, and other important project components. This procedure can be greatly streamlined by automation scripts, especially those written in Python, which can automate project setup and make sure all required files are in the right places.

You may guarantee a consistent development environment across several systems by automating the setup, which lowers the possibility of path-related problems. This method makes project management easier while also promoting more seamless developer collaboration. Furthermore, version control and editing are made simpler by leaving the source files in their original locations and pointing CMake to them, all without having to deal with the difficulties of handling Vitis's internal file structures.

Completing the Vitis and Git Workflow

To handle version control efficiently when integrating Git with the Unified Vitis IDE, a calculated strategy is necessary. Developers can steer clear of frequent issues related to absolute paths and IDE-specific metadata by eliminating Vitis-managed folders and concentrating on necessary configuration files. Automation scripts give a uniform and repeatable project setup, which improves this procedure even further. These tactics guarantee that, even in challenging development settings, Vitis projects stay cooperative and manageable.