Add cross compile toolchains for arm & aarch64.
Change-Id: I2b192ff894a4051b652b68ee05eed2b4e8276aee
diff --git a/CMakeLists.txt b/CMakeLists.txt
index de15c9c..0600df9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,10 +2,12 @@
project(CPERParse)
include(FetchContent)
include(GoogleTest)
-include(FindSWIG)
-include(UseSWIG)
-find_package(PythonLibs 3 REQUIRED)
-find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED)
+if (NOT CMAKE_CROSSCOMPILING)
+ include(FindSWIG)
+ include(UseSWIG)
+ find_package(PythonLibs 3 REQUIRED)
+ find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED)
+endif()
# GoogleTest requires at least C++14.
set(CMAKE_CXX_STANDARD 14)
@@ -83,15 +85,17 @@
gtest_discover_tests(cper-tests WORKING_DIRECTORY bin/)
# Generate Python bindings with SWIG.
-include_directories(cperparse_pylib ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
-swig_add_library(cperparse_pylib
- TYPE STATIC
- LANGUAGE python
- SOURCES cper-parse.i
- OUTPUT_DIR lib/
-)
-swig_link_libraries(cperparse_pylib
- cper-parse
- json-c
- ${PYTHON_LIBRARIES}
-)
\ No newline at end of file
+if (NOT CMAKE_CROSSCOMPILING)
+ include_directories(cperparse_pylib ${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
+ swig_add_library(cperparse_pylib
+ TYPE STATIC
+ LANGUAGE python
+ SOURCES cper-parse.i
+ OUTPUT_DIR lib/
+ )
+ swig_link_libraries(cperparse_pylib
+ cper-parse
+ json-c
+ ${PYTHON_LIBRARIES}
+ )
+endif()
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index d645695..4947287 100644
--- a/LICENSE
+++ b/LICENSE
@@ -174,29 +174,4 @@
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/README.md b/README.md
index 4fd641f..2da277b 100644
--- a/README.md
+++ b/README.md
@@ -11,13 +11,22 @@
You should also have Python3 and associated libraries installed for the purposes of building the Python bindings.
## Building
-This project uses CMake (>=3.10). To build, simply run:
+This project uses CMake (>=3.10). To build for native architecture, simply run:
```
cmake .
make
```
A static library file for the parsing library will be written to `lib/`, and test executables will be written to `bin/`.
+### Cross Compilation
+To cross compile for ARM/AArch64 architecture from x86, instead use the below commands (ensure `cmake clean .` beforehand).
+You will need either the `arm-linux-gnueabi` or `aarch64-linux-gnu` toolchain installed.
+```bash
+cmake -DCMAKE_TOOLCHAIN_FILE="toolchains/arm-toolchain.cmake" -S. -Bbin # arm-linux-gnueabi
+cmake -DCMAKE_TOOLCHAIN_FILE="toolchains/aarch64-toolchain.cmake" -S. -Bbin # aarch64-linux-gnu
+make
+```
+
## Usage
This project comes with several binaries to help you deal with CPER binary and CPER-JSON. The first of these is `cper-convert`, which is a command line tool that can be found in `bin/`. With this, you can convert to and from CPER and CPER-JSON through the command line. An example usage scenario is below:
```