Skip to content

Commit

Permalink
Merge branch 'main' into fixies
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr authored May 28, 2024
2 parents a728b30 + e07b711 commit ffc2a68
Show file tree
Hide file tree
Showing 20 changed files with 354 additions and 249 deletions.
34 changes: 0 additions & 34 deletions .github/scripts/build-linux.sh

This file was deleted.

23 changes: 0 additions & 23 deletions .github/scripts/build-macos.sh

This file was deleted.

55 changes: 0 additions & 55 deletions .github/scripts/build-mingw.sh

This file was deleted.

43 changes: 0 additions & 43 deletions .github/scripts/build-msvc.ps1

This file was deleted.

83 changes: 57 additions & 26 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,69 @@ jobs:
strategy:
matrix:
platform:
- { name: Linux, os: ubuntu-latest, arch: amd64, script: build-linux.sh }
- { name: MacOS, os: macos-latest, arch: amd64, script: build-macos.sh }
- { name: Windows, os: windows-latest, arch: amd64, script: build-msvc.ps1 }
- { name: Windows, os: windows-latest, arch: x86, script: build-msvc.ps1 }

runs-on: ${{ matrix.platform.os }}
name: CI (${{ matrix.platform.name }} ${{ matrix.platform.arch }})
- { name: 'Linux', arch: 'x64', os: ubuntu-latest, werror: true }
- { name: 'MacOS', arch: 'arm64-x64', os: macos-latest, werror: true, cmake-args: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
- { name: 'Windows', arch: 'Win32', os: windows-latest }
- { name: 'Windows', arch: 'x64', os: windows-latest }

defaults:
run:
shell: sh
runs-on: '${{ matrix.platform.os }}'
name: 'CI ${{ matrix.platform.name }} ${{ matrix.platform.arch }}'
steps:
- uses: actions/checkout@v3
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.2
- uses: ilammy/msvc-dev-cmd@v1.4.1
- uses: actions/checkout@v4
- name: Set up Ninja
uses: aseprite/get-ninja@main
- uses: ilammy/msvc-dev-cmd@v1.13.0
if: runner.os == 'Windows'
with:
arch: ${{ matrix.platform.arch }}
- name: Build
id: build
run: .github/scripts/${{ matrix.platform.script }}
env:
PLATFORM_ARCH: ${{ matrix.platform.arch }}
- name: Test
- name: Install Linux dependencies
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update
sudo apt-get install -y libgl-dev
- name: Set up SDL
uses: libsdl-org/setup-sdl@main
with:
cmake-arguments: ${{ matrix.platform.cmake-args }}
cmake-generator: Ninja
version: 2-latest
add-to-environment: true

- name: 'Prepare sources for release'
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "${{ github.ref_name }}" >VERSION
- name: 'Configure (CMake)'
id: configure
run: |
cmake -B build -GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_TESTS=ON \
-DDETHRACE_WERROR=${{ !!matrix.platform.werror }} \
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-DDETHRACE_INSTALL=ON \
-DDETHRACE_PACKAGE_PLATFORM=${{ matrix.platform.name }} \
-DDETHRACE_PACKAGE_ARCH=${{ matrix.platform.arch }} \
${{ matrix.platform.cmake-args }}
- name: 'Build (CMake)'
run: |
cmake --build build
- name: 'Test (CTest)'
run: |
ctest --test-dir build --verbose
- name: 'Package (CPack)'
run: |
cd build
ctest --verbose
cpack .
- name: Upload Artifact
if: startsWith(github.ref, 'refs/tags/') || github.ref_name == 'main'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.filename }}
path: ${{ steps.build.outputs.filename }}
name: '${{ steps.configure.outputs.filename }}'
path: 'build/dist/${{ steps.configure.outputs.filename }}'
if-no-files-found: error

create-release:
name: Create Release
Expand All @@ -55,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Fetch Build Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Calculate Variables
Expand All @@ -64,7 +95,7 @@ jobs:
echo "ref_name_without_v=$(echo ${GITHUB_REF_NAME} | cut -c2-)" >>$GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v0.1.14
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
Expand Down
53 changes: 30 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ project(dethrace C)

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

if(MSVC)
set(CMAKE_INSTALL_BINDIR "." CACHE PATH "User executables")
set(CMAKE_INSTALL_DOCDIR "." CACHE PATH "Documentation root")
endif()

