From 0d248364823c8176a81fa508b54d21b901c75f93 Mon Sep 17 00:00:00 2001 From: Dennis Buchhorn Date: Tue, 18 Jan 2022 12:09:12 +0100 Subject: [PATCH] feat: create scripts to automate workflow --- .gitignore | 3 + clean_and_recreate_all | 78 +++++++++++++++++++ init_after_clone | 26 +++++++ .../import_platform_only.tcl.gitsubstitute | 6 ++ 4 files changed, 113 insertions(+) create mode 100755 clean_and_recreate_all create mode 100755 init_after_clone create mode 100644 tcl_scripts/import_platform_only.tcl.gitsubstitute diff --git a/.gitignore b/.gitignore index 9eda234..6357923 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ vitis_pid*.str # ignore ide scripts /*_system/_ide/scripts/* + +# ignore local only files +.repo_initialized diff --git a/clean_and_recreate_all b/clean_and_recreate_all new file mode 100755 index 0000000..36fe592 --- /dev/null +++ b/clean_and_recreate_all @@ -0,0 +1,78 @@ +#!/bin/bash + +NO_PROMPT="false" +START_VITIS="false" +IMPORT_HW_PLATFORM_ONLY="false" + +REPO_INITIALIZED_FILE_EXISTS="false" + +for arg in "$@"; do + if [ $arg == "--no-prompt" ]; then + NO_PROMPT="true" + elif [ $arg == "--start-vitis" ]; then + START_VITIS="true" + elif [ $arg == "--import-hw-platform-only" ]; then + IMPORT_HW_PLATFORM_ONLY="true" + fi +done + +if [ $NO_PROMPT == "false" ]; then + read -p "!!! WARNING !!! All unstaged and untracked files will be deleted! Press ENTER to continue or CTRL+C to abort..." +fi + +echo "############################################################" +echo "# Delete all unstaged and untracked files ..." +echo "############################################################" +if [ -f ".repo_initialized" ]; then + REPO_INITIALIZED_FILE_EXISTS="true" +fi + +git clean -dfx + +if [ $REPO_INITIALIZED_FILE_EXISTS == "true" ]; then + touch .repo_initialized + echo "This file is checked by the 'init_after_clone' script." >> .repo_initialized +fi + +echo "############################################################" +echo "# Re-checkout current branch ..." +echo "############################################################" +git checkout + +echo "############################################################" +echo "# Create hardware platform ..." +echo "############################################################" +xsct scripts/platform_create.tcl + +if [ $IMPORT_HW_PLATFORM_ONLY == "true" ]; then + echo "############################################################" + echo "# Import hw_platform only to workspace ..." + echo "############################################################" + xsct scripts/import_platform_only.tcl +else + echo "############################################################" + echo "# Import all projects to workspace ..." + echo "############################################################" + xsct scripts/import_platform_and_projects.tcl +fi + +# Disable Vitis welcome screen +FILE=".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs" +touch $FILE +echo "eclipse.preferences.version=1" >> $FILE +echo "showIntro=false" >> $FILE + +echo "############################################################" +echo "# ... finished!" + +if [ $START_VITIS == "true" ]; then + echo "#" + echo "# Starting Vitis ..." + echo "############################################################" + + vitis -workspace . +else + echo "#" + echo "# Start Vitis with 'vitis -workspace .'" + echo "############################################################" +fi diff --git a/init_after_clone b/init_after_clone new file mode 100755 index 0000000..1061c27 --- /dev/null +++ b/init_after_clone @@ -0,0 +1,26 @@ +#!/bin/bash + +if [ -f ".repo_initialized" ]; then + echo "This repo is already initialized!" +else + if [ -f "README_PROJECT_TEMPLATE.md" ]; then + echo "First run after creation from template." + + rm -f README.md + mv README_PROJECT_TEMPLATE.md README.md + + touch .repo_initialized + echo "This file is checked by the 'init_after_clone' script." >> .repo_initialized + + git add README.md README_PROJECT_TEMPLATE.md + git commit -m "chore: replace template readme" + + git config --local core.hooksPath .githooks + + source ./clean_and_recreate_all --no-prompt --import-hw-platform-only + else + git config --local core.hooksPath .githooks + + source ./clean_and_recreate_all --no-prompt + fi +fi diff --git a/tcl_scripts/import_platform_only.tcl.gitsubstitute b/tcl_scripts/import_platform_only.tcl.gitsubstitute new file mode 100644 index 0000000..08d1320 --- /dev/null +++ b/tcl_scripts/import_platform_only.tcl.gitsubstitute @@ -0,0 +1,6 @@ +setws {$$${GITSUBSTITUTE_REPO_ROOT}} + +########################################################################################## +# !!! Leave the 'hw_platform' unchanged !!! +########################################################################################## +importprojects ./hw_platform