如何将 git 与新的“Unified Vitis”IDE (Xilinx) 一起使用

问题描述 投票:0回答:1

我有与这个问题相同的问题,但是使用git(而不是Mercurial),并且还使用新的“Unified Vitis”,它基于VSCode(而不是旧的,基于Eclipse)。 Vitis的新旧版本有很大差异,这意味着这个问题不是重复的。

Vitis(新旧)“支持”git,至少根据文档是这样。然而,我不明白他们是如何想象这个工作的,而且我还没有看到实际可用的记录工作流程。

Vitis 有一个“导入/导出项目向导”。这一点在新款 Vitis 中似乎不存在。 Xilinx 论坛中的这篇文章 表示导入/导出功能在新 Vitis 中尚未提供,但计划在 2024.1 版本中提供。至于用户指南,“源代码控制”部分中的 UG1400(2023-12-13) 解释了如何通过在 Vitis GUI 中单击来执行 git add

,但不幸的是,没有如何以这样的方式对项目进行版本控制:其他人实际上可以使用它。

我希望他们找到更好的解决方案,因为如果我正确理解那里描述的工作流程,导入/导出功能不是很好。

Vitis 中版本控制的根本问题...

...似乎 Vitis 生成了

很多具有很多绝对路径的文件。即使使用自动生成的 .gitignore

,向版本控制添加“其他所有内容”也会添加 Vitis 不断更新的大量 IDE 内部文件(即使用户没有更改任何源或配置)。此外,这些文件包含大量绝对路径,这使得提取在不同开发人员的系统上所做的更改变得不切实际(项目将因构建错误而失败)。

我目前的解决方案...

... 是对 vitis 管理的平台和应用程序文件夹内的任何内容进行版本控制。相反,我使用 Vitis Python CLI 并仅复制 Vitis 期望存在的“神奇内容”(链接器脚本、CMake 文件等),以及一个空源文件以使 Vitis 满意。

然后,

我的 CMakeLists.txt 指示构建系统从我的

original 源目录中获取源代码。这棵树看起来像这样:

"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 └── ...

build_app.py

(稍微简化):

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()
克隆存储库后,这被称为 

vitis -s tools/build_app.py

(我的实际脚本检查平台/应用程序是否存在,并且仅在需要时更新它们......)。

缺点

我不会复制源代码,因为我希望能够在版本控制的位置对其进行编辑。我(认为我)

必须将“魔法文件”复制到 Vitis 期望的位置,因为我不想使用符号链接来实现例如之间的兼容性。 Windows/Linux 开发机器。 (另外,喜欢的问题说符号链接可能会导致问题。)这意味着:

  • 我必须将通过 Vitis 对配置文件(CMake、链接器脚本等)所做的任何更改(我想要提交)“复制回”我自己的

    src

     目录。询问
    使用 Mercurial 的人对所有源代码都这样做了。

  • 通过指示 CMake 从我自己的目录中获取源代码,我可以在 Vitis 中编辑它们(尽管在对源代码进行重大更改时我通常根本不使用 Vitis),但它很混乱并且无法识别任何包含/名称更多语法高亮等内容。

有更好的办法吗?

git embedded vitis
1个回答
0
投票
我使用的是 vitis 2024.1,但是导入/导出是通过

.zip

 实现的,在我看来,用 git 是无法使用的。

我通过 .xsa 文件生成平台并生成 2 个具有绝对路径的文件来解决这个问题,这是应用程序项目所需的。我通过 python 脚本实现了这一点。

有问题的文件是:

  • vitis-comp.json
    
    
  • app.yaml
    
    
我已将它们添加到我的

.gitignore

 中,复制文件并将它们重命名为 
app_template.yaml
 之类的名称,然后将它们添加到我的版本控制中。然后,我用 
${workspaceFolder}/realativePathToFile
 这样的占位符替换了绝对路径。

我编写了一个小Python脚本,它为我生成了

app.yaml

vitis-comp.json
,在克隆项目时必须运行该脚本。

对我来说,Vitis 现在可以打开应用程序项目并编译 .elf 文件。

优点

    这样我就不必接触我的来源和
  • CMakeLists.txt
  • 我可以在 Vitis 中编辑源代码,并且可以在 git 中找到更改。

缺点

    如果这些生成的文件被 vitis 更改,您必须找到更改并相应地调整
  • *_template
     文件。 (脚本至少可以警告您这些文件已被更改)。
  • 对于更复杂的文件,可能会有额外的文件。
python脚本:

import re import pathlib def replace_in_file(old_file, new_file, token, replacement): with open(old_file, "r") as sources: lines = sources.readlines() with open(new_file, "w") as sources: for line in lines: sources.write(re.sub(str(token), str(replacement), line)) #replace ${workspaceFolder} def replace_abs_paths(): # I have placed my script in ${workspaceFolder}/scripts, so maybe you have to adapt it workspace_path = pathlib.Path(__file__).parent.parent.resolve() replace_in_file( f"{workspace_path}/application_project/src/app_template.yaml", f"{workspace_path}/application_project/src/app.yaml", r"\$\{workspaceFolder\}", workspace_path ) replace_in_file( f"{workspace_path}/application_project/vitis-comp_template.json", f"{workspace_path}/application_project/vitis-comp.json", r"\$\{workspaceFolder\}", workspace_path ) replace_abs_paths()
app_template.yaml

domain_path: ${workspaceFolder}/application_project/export/cvc-blu-plat/sw/standalone_psu_cortexr5_0 app_src_dir: /opt/Xilinx/Vitis/2024.1/data/embeddedsw/lib/sw_apps/hello_world template: hello_world
vitis-comp_template.json

{ "name": "cvc-blu-sw", "type": "HOST", "platform": "${workspaceFolder}/application_project/export/cvc-blu-plat/cvc-blu-plat.xpfm", "domain": "standalone_psu_cortexr5_0", "cpuInstance": "psu_cortexr5_0", "cpuType": "cortex-r5", "os": "standalone", "configuration": { "componentType": "HOST", "hostToolchainConfigurations": [] }, "domainRealName": "standalone_psu_cortexr5_0", "applicationFlow": "EMBEDDED" }
    
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.