Skip to content

Commit

Permalink
Merge pull request #45 from nbosb/dev-restructure
Browse files Browse the repository at this point in the history
Restructure
  • Loading branch information
nbosb authored Jul 30, 2024
2 parents dc33d6f + 5e41b67 commit 16abdd4
Show file tree
Hide file tree
Showing 48 changed files with 1,003 additions and 1,563 deletions.
2 changes: 1 addition & 1 deletion .clang-format
2 changes: 1 addition & 1 deletion .clang-tidy
16 changes: 6 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,25 @@ jobs:
submodules: 'recursive'

- name: Download software
working-directory: ./sw
run: |
wget https://github.com/aut0/avp64_sw/releases/latest/download/linux.tar.gz
tar -xvf linux.tar.gz
rm linux.tar.gz
wget https://github.com/aut0/avp64_sw/releases/download/v2024.07.30/buildroot_6_5_6.tar.gz
tar -xvf buildroot_6_5_6.tar.gz
rm buildroot_6_5_6.tar.gz
- name: Setup Dependencies
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install libelf-dev libsdl2-dev libvncserver-dev libslirp-dev
- name: Patch unicorn
run: |
git apply ${{github.workspace}}/patches/unicorn-*.patch
working-directory: ${{github.workspace}}/deps/ocx-qemu-arm/unicorn
sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev
- name: Configure
run: |
cmake \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} \
-DAVP64_BUILD_TESTS=ON \
-DOCX_QEMU_ARM_BUILD_TESTS=OFF
-DAVP64_BUILD_RUNNER=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}} -j $(nproc)
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,16 @@ jobs:
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install libelf-dev libsdl2-dev libvncserver-dev libslirp-dev clang-tidy
- name: Patch unicorn
run: |
git apply ${{github.workspace}}/patches/unicorn-*.patch
working-directory: ${{github.workspace}}/deps/ocx-qemu-arm/unicorn
sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev clang-tidy
- name: Configure
run: |
cmake \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DAVP64_BUILD_TESTS=ON \
-DOCX_QEMU_ARM_BUILD_TESTS=OFF \
-DAVP64_LINTER="clang-tidy" \
-DCMAKE_CXX_STANDARD=17
-DAVP64_BUILD_TESTS=OFF \
-DAVP64_BUILD_RUNNER=ON \
-DAVP64_LINTER="clang-tidy"
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j $(nproc)
60 changes: 60 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: cmake

on:
schedule:
- cron: '0 1 * * *'

env:
TARGET_ARCH: linux64
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false

name: Build AVP64

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Download software
working-directory: ./sw
run: |
wget https://github.com/aut0/avp64_sw/releases/download/v2024.07.30/buildroot_6_5_6.tar.gz
tar -xvf buildroot_6_5_6.tar.gz
rm buildroot_6_5_6.tar.gz
- name: Setup Dependencies
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev
- name: Configure
run: |
cmake \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DAVP64_BUILD_TESTS=ON \
-DAVP64_BUILD_RUNNER=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j $(nproc)

- name: Test
env:
LD_LIBRARY_PATH: ${{github.workspace}}/build/ocx-qemu-arm
working-directory: ${{github.workspace}}/build
run: |
ctest -C ${{env.BUILD_TYPE}} --output-on-failure --output-junit testreport.xml
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: ${{github.workspace}}/build/testreport.xml
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: 'recursive'

- name: Check code style
run: deps/vcml/utils/format -n
run: ./utils/format -n
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ gdbscript*
.vscode
.cache
compile_commands.json
linux-src/

9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "deps/ocx-qemu-arm"]
path = deps/ocx-qemu-arm
url = https://github.com/snps-virtualprototyping/ocx-qemu-arm
[submodule "deps/vcml"]
path = deps/vcml
url = https://github.com/machineware-gmbh/vcml
[submodule "cmake"]
path = cmake
url = https://github.com/machineware-gmbh/cmake.git
101 changes: 63 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,91 @@
##############################################################################
# #
# Copyright 2020 Lukas Jünger #
# Copyright 2024 Lukas Jünger, Nils Bosbach #
# #
# This software is licensed under the MIT license. #
# A copy of the license can be found in the LICENSE file at the root #
# of the source tree. #
# #
#############################################################################

cmake_minimum_required(VERSION 3.6)
project(avp64)
option(AVP64_BUILD_TESTS "Build unit tests" OFF)
##############################################################################