include(CheckCCompilerFlag)
include(GNUInstallDirs)
include(TestBigEndian)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
Expand All @@ -18,6 +22,9 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
else()
include(GetGitRevisionDescription)
git_describe(DETHRACE_VERSION)
if(NOT DETHRACE_VERSION)
set(DETHRACE_VERSION "unknown")
endif()
endif()

message(STATUS "dethrace version ${DETHRACE_VERSION}")
Expand Down Expand Up @@ -82,39 +89,39 @@ endif()

if(DETHRACE_INSTALL)
install(FILES LICENSE
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
DESTINATION "."
)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^([xX]86|[xX]86_64|[iI].86|AMD64)$")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(DETHRACE_ARCH x86)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(DETHRACE_ARCH amd64)
else()
message(SEND_ERROR "Unknown CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P})")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM|arm|ARM64|aarch64)$")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(DETHRACE_ARCH arm)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(DETHRACE_ARCH aarch64)
else()
message(SEND_ERROR "Unknown CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P})")
endif()
else()
message(SEND_ERROR "Unknown CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR})")
set(DETHRACE_PACKAGE_PLATFORM "" CACHE STRING "Dethrace binary package platform")
set(DETHRACE_PACKAGE_ARCH "" CACHE STRING "Dethrace binary package architecture")

if(NOT DETHRACE_PACKAGE_PLATFORM)
set(DETHRACE_PACKAGE_PLATFORM "${CMAKE_SYSTEM_NAME}")
endif()

set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${DETHRACE_VERSION}")
string(TOLOWER "${CMAKE_SYSTEM_NAME}-${DETHRACE_ARCH}" CPACK_SYSTEM_NAME)
string(TOLOWER "${DETHRACE_PACKAGE_PLATFORM}" DETHRACE_PACKAGE_PLATFORM)
string(TOLOWER "${DETHRACE_PACKAGE_ARCH}" DETHRACE_PACKAGE_ARCH)

set(CPACK_PACKAGE_NAME "dethrace")
set(CPACK_SYSTEM_NAME "${DETHRACE_PACKAGE_PLATFORM}")

set(CPACK_PACKAGE_FILE_NAME "dethrace-${DETHRACE_VERSION}-${DETHRACE_PACKAGE_PLATFORM}")
if(DETHRACE_PACKAGE_ARCH)
string(APPEND CPACK_PACKAGE_FILE_NAME "-${DETHRACE_PACKAGE_ARCH}")
endif()

set(CPACK_PACKAGE_DIRECTORY dist)

if(MSVC)
set(CPACK_GENERATOR ZIP)
set(ext ".zip")
else()
set(CPACK_GENERATOR TGZ)
set(ext ".tar.gz")
endif()

if(EXISTS "$ENV{GITHUB_OUTPUT}")
file(APPEND "$ENV{GITHUB_OUTPUT}" "filename=${CPACK_PACKAGE_FILE_NAME}${ext}")
endif()

include(CPack)
Expand Down
2 changes: 1 addition & 1 deletion src/BRSRC13/CORE/FW/datafile.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ br_uint_32 DfStructReadBinary(br_datafile* df, br_file_struct* str, void* base)

return 1;
}
#include <stdio.h>

// IDA: int __usercall DfStructSizeBinary@<EAX>(br_datafile *df@<EAX>, br_file_struct *str@<EDX>, void *base@<EBX>)
int DfStructSizeBinary(br_datafile* df, br_file_struct* str, void* base) {
unsigned char* mp;
Expand Down
10 changes: 8 additions & 2 deletions src/DETHRACE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,17 @@ endif()

if (DETHRACE_INSTALL)
install(TARGETS dethrace
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
RUNTIME DESTINATION "."
)
if(MSVC)
INSTALL(FILES $<TARGET_PDB_FILE:dethrace>
DESTINATION "${CMAKE_INSTALL_BINDIR}"
DESTINATION "."
OPTIONAL
)
endif()
if(WIN32)
INSTALL(FILES $<TARGET_RUNTIME_DLLS:dethrace>
DESTINATION "."
OPTIONAL
)
endif()
Expand Down
Loading

0 comments on commit ffc2a68

Please sign in to comment.