Skip to content

Commit

Permalink
Setup build workflow (#13)
Browse files Browse the repository at this point in the history
* .github/workflows: Add build and release workflow.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* ./tools: Add script to prepare release package.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* ./development-instructions.rst: Fix path to the package.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* examples/testSketch: Add an example sketch for CI test.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* .github/workflows: Refactor the release and compile steps.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* ./platform.txt: Refactor platform text.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* ./Makefile: Dynamically get the path to MTB tools.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* tools/dev-setup.sh: Add support to call individual function from the dev setup script.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

* .github/workflows: Fix the fbqn with new naming convention.

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>

---------

Signed-off-by: Ramya Subramanyam <ramya.subramanyam@infineon.com>
  • Loading branch information
ramya-subramanyam authored Oct 3, 2024
1 parent f75640c commit 151b1ef
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 36 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Arduino Core PSoC CI compile

# on which event should we start push, pull request or schedule dispatches
on:
- push
- pull_request

jobs:

# The build job compiles the sample code for different boards
build:

# we run this on self hosted runner, use labels to be more specific
# add specific names if there are some, otherwise self-hosted, X64, Linux are the default ones
runs-on:
- self-hosted
- X64
- Linux
- PSoC

# which combination of sample code and boards should run
# for this example of 2 sample codes and 3 boards a total of 2x3=6 runners have to work.
# if we have only 4 runner then these 4 are started and the last 2 are waiting until they can start
strategy:

matrix:
# List of all examples in the lib to compile
example: [
examples/testSketch/testSketch.ino
]

# board packages we want to run
# attention the matrix spans over the fqbn not platform so that we can choose different boards
# this example compiles each sample code for Arduino Uno, XMC2Go and XMC4700 boards
fqbn: [
"infineon:psoc:cy8ckit_062s2_ai"
]

# include additional information for each fqbn, in this case the platform name to install
include:
- fqbn: "infineon:psoc:cy8ckit_062s2_ai"
platform: "infineon:psoc"

# These are the steps which should run for each combination of fqbn and example code
steps:

- name: Install/Update Arduino Platform
run: |
arduino-cli core update-index
arduino-cli core install ${{ matrix.platform }} --additional-urls https://github.com/Infineon/arduino-core-psoc/releases/latest/download/package_psoc_index.json
arduino-cli core list
- name: Remove latest installed platform version
run: |
cd ~/.arduino15/packages/infineon/hardware/psoc
rm -rf *
- name: Checkout repository
uses: actions/checkout@v4
#with:
#submodules: true
#recursive-submodules: true

- name: Setup environment
run: |
export REPO="$(basename "$GITHUB_REPOSITORY")"
bash ./tools/dev-setup.sh git_submodule_setup
- name: copy/link repository to arduino path
run: |
mkdir ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build
cp -a ~/actions-runner/_work/arduino-core-psoc/arduino-core-psoc/* ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build
cd ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build
- name: copy/link arduino core api path
run: |
mkdir ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build/cores/psoc/api
cp -a ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build/extras/arduino-core-api/api/* ~/.arduino15/packages/infineon/hardware/psoc/0.1.0-build/cores/psoc/api
# Compile the sample code for the selected board and board support package with the arduino compiler
- name: Compile Sketch
run: |
arduino-cli compile --clean --verbose --fqbn ${{ matrix.fqbn }} ${{ matrix.example }}
14 changes: 9 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ on:
jobs:
release:
runs-on: ubuntu-latest

if: startsWith(github.ref, 'refs/tags/V')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Checkout actions
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install requests
Expand All @@ -26,14 +30,14 @@ jobs:

- name: Build release assets
run: |
cd .github/scripts
python release.py build-release ${{ github.repository }} ${{ github.ref_name }}
bash ./tools/dev-setup.sh
python ./tools/release.py build-release ${{ github.repository }} ${{ github.ref_name }}
- name: Upload assets
uses: softprops/action-gh-release@v1
with:
name: PSoC-for-Arduino ${{ github.ref_name }}
files: |
pkg_build/*.zip
pkg_build/package_infineon_index.json
pkg_build/package_psoc_index.json
body: ${{steps.build_changelog.outputs.changelog}}
2 changes: 1 addition & 1 deletion docs/development-instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Environment setup

::

cd packages/Infineon-psoc/hardware/psoc
cd packages/infineon/hardware/psoc

..
TODO: We already have the "Infineon" package (from XMC-for-Arduino). We should go for "infineon" instead of "infineon-psoc". And
Expand Down
18 changes: 18 additions & 0 deletions examples/testSketch/testSketch.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

double number;
double result;

// the setup function runs once when you press reset or power the board
void setup() {

// Define a number to calculate the square root of
number = 25.0;
}

// the loop function runs over and over again forever
void loop() {
// Loop to count from 0 to 100
for (int i = 0; i <= 100; i++) {
result = sqrt(number);
}
}
14 changes: 0 additions & 14 deletions mtb-libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,6 @@ CY_GETLIBS_SHARED_NAME=mtb_shared
# software provided compiler by default).
CY_COMPILER_GCC_ARM_DIR=


# Locate ModusToolbox helper tools folders in default installation
# locations for Windows, Linux, and macOS.
CY_WIN_HOME=$(subst \,/,$(USERPROFILE))
CY_TOOLS_PATHS ?= $(wildcard \
$(CY_WIN_HOME)/ModusToolbox/tools_* \
$(HOME)/ModusToolbox/tools_* \
/Applications/ModusToolbox/tools_*)

# If you install ModusToolbox software in a custom location, add the path to its
# "tools_X.Y" folder (where X and Y are the version number of the tools
# folder). Make sure you use forward slashes.
CY_TOOLS_PATHS+=

# Default to the newest installed tools folder, or the users override (if it's
# found).
CY_TOOLS_DIR=$(lastword $(sort $(wildcard $(CY_TOOLS_PATHS))))
Expand Down
12 changes: 5 additions & 7 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version=0.0.0
build.core.path={runtime.platform.path}/core
build.flash_ld_path={runtime.platform.path}/mtb-libs/bsps/TARGET_APP_{build.variant}/COMPONENT_CM4/TOOLCHAIN_GCC_ARM/linker.ld
build.mtb_libs_board_build_path={runtime.platform.path}/mtb-libs/build/APP_{build.variant}/Debug

build.lib_path={runtime.platform.path}/mtb-libs/libs/core-make.mtb
# Compiler and toolchain paths
# ---------

Expand Down Expand Up @@ -74,14 +74,12 @@ mtbshell={compiler.mtb_lib_tools.path}/modus-shell/bin/bash
# Prebuild Hooks

recipe.hooks.prebuild.1.pattern.windows=cmd /c if not exist "{build.flash_ld_path}" {libmanager}.exe --project {runtime.platform.path}/mtb-libs --add-bsp-name {build.variant} --add-bsp-version {build.board.version}
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.flash_ld_path}" {mtbshell}.exe -i -l -c "cd '{runtime.platform.path}/mtb-libs' && make getlibs BOARD={build.variant}"
recipe.hooks.prebuild.3.pattern.windows={libmanager} --project {runtime.platform.path}/mtb-libs --set-active-bsp APP_{build.variant}
recipe.hooks.prebuild.4.pattern.windows={mtbshell} -i -l -c "cd '{runtime.platform.path}/mtb-libs' && make build BOARD={build.variant}"
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.lib_path}" {mtbshell}.exe -i -l -c "cd '{runtime.platform.path}/mtb-libs' && make getlibs BOARD={build.variant} CY_TOOLS_PATHS={compiler.mtb_lib_tools.path}"
recipe.hooks.prebuild.4.pattern.windows={mtbshell} -i -l -c "cd '{runtime.platform.path}/mtb-libs' && make build BOARD={build.variant} CY_TOOLS_PATHS={compiler.mtb_lib_tools.path}"

recipe.hooks.prebuild.1.pattern.linux=/bin/sh -c 'if [ ! -f "{build.flash_ld_path}" ]; then {libmanager} --project "{runtime.platform.path}/mtb-libs" --add-bsp-name {build.variant} --add-bsp-version {build.board.version}; fi'
recipe.hooks.prebuild.2.pattern.linux=/bin/sh -c 'if [ ! -f "{build.flash_ld_path}" ]; then cd {runtime.platform.path}/mtb-libs && make build BOARD={build.variant}; fi'
recipe.hooks.prebuild.3.pattern.linux={libmanager} --project {runtime.platform.path}/mtb-libs --set-active-bsp APP_{build.variant}
recipe.hooks.prebuild.4.pattern.linux=/bin/sh -c 'cd {runtime.platform.path}/mtb-libs && make build BOARD={build.variant}'
recipe.hooks.prebuild.2.pattern.linux=/bin/sh -c 'if [ ! -f "{build.lib_path}" ]; then cd {runtime.platform.path}/mtb-libs && make getlibs BOARD={build.variant} CY_TOOLS_PATHS={compiler.mtb_lib_tools.path}; fi'
recipe.hooks.prebuild.4.pattern.linux=/bin/sh -c 'cd {runtime.platform.path}/mtb-libs && make build BOARD={build.variant} CY_TOOLS_PATHS={compiler.mtb_lib_tools.path}'

# Prebuild Hook to Fetch Compiler and Linker Flags from mtb-libs build

Expand Down
14 changes: 12 additions & 2 deletions tools/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,15 @@ function core_api_setup {
ln -sf ${core_api_submodule_dir}/api ${cores_psoc_dir}
}

git_submodule_setup
core_api_setup
# Check if a function name is passed as an argument
if [ $# -gt 0 ]; then
if declare -f "$1" > /dev/null; then
"$1"
else
echo "Function $1 not found"
exit 1
fi
else
git_submodule_setup
core_api_setup
fi
12 changes: 5 additions & 7 deletions .github/scripts/release.py → tools/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import os
import shutil

version = "0.2.0"
version = "0.1.0"

psoc_ino_root_path = os.path.relpath(
os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir)
os.getcwd()
)
build_dir_name = "pkg_build"
pkg_assets_build_path = os.path.join(psoc_ino_root_path, build_dir_name)
Expand All @@ -32,12 +32,10 @@ def mkdir_package_dir(version):
def build_package(pkg_name):
pkg_build_path = os.path.join(pkg_assets_build_path, pkg_name)

dirs_to_copy = ["cores", "libraries", "tools", "variants"]
dirs_to_copy = ["cores", "tools", "mtb-libs", "examples"]

files_to_copy = [
"boards.txt",
"keywords.txt",
"package.json",
"platform.txt",
"LICENSE.md",
"README.md",
Expand Down Expand Up @@ -73,14 +71,14 @@ def get_package_sha256(pkg):

def get_latest_package_index_json():
return requests.get(
"https://github.com/Infineon/arduino-core-psoc/releases/latest/download/package_infineon_index.json"
"https://github.com/Infineon/arduino-core-psoc/releases/download/0.0.0-none/package_psoc_index.json"
).json()


def get_local_package_index_json():
with open(
os.path.join(
psoc_ino_root_path, "package/package_infineon_index.template.json"
psoc_ino_root_path, "package/package_psoc_index.template.json"
),
"r",
) as f:
Expand Down

0 comments on commit 151b1ef

Please sign in to comment.