I have the same problem as this question but using git (instead of Mercurial) and also using the new “Unified Vitis”, which is based on VSCode (instead of the old one, based on Eclipse).
Vitis (both old and new) “supports” git, at least according to documentation. However, I don’t understand how they imagine this working and I haven’t seen a documented workflow that’s actually usable.
The old Vitis had an “import/export project Wizard”. This seems to be absent in the new Vitis. This post in Xilinx formus says that the import/export feature is not yet available in new Vitis but planned for the 2024.1 release. As for user guides, UG1400(2023-12-13) in section “Source Control” explains how to do git add
by clicking around in the Vitis GUI, but unfortunately not how to version control a project in such a way that someone else can actually use it.
I hope they find a better solution because, if I understand the workflow described there correctly, the import/export feature isn’t very nice.
The fundamental problem with version control in Vitis…
… seems to be that Vitis generates a lot of files that have a lot of absolute paths. Even when using the automatically generated .gitignore
, adding “everything else” to version control adds a lot of IDE-internal files that Vitis is constantly updating (even while the user doesn’t change any sources or configuration). Furthermore, these files contain a lot of absolute paths, which makes it unpractical to pull changes made on a different developer’s system (the project will fail with build errors).
My current solution…
… is to version control NOTHING inside the vitis-managed platform and application folders. Instead, I use the Vitis Python CLI and copy over only the “magic stuff” (linker script, CMake files, etc.) that Vitis expects to be there, as well as an empty source file to make Vitis happy.
My CMakeLists.txt then instructs the build system to take sources from my original source directory. The tree looks like this:
"ROOT_PATH"
├── build-vitis (NOT version controlled at all!
│ Vitis stuff: "platform" and "application" folders.)
├── build-vivado (Vivado output, e.g. the .xsa file)
├── src
│ ├── CMakeLists.txt
│ ├── lscript.ld
│ ├── main.cpp
| | (more sources in a directory tree...)
│ ├── NOTUSED.cpp
| | (empty file, copied over to make Vivado think it "has sources")
│ └── UserConfig.cmake
└── tools
├── build_app.py
└── ...
And build_app.py
(somewhat simplified):
import vitis
import os
ROOT_PATH = <path to directory containing `tools` directory, user specified or deduced from PWD>
# This is the folder that "belongs" to Vitis.
# I put it into my .gitignore.
VITIS_BUILD_DIR_PATH = os.path.abspath(
os.path.join(ROOT_PATH, "build-vitis")
)
os.makedirs(VITIS_BUILD_DIR_PATH, exist_ok=True)
EXPECTED_XSA_FILE_PATH = os.path.abspath(
os.path.join(ROOT_PATH, "build-vivado", "<filename>.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=os.path.join(MAIN_SRC_PATH),
files=[
# Note: the actual C/C++ sources are NOT imported!
"CMakeLists.txt",
"UserConfig.cmake",
"lscript.ld",
"NOTUSED.cpp" # empty
],
dest_dir_in_cmp="src",
)
comp.build()
Disadvantages
I don’t copy over the sources because I want to be able to edit them at the location they are version controlled. I have to copy over the “magic files” to where Vitis expects them because I DO NOT want to use symlinks for compatibility between e.g. Windows/Linux developer machines. This means that:
-
I have to “copy back” any changes (that I want to commit) made via Vitis to the configuration files (CMake, linker script, etc.) to my own
src
directory. The person asking about using Mercurial did this for all source code. -
By instructing CMake to take sources from my own directory, I can edit them in Vitis (though I usually don’t use Vitis at all when making major changes to source code) but it’s confused and doesn’t recognize includes/names any more in syntax highlighting etc.
Is there a better way?