Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to standalone CMake. #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text eol=crlf
*.h text eol=crlf
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build ESPTK

on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4

- name: Configure ESPTK build
shell: pwsh
run: |
cmake --preset vs2022-windows "-DCMAKE_INSTALL_PREFIX=install"

- name: Build ESPTK
run: cmake --build vsbuild --config RelWithDebInfo

- name: Install ESPTK
run: cmake --install vsbuild --config RelWithDebInfo

- name: Upload ESPTK artifact
uses: actions/upload-artifact@master
with:
name: esptk
path: ./install
16 changes: 16 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint ESPTK

on:
push:
pull_request:
types: [opened, synchronize, reopened]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check format
uses: ModOrganizer2/check-formatting-action@master
with:
check-path: "."
26 changes: 21 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
cmake_minimum_required(VERSION 3.16)

if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
endif()
include(CMakePackageConfigHelpers)

project(esptk)

add_subdirectory(src)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config.cmake"
INSTALL_DESTINATION "lib/cmake/mo2-esptk"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config-version.cmake"
VERSION "1.3.12"
COMPATIBILITY AnyNewerVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config-version.cmake
DESTINATION lib/cmake/mo2-esptk
)
36 changes: 36 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"configurePresets": [
{
"errors": {
"deprecated": true
},
"hidden": true,
"name": "cmake-dev",
"warnings": {
"deprecated": true,
"dev": true
}
},
{
"binaryDir": "${sourceDir}/vsbuild",
"architecture": {
"strategy": "set",
"value": "x64"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4"
},
"generator": "Visual Studio 17 2022",
"inherits": ["cmake-dev"],
"name": "vs2022-windows",
"toolset": "v143"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"configurePreset": "vs2022-windows"
}
],
"version": 4
}
36 changes: 0 additions & 36 deletions appveyor.yml

This file was deleted.

3 changes: 3 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-esptk-targets.cmake" )
46 changes: 23 additions & 23 deletions src/espexceptions.h → include/esptk/espexceptions.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#ifndef ESPEXCEPTIONS_H
#define ESPEXCEPTIONS_H
#include <stdexcept>
namespace ESP
{
class InvalidRecordException : public std::runtime_error
{
public:
InvalidRecordException(const std::string& message) : std::runtime_error(message) {}
};
class InvalidFileException : public std::runtime_error
{
public:
InvalidFileException(const std::string& message) : std::runtime_error(message) {}
};
} // namespace ESP
#endif // ESPEXCEPTIONS_H
#ifndef ESPEXCEPTIONS_H
#define ESPEXCEPTIONS_H

#include <stdexcept>

namespace ESP
{

class InvalidRecordException : public std::runtime_error
{
public:
InvalidRecordException(const std::string& message) : std::runtime_error(message) {}
};

class InvalidFileException : public std::runtime_error
{
public:
InvalidFileException(const std::string& message) : std::runtime_error(message) {}
};

} // namespace ESP

#endif // ESPEXCEPTIONS_H
140 changes: 70 additions & 70 deletions src/espfile.h → include/esptk/espfile.h
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
#ifndef ESPFILE_H
#define ESPFILE_H
#include "record.h"
#include "tes3record.h"
#include <fstream>
#include <set>
#include <string>
namespace ESP
{
class SubRecord;
class File
{
public:
File(const std::string& fileName);
File(const std::wstring& fileName);
Record readRecord();
bool isMaster() const;
bool isLight(bool overlaySupport = false) const;
bool isMedium() const;
bool isOverlay() const;
bool isBlueprint() const;
bool isDummy() const;
std::string author() const { return m_Author; }
std::string description() const { return m_Description; }
std::set<std::string> masters() const { return m_Masters; }
private:
void init();
void onHEDR(const SubRecord& rec);
void onMAST(const SubRecord& rec);
void onCNAM(const SubRecord& rec);
void onSNAM(const SubRecord& rec);
private:
std::ifstream m_File;
struct
{
float version;
int32_t numRecords;
uint32_t nextObjectId;
} m_Header;
struct
{
float version;
uint32_t unknown;
char author[32];
char description[256];
uint32_t numRecords;
} m_TES3Header;
Record m_MainRecord;
std::string m_Author;
std::string m_Description;
std::set<std::string> m_Masters;
};
} // namespace ESP
#endif // ESPFILE_H
#ifndef ESPFILE_H
#define ESPFILE_H

#include "record.h"
#include "tes3record.h"
#include <fstream>
#include <set>
#include <string>

namespace ESP
{

class SubRecord;

class File
{
public:
File(const std::string& fileName);
File(const std::wstring& fileName);

Record readRecord();

bool isMaster() const;
bool isLight(bool overlaySupport = false) const;
bool isMedium() const;
bool isOverlay() const;
bool isBlueprint() const;
bool isDummy() const;
std::string author() const { return m_Author; }
std::string description() const { return m_Description; }
std::set<std::string> masters() const { return m_Masters; }

private:
void init();

void onHEDR(const SubRecord& rec);
void onMAST(const SubRecord& rec);
void onCNAM(const SubRecord& rec);
void onSNAM(const SubRecord& rec);

private:
std::ifstream m_File;

struct
{
float version;
int32_t numRecords;
uint32_t nextObjectId;
} m_Header;

struct
{
float version;
uint32_t unknown;
char author[32];
char description[256];
uint32_t numRecords;
} m_TES3Header;

Record m_MainRecord;

std::string m_Author;
std::string m_Description;

std::set<std::string> m_Masters;
};

} // namespace ESP

#endif // ESPFILE_H
38 changes: 19 additions & 19 deletions src/esptypes.h → include/esptk/esptypes.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef ESPTYPES_H
#define ESPTYPES_H
#include <istream>
template <typename T>
static T readType(std::istream& stream)
{
union
{
char buffer[sizeof(T)];
T value;
};
memset(buffer, 0x42, sizeof(T));
stream.read(buffer, sizeof(T));
return value;
}
#endif // ESPTYPES_H
#ifndef ESPTYPES_H
#define ESPTYPES_H

#include <istream>

template <typename T>
static T readType(std::istream& stream)
{
union
{
char buffer[sizeof(T)];
T value;
};
memset(buffer, 0x42, sizeof(T));
stream.read(buffer, sizeof(T));
return value;
}

#endif // ESPTYPES_H
Loading
Loading