Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Natively

on:
push:
branches: '*'
pull_request:
branches: '*'

jobs:
build-py-script:
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
gcc: ['7-2017-q4', 'latest']
cmake: ['3.6.0', ''] # Empty string installs the latest CMake release
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}, gcc ${{ matrix.gcc }}, cmake ${{ matrix.cmake || 'latest'}}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Setup arm-none-eabi-gcc ${{ matrix.gcc }}
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: ${{ matrix.gcc }}
- name: Setup CMake ${{ matrix.cmake }}
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: ${{ matrix.cmake }}
- name: Install Ninja via PyPI
run: python -m pip install ninja
- name: Check Versions
run: |
arm-none-eabi-gcc --version
cmake --version
ninja --version
python --version
- name: Build default project using build.py
run: python build.py
- name: Upload hex file
uses: actions/upload-artifact@v1
with:
name: build-py-${{ matrix.os }}
path: MICROBIT.hex
- name: Prepare BLE example
run: |
rm codal.json
mv codal.ble.json codal.json
python -c "import pathlib; \
f=pathlib.Path('source/main.cpp'); \
f.write_text(f.read_text().replace('out_of_box_experience()', 'ble_test()'))"
cat codal.json
- name: Build BLE project using build.py
run: python build.py --clean
- name: Upload BLE hex file
uses: actions/upload-artifact@v1
with:
name: build-py-BLE-${{ matrix.os }}
path: MICROBIT.hex
40 changes: 40 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Static Analysis Report

on:
workflow_dispatch:
push:
branches: '*'
pull_request:
branches: '*'

jobs:
cppcheck:
runs-on: ubuntu-20.04
name: Run CppCheck against the codebase + libraries
steps:
- uses: actions/checkout@v3
- name: Install CppCheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Setup arm-none-eabi-gcc
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: latest
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v1
- name: Build default project using build.py
run: python build.py
- name: Run CppCheck
run: |
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
cppcheck --project=compile_commands.json --std=c++11 --template='### {id} - {file}:{line}\n**{severity}:** {message}\n```\n{code}\n```\n' 2> cppcheck.md
- name: Add CppCheck result to job summary
run: |
echo "## Cppcheck output" >> $GITHUB_STEP_SUMMARY
echo "$(cat cppcheck.md)" >> $GITHUB_STEP_SUMMARY
- name: Upload log file
uses: actions/upload-artifact@v1
with:
name: cppcheck.md
path: cppcheck.md
25 changes: 25 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build via Docker

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build using the Docker image
env:
DOCKER_BUILDKIT: 1
run: docker build -t microbit-tools --output type=local,dest=out .
- name: Directory Listing
run: ls -al
- name: Upload hex file
uses: actions/upload-artifact@v1
with:
name: Export from Docker
path: out/MICROBIT.hex
36 changes: 36 additions & 0 deletions .github/workflows/onRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Library Builds

on:
workflow_dispatch:
release:
types: [created]

jobs:
cppcheck:
runs-on: ubuntu-20.04
name: Build against Ubuntu-20.04 for release assets
steps:
- uses: actions/checkout@v3
- name: Install CppCheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck

- name: Setup arm-none-eabi-gcc
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: latest

- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v1

- name: Build default project using build.py
run: python build.py

- uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "build/*.a"
update_latest_release: true

5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"marus25.cortex-debug"
]
}
40 changes: 40 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"configurations": [
{
"name": "micro:bit PyOCD Cortex Debug",
"cwd": "${workspaceFolder}",
"executable": "build/MICROBIT",
"request": "launch",
"type": "cortex-debug",
"servertype": "pyocd",
"interface": "swd",
"device": "nrf52",
"targetId": "nrf52",
"svdFile": "libraries/codal-nrf52/nrfx/mdk/nrf52833.svd",
"preLaunchCommands": [
"load build/MICROBIT",
"enable breakpoint",
"monitor reset"
]
},

{
"name": "micro:bit OpenOCD Cortex Debug",
"cwd": "${workspaceFolder}",
"executable": "build/MICROBIT",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"interface/cmsis-dap.cfg",
"target/nrf52.cfg"
],
"interface": "swd",
"preLaunchCommands": [
"load build/MICROBIT",
"enable breakpoint",
"monitor reset"
]
}
]
}
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"tasks": [
{
"type": "shell",
"label": "CODAL build",
"command": "python build.py",
"windows": {
"command": "py build.py"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "CODAL clean build",
"command": "python build.py --clean",
"windows": {
"command": "py build.py --clean"
},
"group": {
"kind": "build",
"isDefault": false
}
}
]
}
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.6)

# include additional cmake
include(utils/cmake/JSONParser.cmake)
Expand Down Expand Up @@ -132,7 +132,7 @@ foreach(var ${device})
string(REGEX MATCH "[^device\.cmake_definitions\.]([A-Z,a-z,0-9,_,]+)" CODAL_CMAKE_DEFINITION "${var}")

set(${CODAL_CMAKE_DEFINITION} ${${var}})
endforeach()
endforeach()

#define any additional symbols specified by the target.
if("${device.definitions}" STRGREATER "")
Expand Down Expand Up @@ -182,12 +182,12 @@ if("${CODAL_DEFINITIONS}" STRGREATER "")
file(WRITE "${EXTRA_INCLUDES_NEW_PATH}" ${CODAL_DEFINITIONS})
configure_file(${EXTRA_INCLUDES_NEW_PATH} ${EXTRA_INCLUDES_PATH} COPYONLY)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${EXTRA_INCLUDES_PATH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${EXTRA_INCLUDES_PATH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include \"${EXTRA_INCLUDES_PATH}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${EXTRA_INCLUDES_PATH}\"")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PLATFORM_INCLUDES_PATH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${PLATFORM_INCLUDES_PATH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I\"${PLATFORM_INCLUDES_PATH}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I\"${PLATFORM_INCLUDES_PATH}\"")

# a define for cmake if statements to detect if within the CODAL build environment
set(CODAL_BUILD_SYSTEM TRUE)
Expand Down Expand Up @@ -232,13 +232,17 @@ endif()

#finally, find sources and includes of the application, and create a target.
RECURSIVE_FIND_DIR(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.h")
RECURSIVE_FIND_DIR(HPP_DIRS "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.hpp")
list(APPEND INCLUDE_DIRS ${HPP_DIRS})

# *.c?? only catches .cpp, not .c, so let's be precise
RECURSIVE_FIND_FILE(SOURCE_FILES "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.cpp")

RECURSIVE_FIND_FILE(S_FILES "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.s")
RECURSIVE_FIND_FILE(C_FILES "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.c")
RECURSIVE_FIND_FILE(CC_FILES "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.cc")
list(APPEND SOURCE_FILES ${S_FILES})
list(APPEND SOURCE_FILES ${C_FILES})
list(APPEND SOURCE_FILES ${CC_FILES})

if("${SOURCE_FILES}" STREQUAL "")
message(FATAL_ERROR "${BoldRed}No user application to build, please add a main.cpp at: ${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}${ColourReset}")
Expand All @@ -262,4 +266,4 @@ endif()
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_EXE_EXPORTS_C_FLAG "")
set(CMAKE_EXE_EXPORTS_CXX_FLAG "")
set(CMAKE_EXE_EXPORTS_CXX_FLAG "")
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:18.04 as builder

RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
Expand All @@ -13,6 +13,13 @@ RUN apt-get update -qq && \
rm -rf /var/lib/apt/lists/*

# Project sources volume should be mounted at /app
WORKDIR /app
COPY . /opt/microbit-samples
WORKDIR /opt/microbit-samples

ENTRYPOINT ["python3", "build.py"]
RUN python3 build.py

FROM scratch AS export-stage
COPY --from=builder /opt/microbit-samples/MICROBIT.bin .
COPY --from=builder /opt/microbit-samples/MICROBIT.hex .

ENTRYPOINT ["/bin/bash"]
Loading