aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2021-11-16 16:26:41 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2021-11-17 15:07:46 +0100
commit8948704d4a74a2989bd0284d8c030d1af96c8281 (patch)
tree6aa118ce041035733414603b6e11940567e61374
parentf61ea359bb733bedeaa8fefd81775708081de803 (diff)
downloadethos-u-core-platform-8948704d4a74a2989bd0284d8c030d1af96c8281.tar.gz
Add support for Ninja
Add support for Ninja buider under both Linux and Windows. Updating generate_binaries.py to produce dependencies file. Removing files by wild card does not work with Ninja under Windows. Change-Id: I486463603de7413e09edcd959c329253867f4564
-rw-r--r--README.md22
-rw-r--r--README_WINDOWS.md48
-rw-r--r--cmake/helpers.cmake5
-rwxr-xr-xscripts/generate_binaries.py10
4 files changed, 28 insertions, 57 deletions
diff --git a/README.md b/README.md
index e8281b3..278f54d 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,9 @@ downloaded from the Ecosystem page at
## Building
-Building core platform requires a recent version of CMake to be installed
-together with a compiler capable of cross compiling for Arm Cortex-M. There are
-sample toolchain files provided for Arm Clang and Arm GCC.
+Building core platform requires a recent version of CMake, Python 3 and a C/C++
+cross comiler for Arm Cortex-M. There are sample toolchain files provided for
+Arm Clang and Arm GCC.
To run the helper scripts Python 3 is required with the packages listed in
`requirements.txt`.
@@ -47,8 +47,20 @@ $ cmake -B build targets/corstone-300 -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchai
$ cmake --build build
```
-Please see [README_WINDOWS.md](README_WINDOWS.md) for additional information
-regarding building on a Windows system.
+## Building on Windows
+
+Building on a Windows host requires no special tools or shells, and can for
+example be done from a CMD prompt, Git Bash or from the CMake GUI. Only
+requirment is the build tools have been added to the path variable.
+
+CMake supports a long list of generators, for example Ninja, NMake or Makefiles.
+For Windows Ninja has been verified to work well, but any of the supported
+generators should be possible to use.
+
+```
+CMD> cmake -G Ninja -B build targets/corstone-300 -DCMAKE_TOOLCHAIN_FILE=%CD%\cmake\toolchain\arm-none-eabi-gcc.cmake
+CMD> cmake --build build
+```
## run_platform.py
diff --git a/README_WINDOWS.md b/README_WINDOWS.md
deleted file mode 100644
index d453cd9..0000000
--- a/README_WINDOWS.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Building on Windows Systems
-Linux is the main development environment recommended ("Windows Subsystem for
-Linux" can be used for a full Linux Bash environment under Windows), especially
-with regards to building the TensorFlow Lite for Microcontrollers (TFLu)
-library, which depends on GNU Make and are using a number of Bash shell scripts.
-However, there are a number of possibilities for building on a Windows system.
-
-## Requirements
-- **CMake**. E.g. Windows native CMake, MSYS CMake, Cygwin CMake, or MinGW
- CMake. (Note: Supported generators may differ).
-- **make tool**. E.g. GNU Make, NMAKE, Jom, mingw32-make, GNU Make under MSYS or
- Cygwin.
-- **ARM toolchain**.
- [Arm Clang](https://developer.arm.com/tools-and-software/embedded/arm-compiler)
- or
- [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm)
-
-### Building with TensorFlow Lite for Microcontrollers
-- **Shell**. E.g. "MSYS shell", "GIT Bash", or "Cygwin Terminal"
-- **GNU Make**. (NOTE: required when building TFLu even if another generator is
- used in CMake).
-- **GNU Wget**.
-
-### Using a prebuilt TensorFlow Lite for Microcontrollers library
-A prebuilt TFLu library can be supplied via the variable
- `TFLU_PREBUILT_LIBRARY_PATH`. The project can then be built without the
-requirements under
-[Building with TensorFlow Lite for Microcontrollers](#Building-with-TensorFlow-Lite-for-Microcontrollers)
-(apart from the initially build of the library).
-
-## Troubleshooting
-There are many options for tools and environment to build in, and the behaviour
-in each specific development environment might differ slightly.
-
-* Cross drive locations might not work. If this is the case mount to a usable
- path in the shell used.
-* There might be issues with NSYS/CMake and some toolchain paths, i.e. 'Program
- Files (x86)'. Can be solved by mounting in MSYS to a usable path, or the
- native Windows CMake can be called from the MSYS shell.
-* GNU Wget is needed for downloads in TFLu.
-* There might be issues rebuilding with CMake 3.20, with erroneous dependency
- make files generated. Update to CMake 3.20.1, or downgrade to an earlier CMake
- version.
-* May need to unset TMPDIR environmental variable to get FlatBuffers download in
- TFLu to work.
-* When using Cygwin Terminal there might be error messages concerning '\r' in
- the TFLu Bash scripts. In this case run dos2unix on these scripts.
-
diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake
index f9c3be0..11c57d0 100644
--- a/cmake/helpers.cmake
+++ b/cmake/helpers.cmake
@@ -64,7 +64,6 @@ function(ethosu_eval_link_options target)
add_custom_command(
OUTPUT ${LINK_FILE_OUT}
DEPENDS ${LINK_FILE_IN}
- BYPRODUCTS ${LINK_FILE_OUT}
COMMAND ${CMAKE_C_COMPILER} ${COMPILER_PREPROCESSOR_OPTIONS} -o ${LINK_FILE_OUT} ${LINK_FILE_IN}
COMMAND_EXPAND_LISTS "-D$<JOIN:${prop},;-D>"
COMMAND_EXPAND_LISTS "-I$<JOIN:$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>,;-I>"
@@ -148,8 +147,8 @@ function(ethosu_add_binaries target)
set(SCRIPTS_DIR ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../scripts)
add_custom_command(TARGET ${target} POST_BUILD
- COMMAND ${SCRIPTS_DIR}/generate_binaries.py --output ./fw $<TARGET_FILE:${target}>
- BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/fw/*
+ COMMAND ${SCRIPTS_DIR}/generate_binaries.py --output ./fw $<TARGET_FILE:${target}> -d ${target}.d
+ DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${target}.d
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generate binaries for ${target}")
endfunction()
diff --git a/scripts/generate_binaries.py b/scripts/generate_binaries.py
index 8eccc14..705bff8 100755
--- a/scripts/generate_binaries.py
+++ b/scripts/generate_binaries.py
@@ -26,7 +26,8 @@ import sys
import elftools.elf.elffile as elffile
def generate_binaries(args):
- load_segments = [];
+ outfiles = []
+
with open(args.input, 'rb') as f:
elf = elffile.ELFFile(f)
for segment in elf.iter_segments():
@@ -38,9 +39,16 @@ def generate_binaries(args):
with open(out, 'wb') as of:
of.write(segment.data())
+ outfiles.append(out)
+
+ if args.d:
+ with open(args.d, 'w') as f:
+ f.writelines(outfiles)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate binaries from ELF file')
parser.add_argument('-o', '--output', default='.', required=False, help='Output directory for binaries')
+ parser.add_argument('-d', help='Dependency file')
parser.add_argument('input', metavar='inputfile', type=str, help='ELF file to extract binaries from')
args = parser.parse_args()