Compare commits

..

3 Commits

Author SHA1 Message Date
762b8789c1 Bump copyright year 2024-01-20 18:59:19 -08:00
8dd76e1c96 Create cmake-multi-platform.yml (#1) 2023-12-07 15:42:23 -08:00
2205e1f164 Fixed MacOS build 2023-11-23 20:14:25 -08:00
6 changed files with 94 additions and 8 deletions

View File

@@ -0,0 +1,82 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc
- os: macos-latest
c_compiler: cl
steps:
- uses: actions/checkout@v3
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

View File

@@ -2,7 +2,7 @@
// block.h // block.h
// Kraken Engine / Mimir // Kraken Engine / Mimir
// //
// Copyright 2023 Kearwood Gilbert. All rights reserved. // Copyright 2024 Kearwood Gilbert. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, are // Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met: // permitted provided that the following conditions are met:

View File

@@ -2,7 +2,7 @@
// mimir.h // mimir.h
// Kraken Engine / Mimir // Kraken Engine / Mimir
// //
// Copyright 2023 Kearwood Gilbert. All rights reserved. // Copyright 2024 Kearwood Gilbert. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, are // Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met: // permitted provided that the following conditions are met:

View File

@@ -2,7 +2,7 @@
// util.h // util.h
// Kraken Engine / Mimir // Kraken Engine / Mimir
// //
// Copyright 2023 Kearwood Gilbert. All rights reserved. // Copyright 2024 Kearwood Gilbert. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, are // Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met: // permitted provided that the following conditions are met:

View File

@@ -2,7 +2,7 @@
// block.cpp // block.cpp
// Kraken Engine // Kraken Engine
// //
// Copyright 2023 Kearwood Gilbert. All rights reserved. // Copyright 2024 Kearwood Gilbert. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, are // Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met: // permitted provided that the following conditions are met:
@@ -34,6 +34,7 @@
#if defined(__unix__) || defined(__APPLE__) || defined(ANDROID) #if defined(__unix__) || defined(__APPLE__) || defined(ANDROID)
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
@@ -190,7 +191,7 @@ bool Block::load(const std::string& path)
m_fdPackFile = open(path.c_str(), O_RDONLY); m_fdPackFile = open(path.c_str(), O_RDONLY);
if (m_fdPackFile >= 0) { if (m_fdPackFile >= 0) {
m_fileOwnerDataBlock = this; m_fileOwnerDataBlock = this;
m_fileName = KRResource::GetFileBase(path); m_fileName = util::GetFileBase(path);
struct stat statbuf; struct stat statbuf;
if (fstat(m_fdPackFile, &statbuf) >= 0) { if (fstat(m_fdPackFile, &statbuf) >= 0) {
m_data_size = statbuf.st_size; m_data_size = statbuf.st_size;
@@ -433,7 +434,7 @@ bool Block::save(const std::string & path)
// Now map it... // Now map it...
void* pNewData = mmap(0, m_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdNewFile, 0); void* pNewData = mmap(0, m_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdNewFile, 0);
if (pNewData == (caddr_t)-1) { if (pNewData == (void*)-1) {
close(fdNewFile); close(fdNewFile);
return false; return false;
} }
@@ -532,7 +533,9 @@ void Block::lock()
//fprintf(stderr, "Block::lock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount); //fprintf(stderr, "Block::lock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount);
// Round m_data_offset down to the next memory page, as required by mmap // Round m_data_offset down to the next memory page, as required by mmap
if ((m_mmapData = mmap(0, m_data_size + alignment_offset, m_bReadOnly ? PROT_READ : PROT_WRITE, MAP_SHARED, m_fdPackFile, m_data_offset - alignment_offset)) == (caddr_t)-1) { if ((m_mmapData = mmap(0, m_data_size + alignment_offset, m_bReadOnly ? PROT_READ : PROT_WRITE, MAP_SHARED, m_fdPackFile, m_data_offset - alignment_offset)) == (void*)-1) {
/*
// Disabled until logging utility can be implemented
int iError = errno; int iError = errno;
switch (iError) { switch (iError) {
case EACCES: case EACCES:
@@ -560,6 +563,7 @@ void Block::lock()
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "mmap failed with errno: %i", iError); KRContext::Log(KRContext::LOG_LEVEL_ERROR, "mmap failed with errno: %i", iError);
break; break;
} }
*/
assert(false); // mmap() failed. assert(false); // mmap() failed.
} }
#else #else

View File

@@ -2,7 +2,7 @@
// util.cpp // util.cpp
// Kraken Engine / Mimir // Kraken Engine / Mimir
// //
// Copyright 2023 Kearwood Gilbert. All rights reserved. // Copyright 2024 Kearwood Gilbert. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, are // Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met: // permitted provided that the following conditions are met: