Skip to content

Commit

Permalink
Merge e330fb4 into 5b5566f
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-hb authored Oct 11, 2023
2 parents 5b5566f + e330fb4 commit fd497c9
Show file tree
Hide file tree
Showing 82 changed files with 22,379 additions and 45 deletions.
36 changes: 17 additions & 19 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
[submodule "rimage"]
path = rimage
# This is a _relative_ submodule URL. In some use cases it's better than
# an _absolute_ submodule URL, in other cases it's not. One size does
# unfortunately not fit all.
#
# Among other pages, http://blog.tremily.us/posts/Relative_submodules/
# has a good comparison
#
# If you use Zephyr you must also look at the comments in sof/west.yml.
#
# If you want to fork or mirror sof.git _without_ doing the same for
# rimage.git then your automation may want you to change and git commit
# an absolute URL in your branch. No need to git commit for interactive
# use; a local and temporary edit of this file is enough for interactive
# use because .gitmodules is used only once to --init[ialize]
# .git/config the first time. Then .gitmodules is never used again after
# cloning.
url = ../rimage
# This is required for non-Zephyr ("XTOS") configurations. Zephyr
# configs also get it from sof/west.yml which adds the burden of keeping
# both tomlc99 SHA1s synchronized but in practice this barely ever moves.
[submodule "tomlc99"]
path = tools/rimage/tomlc99
# This is a _absolute_ submodule URL. In some use cases it's
# better than an _relative_ submodule URL, in other cases it's
# not. One size does unfortunately not fit all. Among other
# pages, http://blog.tremily.us/posts/Relative_submodules/ has a
# good comparison.
#
# A local and temporary edit of this url can be enough because
# .gitmodules is used _only once_ to submodule --init[ialize]
# .git/config the first time. Then .gitmodules is never used
# again after cloning tomlc99 the first time.
url = https://github.com/thesofproject/tomlc99.git
branch = master
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ project(SOF C ASM)
set(SOF_ROOT_SOURCE_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(SOF_ROOT_BINARY_DIRECTORY "${PROJECT_BINARY_DIR}")

set(RIMAGE_TOP "${PROJECT_SOURCE_DIR}/rimage")
set(RIMAGE_TOP "${PROJECT_SOURCE_DIR}/tools/rimage")

# check git hooks
include(scripts/cmake/git-hooks.cmake)
Expand Down
1 change: 0 additions & 1 deletion rimage
Submodule rimage deleted from ac487e
18 changes: 12 additions & 6 deletions scripts/cmake/git-submodules.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# SPDX-License-Identifier: BSD-3-Clause

find_package(Git)
set(RIMAGE_CMAKE "${SOF_ROOT_SOURCE_DIRECTORY}/rimage/CMakeLists.txt")
set(RIMAGE_SUBMODULE "${SOF_ROOT_SOURCE_DIRECTORY}/rimage")
if(EXISTS "${RIMAGE_SUBMODULE}/CMakeLists.txt")
message(WARNING
"${RIMAGE_SUBMODULE} is deprecated and ignored"
)
endif()

find_package(Git)
set(TOMLC99_MAKE "${SOF_ROOT_SOURCE_DIRECTORY}/tools/rimage/tomlc99/Makefile")
if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")

if(EXISTS "${RIMAGE_CMAKE}")
if(EXISTS "${TOMLC99_MAKE}")

# As incredible as it sounds, some people run neither
# "git status" nor "git diff" every few minutes and not
Expand Down Expand Up @@ -36,10 +42,10 @@ if(GIT_FOUND AND EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git")
NOT CONFIG_LIBRARY)

message(FATAL_ERROR
"${RIMAGE_CMAKE} not found. You should have used 'git clone --recursive'. \
"${TOMLC99_MAKE} not found. You should have used 'git clone --recursive'. \
To fix this existing git clone run:
git submodule update --init --merge --recursive
git submodule update --init --merge tools/rimage/tomlc99
")
endif() # rimage/CMakeLists.txt
endif() # tomlc99/Makefile

endif() # .git/
15 changes: 6 additions & 9 deletions scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def clean_staging(platform):
# for now we must stick to `sof/rimage/[tomlc99]` for
# backwards-compatibility with XTOS platforms and git submodules, see more
# detailed comments in west.yml
RIMAGE_SOURCE_DIR = west_top / "sof" / "rimage"
RIMAGE_SOURCE_DIR = west_top / "sof" / "tools" / "rimage"


def rimage_west_configuration(platform_dict, dest_dir):
Expand Down Expand Up @@ -563,14 +563,11 @@ def rimage_west_configuration(platform_dict, dest_dir):

def build_rimage():

# Detect non-west rimage duplicates, example: git submdule
# SOF_TOP/rimage = sof2/rimage
nested_rimage = pathlib.Path(SOF_TOP, "rimage")
if nested_rimage.is_dir() and not nested_rimage.samefile(RIMAGE_SOURCE_DIR):
raise RuntimeError(
f"""Two rimage source directories found.
Move non-west {nested_rimage} out of west workspace {west_top}.
See output of 'west list'."""
old_rimage_loc = SOF_TOP / "rimage"
# Don't warn on empty directories
if ( old_rimage_loc / "CMakeLists.txt" ).exists():
warnings.warn(f"""{old_rimage_loc} is now ignored,
new location is {RIMAGE_SOURCE_DIR}"""
)
rimage_dir_name = RIMAGE_BUILD_DIR.name
# CMake build rimage module
Expand Down
2 changes: 1 addition & 1 deletion smex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ target_link_options(smex PRIVATE

target_include_directories(smex PRIVATE
"${SOF_ROOT_SOURCE_DIRECTORY}/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}/rimage/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}/tools/rimage/src/include"
)

# TODO: smex should not need RTOS headers: FIX.
Expand Down
2 changes: 1 addition & 1 deletion tools/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_compile_options(sof-logger PRIVATE

target_include_directories(sof-logger PRIVATE
"${SOF_ROOT_SOURCE_DIRECTORY}/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}/rimage/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}/tools/rimage/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}"
)

Expand Down
6 changes: 6 additions & 0 deletions tools/rimage/.checkpatch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--codespell
--codespellfile scripts/spelling.txt
--ignore C99_COMMENT_TOLERANCE
--no-tree
--strict
-g
25 changes: 25 additions & 0 deletions tools/rimage/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# Basic build test

name: build

# yamllint disable-line rule:truthy
on: [pull_request, push, workflow_dispatch]

env:
CMAKE_C_FLAGS: "-Werror -Wall -Wmissing-prototypes\
-Wimplicit-fallthrough=3 -Wpointer-arith"

jobs:
build-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with: {fetch-depth: 50, submodules: recursive}

- name: install tools
run: sudo apt update && sudo apt install -y ninja-build

- name: build
run: cmake -B build/ -G Ninja
- run: cmake --build build/
30 changes: 30 additions & 0 deletions tools/rimage/.github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# SPDX-License-Identifier: BSD-3-Clause
# Tools that can save round-trips to github and a lot of time:
#
# yamllint -f parsable this.yml
# pip3 install ruamel.yaml.cmd
# yaml merge-expand this.yml exp.yml && diff -w -u this.yml exp.yml
#
# github.com also has a powerful web editor that can be used without
# committing.

name: cppcheck

# yamllint disable-line rule:truthy
on: [pull_request, push]

jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with: {fetch-depth: 50, submodules: recursive}

- name: apt install cppcheck
run: sudo apt update && sudo apt-get -y install cppcheck

# TODO enable more types of checks as they are fixed
- name: run cppcheck
run: cppcheck --platform=unix32 --force --max-configs=1024
--inconclusive --quiet --inline-suppr .
42 changes: 42 additions & 0 deletions tools/rimage/.github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# SPDX-License-Identifier: BSD-3-Clause
# Tools that can save round-trips to github and a lot of time:
#
# yamllint -f parsable this.yml
# pip3 install ruamel.yaml.cmd
# yaml merge-expand this.yml exp.yml && diff -w -u this.yml exp.yml
#
# github.com also has a powerful web editor that can be used without
# committing.

name: codestyle

# yamllint disable-line rule:truthy
on: [pull_request]

jobs:
yamllint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50
submodules: recursive

- name: run yamllint
run: yamllint .github/workflows/*.yml
checkpatch:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: install codespell
run: sudo apt update && sudo apt install -y codespell

- name: checkpatch.pl PR review
uses: webispy/checkpatch-action@v9
env:
CHECKPATCH_COMMAND: ./scripts/checkpatch.pl
2 changes: 2 additions & 0 deletions tools/rimage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
.checkpatch-camelcase.git.*
67 changes: 67 additions & 0 deletions tools/rimage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.10)

project(SOF_RIMAGE C)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No CMAKE_BUILD_TYPE, defaulting to Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
endif()

add_executable(rimage
src/file_simple.c
src/cse.c
src/css.c
src/plat_auth.c
src/hash.c
src/pkcs1_5.c
src/manifest.c
src/ext_manifest.c
src/rimage.c
src/toml_utils.c
src/adsp_config.c
src/misc_utils.c
src/file_utils.c
src/elf_file.c
src/module.c
tomlc99/toml.c
)

set_property(TARGET rimage PROPERTY C_STANDARD 99)

target_compile_options(rimage PRIVATE
-Wall -Werror -Wmissing-prototypes -Wimplicit-fallthrough
)

if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 9.1)
target_compile_options(rimage PRIVATE -Wno-char-subscripts)
endif()

# Windows builds use MSYS2 https://www.msys2.org/ to get linux tools and headers.
# MSYS_INSTALL_DIR variable points to MSYS2 installation directory.
# You may pass it as environmental or cmake configure variable.
if(${CMAKE_HOST_WIN32})
cmake_minimum_required(VERSION 3.20)
if(DEFINED ENV{MSYS_INSTALL_DIR} AND NOT MSYS_INSTALL_DIR)
set(MSYS_INSTALL_DIR $ENV{MSYS_INSTALL_DIR})
endif()

if(MSYS_INSTALL_DIR)
cmake_path(IS_ABSOLUTE MSYS_INSTALL_DIR IS_MSYS_INSTALL_DIR_ABSOLUTE)
if(NOT IS_MSYS_INSTALL_DIR_ABSOLUTE)
message(FATAL_ERROR "Please provide absolute path to MSYS2 installation
setting MSYS_INSTALL_DIR env variable")
endif()
# Include standard posix headers. Requires pacman openssl-devel package.
cmake_path(APPEND MSYS_INSTALL_DIR "usr" "include" OUTPUT_VARIABLE MSYS_SYSTEM_INCLUDE_PATH)
target_include_directories(rimage PRIVATE "${MSYS_SYSTEM_INCLUDE_PATH}")
endif()
endif()

target_link_libraries(rimage PRIVATE crypto)

target_include_directories(rimage PRIVATE
src/include/
tomlc99/
)
Loading

0 comments on commit fd497c9

Please sign in to comment.