include(ExternalProject)
cmake_minimum_required(VERSION 3.12)
project(avp64 VERSION 2024.07.30 LANGUAGES C CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(AVP64_BUILD_TESTS "Build unit tests" OFF)
option(AVP64_BUILD_RUNNER "Build avp64 runner" ON)
set(AVP64_LINTER "" CACHE STRING "Code linter to use")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

set(CMAKE_EXE_LINKER_FLAGS -rdynamic)

set(OCX_QEMU_ARM_HOME $ENV{OCX_QEMU_HOME})
if(NOT EXISTS ${OCX_QEMU_ARM_HOME})
set(OCX_QEMU_ARM_HOME ${CMAKE_CURRENT_SOURCE_DIR}/deps/ocx-qemu-arm)
endif()

set(VCML_HOME $ENV{VCML_HOME})
if(NOT EXISTS ${VCML_HOME})
set(VCML_HOME ${CMAKE_CURRENT_SOURCE_DIR}/deps/vcml)
endif()

message(STATUS "Found OCX-QEMU-ARM at " ${OCX_QEMU_ARM_HOME})
message(STATUS "Found VCML at " ${VCML_HOME})
include(cmake/common.cmake)
find_github_repo(vcml "machineware-gmbh/vcml")

add_subdirectory(${OCX_QEMU_ARM_HOME} ocx-qemu-arm)
add_subdirectory(${VCML_HOME} vcml)
set(OCX_QEMU_ARM_BUILD_TESTS OFF CACHE BOOL "disable ocx tests")
find_github_repo(ocx-qemu-arm "nbosb/ocx-qemu-arm" "fix-namespace")

set(src "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(inc "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/ocx-qemu-arm/ocx/include")
set(inc "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(gen ${CMAKE_CURRENT_BINARY_DIR}/gen)

configure_file(${src}/avp64/version.h.in
${gen}/avp64/version.h @ONLY)

set(sources
${src}/arm64_cpu.cpp
${src}/system.cpp
${src}/main.cpp)
${src}/avp64/core.cpp
${src}/avp64/cpu.cpp
)

add_executable(avp64 ${sources})
add_library(avp64 STATIC ${sources})

set_target_properties(avp64 PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}")
target_compile_options(avp64 PRIVATE ${MWR_COMPILER_WARN_FLAGS})
target_include_directories(avp64 PUBLIC ${inc})
target_include_directories(avp64 PUBLIC ${gen})
target_include_directories(avp64 PUBLIC ${OCX_QEMU_ARM_HOME}/ocx/include)
target_link_libraries(avp64 PUBLIC ${CMAKE_DL_LIBS})
target_link_libraries(avp64 PUBLIC vcml)
set_target_properties(avp64 PROPERTIES CXX_STANDARD 17)
set_target_properties(avp64 PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}")
set_target_properties(avp64 PROPERTIES VERSION "${AVP64_VERSION}")
set_target_properties(avp64 PROPERTIES SOVERSION "${AVP64_VERSION_MAJOR}")

target_include_directories(avp64 PRIVATE ${inc})
if(NOT ${AVP64_LINTER} STREQUAL "")
# -std=c++17 is not passed to the compiler if it is the comiler's default
# this caused problems with clang-tidy
set_target_properties(avp64 PROPERTIES CXX_STANDARD_REQUIRED ON)
endif()

target_link_libraries(avp64 ${CMAKE_DL_LIBS})
target_link_whole_archives(avp64 vcml)
set_target_properties(ocx-qemu-arm PROPERTIES EXCLUDE_FROM_ALL FALSE)

install(TARGETS avp64 DESTINATION bin)
install(DIRECTORY config/ DESTINATION config)
install(TARGETS avp64)
install(TARGETS ocx-qemu-arm DESTINATION lib)
install(DIRECTORY sw/ DESTINATION sw)
install(DIRECTORY ${inc}/ DESTINATION include)
install(DIRECTORY ${gen}/ DESTINATION include)

if(AVP64_BUILD_TESTS)
message(STATUS "Building AVP64 tests")
enable_testing()
add_subdirectory(tests)
endif()

if(AVP64_BUILD_RUNNER)
add_executable(avp64-runner
${src}/avp64/system.cpp
${src}/avp64/main.cpp
)

target_compile_options(avp64-runner PRIVATE ${MWR_COMPILER_WARN_FLAGS})
target_include_directories(avp64-runner PRIVATE ${src})
set_target_properties(avp64-runner PROPERTIES CXX_STANDARD 17)
set_target_properties(avp64-runner PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}")
set_target_properties(avp64-runner PROPERTIES VERSION "${AVP64_VERSION}")
set_target_properties(avp64-runner PROPERTIES SOVERSION "${AVP64_VERSION_MAJOR}")
target_link_whole_archives(avp64-runner avp64)
target_link_whole_archives(avp64-runner vcml)

if(NOT ${AVP64_LINTER} STREQUAL "")
# -std=c++17 is not passed to the compiler if it is the comiler's default
# this caused problems with clang-tidy
set_target_properties(avp64-runner PROPERTIES CXX_STANDARD_REQUIRED ON)
endif()

install(TARGETS avp64-runner)
endif()
Loading

0 comments on commit 16abdd4

Please sign in to comment.