Skip to content

Commit

Permalink
Merge pull request #24 from tashcan/refactor/xmake
Browse files Browse the repository at this point in the history
Move from CMake to XMake
  • Loading branch information
tashcan authored Mar 24, 2024
2 parents 0b72511 + 0ffb97b commit 8f36012
Show file tree
Hide file tree
Showing 179 changed files with 5,509 additions and 364,698 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ jobs:
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64

- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest

- name: Configure CMake
run: cmake -G "Ninja Multi-Config" -B build -S ${{ github.workspace }}
- name: Configure
run: xmake f -m releasedbg -y

- name: Build
run: cmake --build build --target stfc-community-patch -j --config Release

run: xmake -y
- name: Package
run: |
mv build/Release/stfc-community-patch.dll version.dll
mv build/windows/x64/releasedbg/stfc-community-patch.dll version.dll
- uses: actions/upload-artifact@v2
with:
name: stfc-community-patch
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.vscode/*
!.vscode/extensions.json
.vs/
/out/
/build/
Expand All @@ -8,5 +9,6 @@ compile_commands.json
version.aps
*.vars
debug.log
enc_temp_folder/
/app/
/.xmake/
/vsxmake*/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "third_party/spdlog"]
path = third_party/spdlog
url = https://github.com/gabime/spdlog.git
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"tboox.xmake-vscode"
]
}
146 changes: 0 additions & 146 deletions CMakeLists.txt

This file was deleted.

35 changes: 0 additions & 35 deletions CMakeSettings.json

This file was deleted.

57 changes: 16 additions & 41 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

## Building

First clone and initialise the repository:
First clone and initialize the repository:

```bash
git clone https://github.com/tashcan/bob.git
cd bob
git submodule update --recursive --init
```

This will download three submodules and further submodules that they have, so this will take some time to complete.

## Installing

Please note that when this project compiles, it will create a DLL called `stfc-community-patch.dll`. This
Expand Down Expand Up @@ -52,39 +49,20 @@ apply the changes to have the SDK downloaded and installed. This will take arou

#### Configure and building the project

Create or enter the `.vs/` folder and place the following in `launch.vs.json`:

```json
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"exe": "C:\\Games\\Star Trek Fleet Command\\Star Trek Fleet Command\\default\\game\\prime.exe",
"project": "CMakeLists.txt",
"projectTarget": "stfc-community-patch.dll",
"name": "Prime",
"cwd": "C:\\Games\\Star Trek Fleet Command\\Star Trek Fleet Command\\default\\game"
}
]
}
```

Once they are installed, either standalone or via Visual Studio, you can open the `bob` folder inside
Visual Studio or by right clicking in a Windows Explorer via and selecting `Open with Visual Studio`.
When it first opens, it should automatically start a build to configure the project. You can
reconfigure the project by right clicking on the `CMakeLists.txt` file and selecting
`Configure STFC Community Patch`.
Once they are installed, either standalone or via Visual Studio, you can configure the `bob` project.
We are using [XMake](https://xmake.io/#/).
To configure a Visual Studio solution, simple run the following on the Command Line.

Once the project configuration has finished, you can build the project by pressing `F6` or right clicking
on the `CMakeLists.txt` file and selecting `Build`.
```powershell
xmake project -k vsxmake -m "debug,release"
```
You will now find a `bob.sln` file inside `vsxmake2022`(or similarly named). You can simply open that in `Visual Studio`
and Build the solution.

**IMPORTANT**: To reset the build, you can remove the `out/` folder and all items beneath it. Visual
**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
Studio will then rebuild the project.

**IMPORTANT**: To fully reset the project, also remove the `.vs/` folder. If you do this, please remember
to recreate the `.vs/launch.vs.json` file.
**IMPORTANT**: To fully reset the project, also remove the `.vs/` folder.

### Visual Studio Code

Expand All @@ -93,21 +71,18 @@ are available.

Once they are installed, either standalone or via Visual Studio, you can open the `bob` folder inside
Visual Studio or by right clicking in a Windows Explorer via and selecting `Open with Visual Studio Code`.
When it first opens, it should ask you to install the CMake extensions bundle. Once the extensions are
installed, you can build the project by pressing `F7` or right clicking on the `CMakeLists.txt` file and
selecting `Build All Projects`. This will ask you to configure the project and pick various items to use
in the build on the first build only.
When it first opens, it should ask you to install the XMake extension. Once the extensions are
installed, you can build the project by navigating to the XMake section in the Activity Bar and clicking `Build All` at the top.

**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
Studio will then rebuild the project.
Studio Code will then rebuild the project.

### Command Line

If you do not have Visual Studio Code, this project uses CMake, so the simplest way to build it on Windows:
If you do not have Visual Studio Code, this project uses XMake, so the simplest way to build it on Windows:

```ps1
mkdir build
cd build
cmake ../
cmake --build .
xmake
```
1 change: 1 addition & 0 deletions gen_compdb.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xmake project -k compile_commands
6 changes: 3 additions & 3 deletions src/patches/config.cc → mods/src/config.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "config.h"
#include "version.h"
#include "str_utils.h"
#include "mapkey.h"
#include "patches/mapkey.h"
#include "prime/KeyCode.h"

#include <algorithm>
Expand Down Expand Up @@ -51,7 +51,7 @@ void Config::Save(toml::table config, std::string_view filename, bool apply_warn
if (apply_warning) {
char buff[44];
snprintf(buff, 44, "%-44s", CONFIG_FILE_DEFAULT);

config_file << "#######################################################################\n";
config_file << "#######################################################################\n";
config_file << "#### ####\n";
Expand Down Expand Up @@ -228,7 +228,7 @@ void Config::Load()
toml::table parsed;
bool write_config = false;
try {
config = toml::parse_file("community_patch_settings.toml");
config = std::move(toml::parse_file("community_patch_settings.toml"));
write_config = true;
} catch (const toml::parse_error& e) {
spdlog::warn("Failed to load config file, falling back to default settings: {}", e.description());
Expand Down
File renamed without changes.
Binary file added mods/src/il2cpp/GameAssembly.lib
Binary file not shown.
24 changes: 24 additions & 0 deletions mods/src/il2cpp/il2cpp-functions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#ifdef _WIN32
#pragma comment(lib, "GameAssembly.lib")
#endif

#include <il2cpp-api-types.h>
#include <il2cpp-class-internals.h>
#include <il2cpp-config.h>
#include <il2cpp-object-internals.h>

#if defined(__cplusplus)
extern "C"
{
#endif // __cplusplus
#define DO_API(r, n, p) IL2CPP_IMPORT r n p;
#define DO_API_NO_RETURN(r, n, p) IL2CPP_IMPORT NORETURN r n p;
#include "il2cpp-api-functions.h"
#undef DO_API
#undef DO_API_NORETURN
#if defined(__cplusplus)
}
#endif // __cplusplus

6 changes: 6 additions & 0 deletions mods/src/il2cpp/il2cpp_helper.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "il2cpp_helper.h"

Il2CppObject* get_target(uint32_t handle)
{
return il2cpp_gchandle_get_target(handle);
}
Loading

0 comments on commit 8f36012

Please sign in to comment.