One advantage of the Vitis Unified IDE is the Workspace Journal file. This is a python file that reflects project managment actions taken in the GUI using the Vitis Python API. This acts as other way for users to share there workspaces. This technique is slightly similar to the Import/Export features except rather than be given the workspace, you are given the equivalent python code used to create the workspace allowing you to make your own modifications to it. After creating a Vitis workspace the user can send this file to a teammate and they can use it to rebuild the same workspace.
In this example we will look at how you can use python and bash scripting to create your workspace and manage it in Git. For ease of use we will take the already built workspace_journal.py from the ‘_ide’ folder in your project and add version control functionality to it. In this instance we will execute Git commands in python using the ‘subprocess’ module.
Load the workspace_journal.py file Here we can see the code used to build the Vitis workspace.
import vitis
client = vitis.create_client()
client.set_workspace(path="vitis_ws")
platform = client.create_platform_component(name = "zcu102_platform",hw_design = "$COMPONENT_LOCATION/../../zcu102/design_1_wrapper.xsa",os = "standalone",cpu = "psu_cortexa53_0",domain_name = "standalone_psu_cortexa53_0",generate_dtb = True)
platform = client.get_component(name="zcu102_platform")
status = platform.build()
comp = client.create_app_component(name="hello_world",platform = "$COMPONENT_LOCATION/../zcu102_platform/export/zcu102_platform/zcu102_platform.xpfm",domain = "standalone_psu_cortexa53_0",template = "hello_world")
comp = client.get_component(name="hello_world")
comp.build()
Now we want to add some code to handle the version control part.
We can use the following bash commands to upload the workspace to git.
git add .
git commit -m "Initial Commit"
git push $git_repo_path master
So we build the workspace with the python script and then push it with git commands.
One way that we can automate this in the one script is through the use of the make build automation tool. Make builds are configured through the use of a Makefile. The Makefile in the scripts folder of this tutorial shows how we can create a design and then push that workspace to a remote repository. The script walks through the full git flow from initialising a git repository then creating the working repo, build the workspace, commiting and pushing to the main git repo and then cloning that repo to another location.
make all
Note: The Makefile provided does not setup and use a remote github repo that is hosted on the github website as obviously it is not viable to pass user credentials into this tutorial. Therefore instead this script initialises a local git repo which requires no credentials and works entirely locally but behaves like a real Git workflow (git init, add, commit, push clone). However you can use this file as a reference and make edits to it so that you can use it in your own remote flow.