Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARCH "arm")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64")
set(ARCH "riscv64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv32")
set(ARCH "riscv32")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
set(ARCH "loong64")
else()
Expand Down Expand Up @@ -279,6 +281,9 @@ else()
elseif(ARCH STREQUAL "riscv64")
add_compile_options(-march=rv64gc)
add_compile_options(-mabi=lp64d)
elseif(ARCH STREQUAL "riscv32")
add_compile_options(-march=rv32gc)
add_compile_options(-mabi=ilp32d)
elseif(ARCH STREQUAL "loong64")
add_compile_options(-march=loongarch64)
add_compile_options(-mabi=lp64d)
Expand Down
43 changes: 43 additions & 0 deletions cmake/toolchains/riscv32-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Copyright (C) 2023 The Android Open Source Project
#
# 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.
#

if(UHDR_BUILD_CMAKE_TOOLCHAINS_RISCV32_LINUX_GNU_CMAKE_)
return()
endif()

set(UHDR_BUILD_CMAKE_TOOLCHAINS_RISCV32_LINUX_GNU_CMAKE_ 1)

set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "riscv32")

if("${CROSS}" STREQUAL "")
set(CROSS riscv32-linux-gnu-)
endif()

if(NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER ${CROSS}gcc)
endif()
if(NOT CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${CROSS}g++)
endif()
if(NOT AS_EXECUTABLE)
set(AS_EXECUTABLE ${CROSS}as)
endif()

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25 changes: 25 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,31 @@ This will generate the following files under `build_directory`:
**ultrahdr_app** - sample application <br>
**ultrahdr_unit_test** - unit tests <br>

#### Target - Linux Platform - RISC-V Arch (32 bit)

Install the prerequisite packages before building:

```sh
# Download from https://github.com/riscv-collab/riscv-gnu-toolchain/releases
sudo ln -s {your_dir}/riscv/bin/riscv32-unknown-linux-gnu-g++ /usr/bin/riscv32-linux-gnu-g++
sudo ln -s {your_dir}/riscv/bin/riscv32-unknown-linux-gnu-gcc /usr/bin/riscv32-linux-gnu-gcc
```

Compile:

```sh
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/riscv32-linux-gnu.cmake -DUHDR_BUILD_DEPS=1 ../
ninja
```

This will generate the following files under `build_directory`:

**libuhdr.so.{version}** - Shared library for the libuhdr API <br>
**libuhdr.so** - Symlink to shared library <br>
**libuhdr.a** - Static link library for the libuhdr API <br>
**ultrahdr_app** - sample application <br>
**ultrahdr_unit_test** - unit tests <br>

#### Target - Linux Platform - LOONG Arch (64 bit)

Install the prerequisite packages before building:
Expand Down