mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
5 Commits
0b27770af9
...
146b90632c
Author | SHA1 | Date |
---|---|---|
|
146b90632c | |
|
7bb4940ebd | |
|
c1a0662c1b | |
|
5df8accbbd | |
|
7fc047392c |
|
@ -0,0 +1,50 @@
|
||||||
|
name: 'Setup vcpkg'
|
||||||
|
description: 'Installs vcpkg and initialises binary caching via NuGet'
|
||||||
|
inputs:
|
||||||
|
vcpkg-location:
|
||||||
|
description: 'Where to install vcpkg'
|
||||||
|
required: true
|
||||||
|
mono-install-command:
|
||||||
|
description: 'Command to run to install mono'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install vcpkg
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/microsoft/vcpkg "${{ inputs.vcpkg-location }}"
|
||||||
|
cd "${{ inputs.vcpkg-location }}"
|
||||||
|
./bootstrap-vcpkg.$(if [ "${{ runner.os }}" = "Windows" ]; then echo "bat"; else echo "sh"; fi) -disableMetrics
|
||||||
|
|
||||||
|
- name: Install mono
|
||||||
|
if: inputs.mono-install-command
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
${{ inputs.mono-install-command }}
|
||||||
|
echo "MONO=mono" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Setup NuGet Credentials
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
FEED_URL: 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json'
|
||||||
|
run: |
|
||||||
|
cd "${{ inputs.vcpkg-location }}"
|
||||||
|
${{ env.MONO }} $(./vcpkg fetch nuget | tail -n 1) \
|
||||||
|
sources add \
|
||||||
|
-source "${{ env.FEED_URL }}" \
|
||||||
|
-storepasswordincleartext \
|
||||||
|
-name "GitHub" \
|
||||||
|
-username "${{ github.repository_owner }}" \
|
||||||
|
-password "${{ github.token }}"
|
||||||
|
${{ env.MONO }} $(./vcpkg fetch nuget | tail -n 1) \
|
||||||
|
setapikey "${{ github.token }}" \
|
||||||
|
-source "${{ env.FEED_URL }}"
|
||||||
|
|
||||||
|
- name: Setup vcpkg caching
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;nuget,GitHub,readwrite')
|
||||||
|
|
|
@ -32,18 +32,11 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
mono-install-command: 'sudo apt-get install -y --no-install-recommends mono-complete'
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
|
||||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -34,18 +34,11 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
mono-install-command: 'brew install mono'
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
|
||||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
|
||||||
|
|
||||||
- name: Install OpenGFX
|
- name: Install OpenGFX
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -20,18 +20,10 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}\vcpkg
|
|
||||||
${{ runner.temp }}\vcpkg\bootstrap-vcpkg.bat -disableMetrics
|
|
||||||
|
|
||||||
- name: Install OpenGFX
|
- name: Install OpenGFX
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -70,6 +62,7 @@ jobs:
|
||||||
-GNinja \
|
-GNinja \
|
||||||
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-windows-static \
|
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-windows-static \
|
||||||
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
||||||
|
-DVCPKG_INSTALL_OPTIONS="--debug" \
|
||||||
# EOF
|
# EOF
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
|
|
@ -26,18 +26,11 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
mono-install-command: 'sudo apt-get install -y --no-install-recommends mono-complete'
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
|
||||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -35,14 +35,6 @@ jobs:
|
||||||
- name: Enable Rust cache
|
- name: Enable Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Install system dependencies"
|
echo "::group::Install system dependencies"
|
||||||
|
@ -113,20 +105,16 @@ jobs:
|
||||||
# EOF
|
# EOF
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
# We use vcpkg for our dependencies, to get more up-to-date version.
|
|
||||||
echo "::group::Install vcpkg and dependencies"
|
|
||||||
|
|
||||||
git clone https://github.com/microsoft/vcpkg /vcpkg
|
|
||||||
|
|
||||||
(
|
|
||||||
cd /vcpkg
|
|
||||||
./bootstrap-vcpkg.sh -disableMetrics
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "::group::Install breakpad dependencies"
|
echo "::group::Install breakpad dependencies"
|
||||||
cargo install --locked dump_syms
|
cargo install --locked dump_syms
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Setup vcpkg
|
||||||
|
uses: ./.github/actions/setup-vcpkg
|
||||||
|
with:
|
||||||
|
vcpkg-location: /vcpkg
|
||||||
|
mono-install-command: 'yum install -y mono-complete'
|
||||||
|
|
||||||
- name: Install GCC problem matcher
|
- name: Install GCC problem matcher
|
||||||
uses: ammaraskar/gcc-problem-matcher@master
|
uses: ammaraskar/gcc-problem-matcher@master
|
||||||
|
|
||||||
|
|
|
@ -37,18 +37,11 @@ jobs:
|
||||||
- name: Enable Rust cache
|
- name: Enable Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
mono-install-command: 'brew install mono'
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
|
||||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -45,18 +45,10 @@ jobs:
|
||||||
- name: Enable Rust cache
|
- name: Enable Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Setup vcpkg caching
|
- name: Setup vcpkg
|
||||||
uses: actions/github-script@v7
|
uses: ./.github/actions/setup-vcpkg
|
||||||
with:
|
with:
|
||||||
script: |
|
vcpkg-location: ${{ runner.temp }}/vcpkg
|
||||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
||||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
||||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
||||||
|
|
||||||
- name: Install vcpkg
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}\vcpkg
|
|
||||||
${{ runner.temp }}\vcpkg\bootstrap-vcpkg.bat -disableMetrics
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -83,7 +83,7 @@ void AIInstance::Died()
|
||||||
|
|
||||||
void AIInstance::LoadDummyScript()
|
void AIInstance::LoadDummyScript()
|
||||||
{
|
{
|
||||||
ScriptAllocatorScope alloc_scope(this->engine);
|
ScriptAllocatorScope alloc_scope(this->engine.get());
|
||||||
Script_CreateDummy(this->engine->GetVM(), STR_ERROR_AI_NO_AI_FOUND, "AI");
|
Script_CreateDummy(this->engine->GetVM(), STR_ERROR_AI_NO_AI_FOUND, "AI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ static ScriptStorage &GetStorage()
|
||||||
|
|
||||||
/* static */ ScriptInstance *ScriptObject::ActiveInstance::active = nullptr;
|
/* static */ ScriptInstance *ScriptObject::ActiveInstance::active = nullptr;
|
||||||
|
|
||||||
ScriptObject::ActiveInstance::ActiveInstance(ScriptInstance &instance) : alc_scope(instance.engine)
|
ScriptObject::ActiveInstance::ActiveInstance(ScriptInstance &instance) : alc_scope(instance.engine.get())
|
||||||
{
|
{
|
||||||
this->last_active = ScriptObject::ActiveInstance::active;
|
this->last_active = ScriptObject::ActiveInstance::active;
|
||||||
ScriptObject::ActiveInstance::active = &instance;
|
ScriptObject::ActiveInstance::active = &instance;
|
||||||
|
@ -230,8 +230,8 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
|
|
||||||
/* static */ bool ScriptObject::CanSuspend()
|
/* static */ bool ScriptObject::CanSuspend()
|
||||||
{
|
{
|
||||||
Squirrel *squirrel = ScriptObject::GetActiveInstance().engine;
|
Squirrel &squirrel = *ScriptObject::GetActiveInstance().engine;
|
||||||
return GetStorage().allow_do_command && squirrel->CanSuspend();
|
return GetStorage().allow_do_command && squirrel.CanSuspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
||||||
|
|
|
@ -50,8 +50,8 @@ static void PrintFunc(bool error_msg, std::string_view message)
|
||||||
|
|
||||||
ScriptInstance::ScriptInstance(std::string_view api_name)
|
ScriptInstance::ScriptInstance(std::string_view api_name)
|
||||||
{
|
{
|
||||||
this->storage = new ScriptStorage();
|
this->storage = std::make_unique<ScriptStorage>();
|
||||||
this->engine = new Squirrel(api_name);
|
this->engine = std::make_unique<Squirrel>(api_name);
|
||||||
this->engine->SetPrintFunction(&PrintFunc);
|
this->engine->SetPrintFunction(&PrintFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ void ScriptInstance::Initialize(const std::string &main_script, const std::strin
|
||||||
{
|
{
|
||||||
ScriptObject::ActiveInstance active(*this);
|
ScriptObject::ActiveInstance active(*this);
|
||||||
|
|
||||||
this->controller = new ScriptController(company);
|
this->controller = std::make_unique<ScriptController>(company);
|
||||||
|
|
||||||
/* Register the API functions and classes */
|
/* Register the API functions and classes */
|
||||||
this->engine->SetGlobalPointer(this->engine);
|
this->engine->SetGlobalPointer(this->engine.get());
|
||||||
this->RegisterAPI();
|
this->RegisterAPI();
|
||||||
if (this->IsDead()) {
|
if (this->IsDead()) {
|
||||||
/* Failed to register API; a message has already been logged. */
|
/* Failed to register API; a message has already been logged. */
|
||||||
|
@ -81,12 +81,11 @@ void ScriptInstance::Initialize(const std::string &main_script, const std::strin
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the main-class */
|
/* Create the main-class */
|
||||||
this->instance = new SQObject();
|
this->instance = std::make_unique<SQObject>();
|
||||||
if (!this->engine->CreateClassInstance(instance_name, this->controller, this->instance)) {
|
if (!this->engine->CreateClassInstance(instance_name, this->controller.get(), this->instance.get())) {
|
||||||
/* If CreateClassInstance has returned false instance has not been
|
/* If CreateClassInstance has returned false instance has not been
|
||||||
* registered with squirrel, so avoid trying to Release it by clearing it now */
|
* registered with squirrel, so avoid trying to Release it by clearing it now */
|
||||||
delete this->instance;
|
this->instance.reset();
|
||||||
this->instance = nullptr;
|
|
||||||
this->Died();
|
this->Died();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -158,11 +157,10 @@ ScriptInstance::~ScriptInstance()
|
||||||
ScriptObject::ActiveInstance active(*this);
|
ScriptObject::ActiveInstance active(*this);
|
||||||
this->in_shutdown = true;
|
this->in_shutdown = true;
|
||||||
|
|
||||||
if (instance != nullptr) this->engine->ReleaseObject(this->instance);
|
if (instance != nullptr) this->engine->ReleaseObject(this->instance.get());
|
||||||
if (engine != nullptr) delete this->engine;
|
|
||||||
delete this->storage;
|
/* Engine must be reset explicitly in scope of the active instance. */
|
||||||
delete this->controller;
|
this->engine.reset();
|
||||||
delete this->instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptInstance::Continue()
|
void ScriptInstance::Continue()
|
||||||
|
@ -179,11 +177,9 @@ void ScriptInstance::Died()
|
||||||
|
|
||||||
this->last_allocated_memory = this->GetAllocatedMemory(); // Update cache
|
this->last_allocated_memory = this->GetAllocatedMemory(); // Update cache
|
||||||
|
|
||||||
if (this->instance != nullptr) this->engine->ReleaseObject(this->instance);
|
if (this->instance != nullptr) this->engine->ReleaseObject(this->instance.get());
|
||||||
delete this->instance;
|
this->engine.reset();
|
||||||
delete this->engine;
|
this->instance.reset();
|
||||||
this->instance = nullptr;
|
|
||||||
this->engine = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptInstance::GameLoop()
|
void ScriptInstance::GameLoop()
|
||||||
|
|
|
@ -256,7 +256,7 @@ public:
|
||||||
void ReleaseSQObject(HSQOBJECT *obj);
|
void ReleaseSQObject(HSQOBJECT *obj);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class Squirrel *engine = nullptr; ///< A wrapper around the squirrel vm.
|
std::unique_ptr<class Squirrel> engine; ///< A wrapper around the squirrel vm.
|
||||||
std::string api_version{}; ///< Current API used by this script.
|
std::string api_version{}; ///< Current API used by this script.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,9 +288,9 @@ protected:
|
||||||
virtual void LoadDummyScript() = 0;
|
virtual void LoadDummyScript() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ScriptController *controller = nullptr; ///< The script main class.
|
std::unique_ptr<class ScriptStorage> storage; ///< Some global information for each running script.
|
||||||
class ScriptStorage *storage = nullptr; ///< Some global information for each running script.
|
std::unique_ptr<class ScriptController> controller; ///< The script main class.
|
||||||
SQObject *instance = nullptr; ///< Squirrel-pointer to the script main class.
|
std::unique_ptr<SQObject> instance; ///< Squirrel-pointer to the script main class.
|
||||||
|
|
||||||
bool is_started = false; ///< Is the scripts constructor executed?
|
bool is_started = false; ///< Is the scripts constructor executed?
|
||||||
bool is_dead = false; ///< True if the script has been stopped.
|
bool is_dead = false; ///< True if the script has been stopped.
|
||||||
|
|
Loading…
Reference in New Issue