Skip to content

Commit

Permalink
ports/psoc6: Added bsp assets version control mechanism.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <[email protected]>
  • Loading branch information
jaenrig-ifx committed Oct 24, 2024
1 parent e55dd56 commit 8878cb7
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ports/psoc6/boards/CY8CKIT-062S2-AI/bsp-deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"asset-name": "cat1cm0p",
"locked-commit": "release-v1.7.0"
},
{
"asset-name": "cmsis",
"locked-commit": "release-v5.8.1"
},
{
"asset-name": "core-lib",
"locked-commit": "release-v1.4.2"
},
{
"asset-name": "core-make",
"locked-commit": "release-v3.3.1"
},
{
"asset-name": "device-db",
"locked-commit": "release-v4.18.0"
},
{
"asset-name": "mtb-hal-cat1",
"locked-commit": "release-v2.6.1"
},
{
"asset-name": "mtb-pdl-cat1",
"locked-commit": "release-v3.12.0"
},
{
"asset-name": "recipe-make-cat1a",
"locked-commit": "release-v2.2.1"
}
]
34 changes: 34 additions & 0 deletions ports/psoc6/boards/CY8CPROTO-062-4343W/bsp-deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"asset-name": "cat1cm0p",
"locked-commit": "release-v1.7.0"
},
{
"asset-name": "cmsis",
"locked-commit": "release-v5.8.1"
},
{
"asset-name": "core-lib",
"locked-commit": "release-v1.4.2"
},
{
"asset-name": "core-make",
"locked-commit": "release-v3.3.1"
},
{
"asset-name": "device-db",
"locked-commit": "release-v4.18.0"
},
{
"asset-name": "mtb-hal-cat1",
"locked-commit": "release-v2.6.1"
},
{
"asset-name": "mtb-pdl-cat1",
"locked-commit": "release-v3.12.0"
},
{
"asset-name": "recipe-make-cat1a",
"locked-commit": "release-v2.2.1"
}
]
34 changes: 34 additions & 0 deletions ports/psoc6/boards/CY8CPROTO-063-BLE/bsp-deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"asset-name": "cat1cm0p",
"locked-commit": "release-v1.7.0"
},
{
"asset-name": "cmsis",
"locked-commit": "release-v5.8.1"
},
{
"asset-name": "core-lib",
"locked-commit": "release-v1.4.2"
},
{
"asset-name": "core-make",
"locked-commit": "release-v3.3.1"
},
{
"asset-name": "device-db",
"locked-commit": "release-v4.18.0"
},
{
"asset-name": "mtb-hal-cat1",
"locked-commit": "release-v2.6.1"
},
{
"asset-name": "mtb-pdl-cat1",
"locked-commit": "release-v3.12.0"
},
{
"asset-name": "recipe-make-cat1a",
"locked-commit": "release-v2.2.1"
}
]
2 changes: 2 additions & 0 deletions ports/psoc6/mtb-libs/makefile_mtb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ mtb_config_deps:
$(info Configuring ModusToolbox dependencies ...)
$(info mtb_deps_dir : $(MTB_LIBS_DIR)/deps/$(MTB_DEPS_DIRS)/)
$(Q) $(foreach DIR, $(MTB_DEPS_DIRS), $(shell cp -r $(MTB_LIBS_DIR)/deps/$(DIR)/. $(MTB_LIBS_DIR)/deps))
$(info mtb_bsp_deps_dir : Updating dependencies for $(BOARD) ...)
$(Q) bash $(MTB_LIBS_DIR)/mtb_bsp_set_deps_ver.sh $(BOARD)

mtb_get_libs: mtb_config_deps
$(info )
Expand Down
81 changes: 81 additions & 0 deletions ports/psoc6/mtb-libs/mtb_bsp_set_deps_ver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/bash

# This script will be use to set the dependencies version in the bsps deps/ folder.

# Why we need this script?
# --------------------------------
# The ModusTooolbox sets a fix version for the bsp repo sources, but the version of the dependencies
# are not fixed. They are handled by the manifest system instead.
# As we are not keeping these bsps under version control, but we retrieve them when initializing
# the project, we will always get the latest version of the bsp dependencies (according to the manifest configuration).
# We don´t want libraries to be updated without our knowledge, so we will set the dependencies version with this script.

# Move to the directory where the script is located
cd "$(dirname "$0")"

board=$1
# Pass "-d" as the second argument to enable debug mode
debug=$2

json_file_default_name="bsp-deps.json"
json_file="../boards/$board/$json_file_default_name"
bsp_deps_dir="bsps/TARGET_APP_$board/deps"

if [ ! -f "$json_file" ]; then
echo "JSON file not found: $json_file"
exit 1
fi

# Read the JSON file line by line
while IFS= read -r line; do
# Extract the asset-name
if [[ $line =~ \"asset-name\":\ \"([^\"]+)\" ]]; then
asset_name="${BASH_REMATCH[1]}"
fi

# Extract the locked-commit
if [[ $line =~ \"locked-commit\":\ \"([^\"]+)\" ]]; then
locked_commit="${BASH_REMATCH[1]}"

# Print the extracted values if -d flag is passed
if [ "$debug" == "-d" ]; then
echo "Asset Name: $asset_name"
echo "Locked Commit: $locked_commit"
echo "-------------------------"
fi

# Iterate over each file in the BSP_DEPS_DIR directory
for file in "$bsp_deps_dir"/*; do
if [ -f "$file" ]; then
# Get the file name without the extension
filename=$(basename -- "$file")
filename="${filename%.*}"

# Check if the file name matches the asset name
if [ "$filename" == "$asset_name" ]; then

if [ "$debug" == "-d" ]; then
echo "Match found: $file matches asset name $asset_name"
fi

# Read the content of the .mtbx file
content=$(cat "$file")

# Replace the version pattern with the locked-commit value
updated_content=$(echo "$content" | sed -E "s/release-v[0-9]+\.[0-9]+\.[0-9]+/$locked_commit/g")

# Write the updated content back to the .mtbx file
echo "$updated_content" > "$file"

echo "Updated $file with locked commit $locked_commit"
else
if [ "$debug" == "-d" ]; then
echo "No match: $file does not match asset name $asset_name"
fi
fi
fi
done
fi
done < "$json_file"

exit 0

0 comments on commit 8878cb7

Please sign in to comment.