Skip to content

Commit

Permalink
Add NAV sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuAuahDark committed Jul 28, 2024
1 parent 9b362db commit 3d11743
Show file tree
Hide file tree
Showing 40 changed files with 5,262 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/libraries/nav/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build
on: [push, pull_request]

jobs:
Windows:
runs-on: windows-latest
strategy:
matrix:
PLATFORM: [x64, ARM64]
defaults:
run:
shell: cmd
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get FFmpeg
uses: robinraju/release-downloader@v1
with:
repository: GyanD/codexffmpeg
tag: "6.0"
fileName: ffmpeg-6.0-full_build-shared.7z
tarBall: false
zipBall: false
# A note to myself and other: FFmpeg build is for x64, but it doesn't matter. Only the include files are
# necessary for NAV to work as it will use runtime loading.
- name: Extract FFmpeg
run: 7z x ffmpeg-6.0-full_build-shared.7z
- name: Configure
run: cmake -Bbuild -S. -A ${{ matrix.PLATFORM }} --install-prefix %CD%\install -DBUILD_SHARED_LIBS=1 -DFFMPEG_DIR=%CD%\ffmpeg-6.0-full_build-shared
- name: Install
run: cmake --build build --config RelWithDebInfo --target install -j%NUMBER_OF_PROCESSORS%
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: nav-dll-${{ matrix.PLATFORM }}
path: install/
compression-level: 9
Ubuntu:
runs-on: ubuntu-24.04
steps:
- name: Install FFmpeg Development Libraries
run: sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev
- name: Checkout
uses: actions/checkout@v4
- name: Configure
run: cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo --install-prefix $PWD/install -DBUILD_SHARED_LIBS=1
- name: Install
run: cmake --build build --target install -j$(nproc)
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: nav-so-x86_64
path: install/
compression-level: 9
43 changes: 43 additions & 0 deletions src/libraries/nav/.github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Doxygen
on:
push:
branches: [main]
release:
types: [released]

concurrency:
group: "docs"
cancel-in-progress: false

jobs:
Documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout Main Repository
uses: actions/checkout@v4
with:
path: nav
fetch-depth: 2
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
path: docs
ref: gh-pages
- name: Generate Documentation
uses: mattnotmitt/[email protected]
with:
working-directory: nav
- name: Cleanup Branch
if: github.event_name == 'push'
run:
rm -rf docs/${{ github.ref_name }}
- name: Move Generated Docs
run: sudo mv nav/docs/html docs/${{ github.ref_name }}
- name: Add and Commit
uses: EndBug/add-and-commit@v9
with:
cwd: docs
add: ${{ github.ref_name }}
default_author: github_actions
message: 'Build ${{ github.sha }} of ${{ github.ref_name }}'
push: true
4 changes: 4 additions & 0 deletions src/libraries/nav/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.vscode
build
docs
install
109 changes: 109 additions & 0 deletions src/libraries/nav/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
cmake_minimum_required(VERSION 3.21)
project(nav LANGUAGES C CXX)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Read version
file(READ include/nav/nav.h NAV_INCLUDE_H LIMIT 1024)
string(REGEX MATCH "#define NAV_VERSION_MAJOR ([0-9+])" _ "${NAV_INCLUDE_H}")
set(NAV_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define NAV_VERSION_MINOR ([0-9+])" _ "${NAV_INCLUDE_H}")
set(NAV_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define NAV_VERSION_PATCH ([0-9+])" _ "${NAV_INCLUDE_H}")
set(NAV_VERSION_PATCH ${CMAKE_MATCH_1})

# Public include files
set(NAV_PUBLIC_INCLUDE
include/nav/audioformat.h
include/nav/input.h
include/nav/nav.h
include/nav/types.h
)

# Shared/static library
if(NOT DEFINED NAV_SHARED)
if(BUILD_SHARED_LIBS)
set(NAV_SHARED_DEFAULT 1)
else()
set(NAV_SHARED_DEFAULT 0)
endif()
endif()
option(NAV_SHARED "NAV: Build as shared library" ${NAV_SHARED_DEFAULT})

if(NAV_SHARED)
set(NAV_SHARED_VALUE SHARED)
else()
set(NAV_SHARED_VALUE STATIC)
endif()

add_library(nav ${NAV_SHARED_VALUE}
${NAV_PUBLIC_INCLUDE}
src/nav.cpp
src/nav_backend.cpp
src/nav_backend.hpp
src/nav_backend_androidndk.cpp
src/nav_backend_androidndk.hpp
src/nav_backend_androidndk_funcptr.h
src/nav_backend_androidndk_internal.hpp
src/nav_backend_ffmpeg.cpp
src/nav_backend_ffmpeg.hpp
src/nav_backend_ffmpeg_funcptr.h
src/nav_backend_ffmpeg_internal.hpp
src/nav_backend_mediafoundation.cpp
src/nav_backend_mediafoundation.hpp
src/nav_backend_mediafoundation_internal.hpp
src/nav_common.cpp
src/nav_common.hpp
src/nav_config.hpp
src/nav_dynlib.cpp
src/nav_dynlib.hpp
src/nav_error.cpp
src/nav_error.hpp
src/nav_input_file.cpp
src/nav_input_file.hpp
src/nav_input_memory.cpp
src/nav_input_memory.hpp
src/nav_internal.hpp
src/nav_internal.cpp
)
target_include_directories(nav PUBLIC include)
target_compile_features(nav PUBLIC c_std_99)
target_compile_features(nav PRIVATE cxx_std_17)

if(NAV_SHARED)
target_compile_definitions(nav PUBLIC NAV_SHARED)

if(NOT ANDROID)
set_target_properties(nav PROPERTIES
VERSION ${NAV_VERSION_MAJOR}.${NAV_VERSION_MINOR}.${NAV_VERSION_PATCH}
SOVERSION ${NAV_VERSION_MAJOR}
)
endif()
endif()

# Find FFmpeg
if(FFMPEG_DIR)
# Ok I trusted you
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include)
else()
find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWRESAMPLE SWSCALE)
endif()

if(FFMPEG_FOUND OR FFMPEG_INCLUDE_DIRS)
message(STATUS "Using FFmpeg include directory: ${FFMPEG_INCLUDE_DIRS}")
target_include_directories(nav PRIVATE ${FFMPEG_INCLUDE_DIRS})
endif()

# Install files
if(PROJECT_IS_TOP_LEVEL)
include(GNUInstallDirs)
install(TARGETS nav)
install(FILES ${NAV_PUBLIC_INCLUDE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nav)
if(WIN32 AND NAV_SHARED)
install(FILES $<TARGET_PDB_FILE:nav> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
endif()
endif()
Loading

0 comments on commit 3d11743

Please sign in to comment.