Skip to content

Commit

Permalink
Standalone build (#9)
Browse files Browse the repository at this point in the history
* Organizes libultraship files into directories.

* Adds StormLib, ZAPDUTILS, and tidies up /lib/

* Moves include up a directory and moves abi.h to include.

* Fixes gitignore to only ignore build folders, and commits forgotten files.

* update CMakeLists and `#include`s to match directory structure

* Windows CMake now builds project files.

* Restructure CMake project

* feat: sdl via vcpkg (#1)

Co-authored-by: briaguya <briaguya@alice>

* Build via VS generator

* Use ccache for faster building

* Error CI workflow on no lib generated

* Remove unused lib (mINI)

* Update embedded lib (nlohmann-json)

* Cleanup main CMakeLists.txt

* Remove unecessary header

* Use Ninja for MSVC

* Update embedded lib (spdlog)

* Update embedded lib (StormLib)

* Improve CMake structure

* define NOMINMAX for certain windows files

* Add and run clang-format

* Add and run clang-tidy

* Add CI workflow for clang-format/tidy

* Split CI workflows

* Use new format validation

* Fixes typos preventing patch OTRs from working on Switch (#8)

* Removes third party BinaryTools and re-implements and reloacates ZAPDUtils Binary Tools. (#7)

* Removes third party BinaryTools and implements ZAPDUtils' into LUS.

* Attempts to make the Linter happy.

* Another run of linter fixing improvements.

* Should be last linting-related change.

* Fixes tidy-format-validation to only check src and include directories in the git diff

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: David Chavez <[email protected]>
Co-authored-by: briaguya <[email protected]>
Co-authored-by: Christopher Leggett <[email protected]>
  • Loading branch information
5 people committed Jan 3, 2023
1 parent 016bae2 commit 2756a09
Show file tree
Hide file tree
Showing 2,304 changed files with 338,015 additions and 91,598 deletions.
23 changes: 23 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IndentWidth: 4
Language: Cpp
UseTab: Never
ColumnLimit: 120
PointerAlignment: Left
BreakBeforeBraces: Attach
SpaceAfterCStyleCast: false
Cpp11BracedListStyle: false
IndentCaseLabels: true
BinPackArguments: true
BinPackParameters: true
AlignAfterOpenBracket: Align
AlignOperands: true
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: None
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AlignEscapedNewlines: Left
AlignTrailingComments: true
SortIncludes: false
9 changes: 9 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Checks: '-*,readability-braces-around-statements,readability-inconsistent-declaration-parameter-name'
WarningsAsErrors: ''
HeaderFilterRegex: '(src|include)\/.*\.h$'
FormatStyle: 'file'
CheckOptions:
# Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another)
# Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 1
90 changes: 90 additions & 0 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: build-validation
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-macos:
runs-on: macos-12
steps:
- name: Install dependencies
run: |
brew install sdl2 libpng glew ninja
- uses: actions/checkout@v2
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-ccache
- name: Build libultraship
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build build-cmake --config Release --parallel 10
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: soh-mac
path: build-cmake/src/*.a
if-no-files-found: error
build-linux:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev libpng-dev libglew-dev ninja-build
- uses: actions/checkout@v2
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-ccache
- name: Install latest SDL
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
wget https://www.libsdl.org/release/SDL2-2.24.1.tar.gz
tar -xzf SDL2-2.24.1.tar.gz
cd SDL2-2.24.1
./configure
make -j 10
sudo make install
- name: Build libultraship
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build build-cmake --config Release --parallel 10
env:
CC: gcc-10
CXX: g++-10
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: soh-linux
path: build-cmake/src/*.a
if-no-files-found: error
build-windows:
runs-on: windows-latest
steps:
- name: Install dependencies
run: |
choco install ninja
Remove-Item -Path "C:\ProgramData\Chocolatey\bin\ccache.exe" -Force
- uses: actions/checkout@v2
- name: ccache
uses: dcvz/ccache-action@27b9f33213c0079872f064f6b6ba0233dfa16ba2
with:
key: ${{ runner.os }}-ccache
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build libultraship
run: |
set $env:PATH="$env:USERPROFILE/.cargo/bin;$env:PATH"
cmake --no-warn-unused-cli -S. -Bbuild-cmake -GNinja -DCMAKE_MAKE_PROGRAM=ninja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DUSE_AUTO_VCPKG=ON -DCMAKE_VS_PLATFORM_NAME=x64
cmake --build build-cmake --config Release --parallel 10
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: soh-windows
path: build-cmake/**/src/**/*.lib
if-no-files-found: error
56 changes: 56 additions & 0 deletions .github/workflows/tidy-format-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: tidy-format-validation
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tidy-format:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev libpng-dev libglew-dev ninja-build clang-tidy clang-format-12
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-ccache
- name: Run clang-format
run: |
clang-format-12 -i -style=file src/**/*.cpp src/**/*.h include/*.h
git diff --exit-code
- name: Install latest SDL
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
wget https://www.libsdl.org/release/SDL2-2.24.1.tar.gz
tar -xzf SDL2-2.24.1.tar.gz
cd SDL2-2.24.1
./configure
make -j 10
sudo make install
- name: Prepare compile_commands.json
run: |
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Create results directory
run: |
mkdir clang-tidy-result
- name: Analyze
run: |
git diff -U0 HEAD^ -- 'src' 'include' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@master
with:
# The GitHub token (or a personal access token)
github_token: ${{ secrets.GITHUB_TOKEN }}
# The path to the clang-tidy fixes generated previously
clang_tidy_fixes: clang-tidy-result/fixes.yml
# Optionally set to true if you want the Action to request
# changes in case warnings are found
request_changes: true
# Optionally set the number of comments per review
# to avoid GitHub API timeouts for heavily loaded
# pull requests
suggestions_per_comment: 10
21 changes: 2 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@
# Mono auto generated files
mono_crash.*

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

!otrlib/Lib/SDL/lib/x64
!otrlib/Lib/SDL/lib/x86

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down Expand Up @@ -355,4 +337,5 @@ MigrationBackup/
!libultraship/Lib/**
libultraship/DebugObj/*
build/
libultraship.a
libultraship.a
.DS_Store
77 changes: 77 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"files.associations": {
"unordered_map": "cpp",
"string": "cpp",
"chrono": "cpp",
"iosfwd": "cpp",
"thread": "cpp",
"__bit_reference": "cpp",
"__bits": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"exception": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_set": "cpp",
"valarray": "cpp",
"variant": "cpp",
"vector": "cpp"
}
}
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.16.0)

project(libultraship LANGUAGES C CXX)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
enable_language(OBJCXX)
endif()

include(cmake/Utils.cmake)

if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND USE_AUTO_VCPKG)
include(cmake/automate-vcpkg.cmake)

set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)

vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 SDL2 GLEW)
endif()

add_subdirectory("extern")
add_subdirectory("src")

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# libultraship

## Building
```
cmake -H. -Bbuild
cmake --build build
```

## Generating a Visual Studio `.sln` on Windows
```
# Visual Studio 2022
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64
# Visual Studio 2019
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 16 2019" -T v142 -A x64
```
Loading

0 comments on commit 2756a09

Please sign in to comment.