Skip to content

Commit

Permalink
Merge pull request #529 from Lgt2x/release
Browse files Browse the repository at this point in the history
Update release branch with latest commits
  • Loading branch information
Lgt2x authored Aug 16, 2024
2 parents ae5840f + c01ef38 commit 0388d07
Show file tree
Hide file tree
Showing 62 changed files with 668 additions and 1,262 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,25 @@ jobs:
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build cmake g++ libgtest-dev libsdl2-dev zlib1g-dev libspdlog-dev
ninja-build cmake g++ curl pkg-config autoconf automake libtool libltdl-dev make python3-jinja2 libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev
- name: Install Windows dependencies
if: ${{ matrix.os.runner == 'windows-latest' }}
run: choco install ninja

- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.os.runner == 'windows-latest' }}
with:
arch: win64

- uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: vcpkg.json

- name: Configure CMake
env:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
VCPKG_ROOT: C:/vcpkg
run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=ON

- name: Build ${{ matrix.build_type }}
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release source tarball
on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Generate git hash and tarball
run: |
sudo apt update
sudo apt install -y ninja-build cmake g++ libsdl2-dev zlib1g-dev
cmake --preset linux
cmake --build --preset linux -t get_git_hash
cmake --build --preset linux -t package_source
- name: Release
uses: ncipollo/[email protected]
with:
artifacts: "builds/linux/Descent3-*-Source.tar.xz"
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion 2dlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
set(HEADERS
gr.h
lib2d.h)
set(CPPS
font.cpp
hardsurf.cpp
Expand All @@ -9,7 +12,7 @@ set(CPPS
viewport.cpp
)

add_library(2dlib STATIC ${CPPS})
add_library(2dlib STATIC ${HEADERS} ${CPPS})
target_link_libraries(2dlib PRIVATE
cfile
mem
Expand Down
2 changes: 1 addition & 1 deletion 2dlib/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ void grFont::translate_to_surfaces(int slot) {
void grFont::translate_mono_char(grSurface *sf, int x, int y, int index, gr_font_file_record *ft, int width) {
int row, col; // byte width of char
int rowsize;
uint8_t bit_mask = 0, byte;
uint8_t bit_mask = 0, byte = 0;
uint8_t *fp;

fp = ft->char_data[index];
Expand Down
6 changes: 5 additions & 1 deletion AudioEncode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
set(HEADERS
adecode.h
aencode.h
audio_encode.h)
set(CPPS
adecode.cpp
aencode.cpp
encoder.cpp
)

add_library(AudioEncode STATIC ${CPPS})
add_library(AudioEncode STATIC ${HEADERS} ${CPPS})
target_link_libraries(AudioEncode PRIVATE
libacm
)
Expand Down
9 changes: 5 additions & 4 deletions AudioEncode/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ bool aenc_Compress(char *input_filename, char *output_filename, const int *input
FILE *in, *out;
int32_t result;

int levels, samples_per_subband;
unsigned sample_rate, channels;
float factor, volume_scale;
int levels = 0, samples_per_subband = 0;
unsigned sample_rate = 0, channels = 0;
float factor = 0, volume_scale = 0;
int levels_set = 0, samples_per_subband_set = 0, sample_rate_set = 0, channels_set = 0, factor_set = 0,
volume_scale_set = 0;

Expand Down Expand Up @@ -105,7 +105,8 @@ bool aenc_Compress(char *input_filename, char *output_filename, const int *input
}

if (!levels_set && !samples_per_subband_set) {
levels = 7, samples_per_subband = 16;
levels = 7;
samples_per_subband = 16;
} else if (!samples_per_subband_set) {
samples_per_subband = 2048 / (1 << levels);

Expand Down
170 changes: 170 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@

# Building Descent 3 Open Source

## Dependencies
The build process uses [**CMake**](https://cmake.org/) and, by default, [**Ninja**](https://ninja-build.org/). You must install these; the project cannot locate them for you. The source code depends on [**SDL2**](https://github.com/libsdl-org/SDL/tree/SDL2) and [**zlib**](https://github.com/madler/zlib). You can supply these dependencies yourself via your system's library management tools, or the build system can locate the dependencies for you using [vcpkg](https://github.com/microsoft/vcpkg), a cross-platform dependency-management system developed by Microsoft. The official builds source their dependencies from vcpkg.

## Installing and using vcpkg
* When building for Windows, vcpkg is already installed and configured when using any of the Visual Studio command prompts (either actual Command Prompt, or PowerShell).
* For Android, Linux or Mac (or non-standard-Windows) configurations, you will need to install vcpkg locally by cloning https://github.com/microsoft/vcpkg and setting your `VCPKG_ROOT` env var to the repository location. With this environment variable set, the build will automatically locate its dependencies.

## Building - Windows
1. **Install the prerequisite build tools.**

Make sure that you have Git and Visual Studio 2022 with the “Desktop development with C++” workload and the “C++ MFC for latest v143 build tools (x86 & x64)” component. If you don’t already have those installed or you aren’t sure, then open an elevated Command Prompt and run:
<!--
The following code block specifies the full path to the Visual Studio Installer because the Visual Studio Installer doesn’t add itself to the user’s Path. The installer is guaranteed to be in a specific location on 64-bit systems [1]. The installer will be in a different location on 32-bit systems [2], but Visual Studio 2022 doesn’t support 32-bit systems [3] so we can ignore that detail.
[1]: <https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022>
[2]: <https://github.com/microsoft/vswhere/wiki#installing>
[3]: <https://learn.microsoft.com/en-us/answers/questions/1689898/does-visual-studio-build-tools-2022-support-32-bit>
-->
```batch
winget install Git.Git Microsoft.VisualStudio.2022.Community
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\setup.exe" modify^
--passive^
--channelId VisualStudio.17.Release^
--productId Microsoft.VisualStudio.Product.Community^
--add Microsoft.VisualStudio.Workload.NativeDesktop;includeRecommended^
--add Microsoft.VisualStudio.Component.VC.ATLMFC
```
**NOTE:**
Builds _must_ be performed in one of the Visual Studio-provided **x64 Native Tools** command prompts ("x64 Native Tools Command Prompt" or "x64 Native Tools PowerShell"), _not_ a standard Command Prompt or PowerShell. The VS prompts will already have vcpkg installed and configured for use, so no dependency management is needed.
2. **Clone the Descent3 source code.**
Open a "x64 Native Tools Command Prompt" or "x64 Native Tools PowerShell" and run:
```batch
git clone https://github.com/DescentDevelopers/Descent3
```
4. **Build Descent3.**
```batch
cd Descent3
cmake --preset win
cmake --build --preset win --config [Debug|Release]
```
See [Build Options](#build-options) below for more information on `Debug` vs `Release`.
Once CMake finishes, the built files will be put in `builds\win\Descent3\Debug` or `builds\win\Descent3\Release`.
## Building - macOS
1. **Install the prerequisite build tools.**
* Make sure that [Xcode](https://developer.apple.com/xcode) is installed.
* Make sure that [Homebrew](https://brew.sh) is installed.
2. **Acquire the library dependencies.**
* If you would like to use vcpkg:
```sh
git clone https://github.com/microsoft/vcpkg
export VCPKG_ROOT="$PWD/vcpkg"
```
**NOTE:**
You will need `$VCPKG_ROOT` defined in the environment for all build runs. It is a good idea to set this in your `.bashrc` or equivalent.
* If you would like to manage the code dependencies yourself:
```sh
brew install sdl2 zlib googletest
```
3. **Clone the Descent3 source code.**
```sh
git clone https://github.com/DescentDevelopers/Descent3
```
4. **Build Descent3.**
```sh
cd Descent3
brew bundle install
cmake --preset mac
cmake --build --preset mac --config [Debug|Release]
```
See [Build Options](#build-options) below for more information on `Debug` vs `Release`.
Once CMake finishes, the built files will be put in `builds/mac/Descent3/Debug` or `builds/mac/Descent3/Release`.
## Building - Linux
1. **Install the prerequisite build tools.**
* APT users (Debian, Ubuntu)
```sh
sudo apt update
sudo apt install -y --no-install-recommends git ninja-build cmake g++
```
* DNF users (Red Hat, Fedora)
```sh
sudo dnf update --refresh
sudo dnf install -y git ninja-build cmake gcc-c++
```
2. **Acquire the library dependencies.**
* If you would like to use vcpkg:
1. Clone vcpkg:
```sh
git clone https://github.com/microsoft/vcpkg
export VCPKG_ROOT="$PWD/vcpkg"
```
**NOTE:**
You will need `$VCPKG_ROOT` defined in the environment for all build runs. It is a good idea to set this in your `.bashrc` or equivalent.
2. Install vcpkg-needed build tools and dependencies:
* APT users
```sh
sudo apt install -y --no-install-recommends curl pkg-config autoconf automake libtool libltdl-dev make python3-jinja2 libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev
```
* DNF users
```sh
sudo dnf install -y autoconf automake libtool perl-open perl-FindBin python-jinja2 libX11-devel libXft-devel libXext-devel wayland-devel libxkbcommon-devel mesa-libEGL-devel ibus-devel alsa-lib-devel pulseaudio-libs-devel
```
* If you would like to manage the code dependencies yourself:
* APT users
```sh
sudo apt install -y --no-install-recommends libsdl2-dev zlib1g-dev libgtest-dev
```
* DNF users
```sh
sudo dnf install -y SDL2-devel zlib-devel gtest
```
3. **Clone the Descent3 source code.**
```sh
git clone https://github.com/DescentDevelopers/Descent3
```
4. **Build Descent3.**
```sh
cd Descent3
cmake --preset linux
cmake --build --preset linux --config [Debug|Release]
```
See [Build Options](#build-options) below for more information on `Debug` vs `Release`.
Once CMake finishes, the built files will be put in `builds/linux/Descent3/Debug` or `builds/linux/Descent3/Release`.
## Build Options
The Descent3 build can be customized by [setting CMake variables on the command line](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-D) during its "Configuration" phase (the command without the `--build` option). To set a variable, you prepend the variable name with `-D` and then append the value, all as one single parameter. For example:
```sh
cmake --preset linux -DENABLE_LOGGER=ON
```

**NOTE:** CMake variables, or more technically _CMake cache entries_, will persist in their values until they are explicitly cleared. So, if you set a variable and then run another CMake command _without_ that variable specified, the variable will still be set. Variables must be explicitly unset, or the `builds/` directory cleaned, in order to be cleared.

| Option | Description | Default |
| ------ | ----------- | ------- |
| `CMAKE_BUILD_TYPE`<br/>(or just [`--config`](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-build-config), without the `-D` syntax) | <p>`Debug` builds are generally larger, slower and contain extra correctness checks that will validate game data and interrupt gameplay when problems are detected.</p><p>`Release` builds are optimized for size and speed and do not include debugging information, which makes it harder to find problems.</p> | `Debug` |
| `BUILD_EDITOR` | _(Windows-only)_ Build internal editor. | `OFF` |
| `BUILD_TESTING` | Enable testing. Requires GTest. | `OFF` |
| `ENABLE_LOGGER` | Enable logging to the terminal. | `OFF` |
| `ENABLE_MEM_RTL` | Enable Real-time library memory management functions (disable to verbose memory allocations). | `ON` |
| `FORCE_COLORED_OUTPUT` | Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja). | `OFF` |
| `FORCE_PORTABLE_INSTALL` | Install all files into local directory defined by `CMAKE_INSTALL_PREFIX`. | `ON` |
| `USE_VCPKG` | Explicitly control whether or not to use vcpkg for dependency resolution. `ON` requires the environment variable `VCPKG_ROOT` to be set. | Determined by the existence of `VCPKG_ROOT` in the environment: If it exists, vcpkg is used. |
2 changes: 2 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ brew "ninja"

# zlib
brew "zlib"

brew "glm"
Loading

0 comments on commit 0388d07

Please sign in to comment.