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

Various improvements for app startup #190

Merged
merged 12 commits into from
Nov 21, 2023
10 changes: 7 additions & 3 deletions .github/workflows/pr_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
run: echo $SHA_SHORT
- name: Extract branch name
shell: bash
run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
run: |
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "BRANCH=${BRANCH_NAME/\//\\\/}" >> $GITHUB_ENV
- name: Confirm nightly build name
id: build_name
run: |
Expand All @@ -54,10 +56,12 @@ jobs:
- uses: actions/checkout@v4
- name: Update build number
run: |
sed -i 's/Config.gameVersion = \".*\"/Config.gameVersion = \"${{ needs.gen-build-version.outputs.build }}\"/' "${env:GITHUB_WORKSPACE}/script/Config/App.lua"
sed -i 's/Config.gameVersion = \".*\"/Config.gameVersion = \"${{ needs.gen-build-version.outputs.build }}\"/' "${env:GITHUB_WORKSPACE}/script/Config/Version.lua"
- name: Build
shell: bash
run: ./build.sh
run: |
PHX_VERSION="${{ needs.gen-build-version.outputs.build }}"
./build.sh
- name: Upload binary
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ jobs:
sed -i 's/Config.gameVersion = \".*\"/Config.gameVersion = \"${{ needs.gen-build-version.outputs.build }}\"/' "${env:GITHUB_WORKSPACE}/script/Config/Version.lua"
- name: Build
shell: bash
run: ./build.sh
run: |
PHX_VERSION="${{ needs.gen-build-version.outputs.build }}"
./build.sh
- name: Upload binary
uses: actions/upload-artifact@v3
with:
Expand Down
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ fi
mkdir -p bin
if [[ $debug = 1 ]]; then
cargo build
cargo test --no-fail-fast
cp target/debug/ltr${binsuffix} bin/lt64d${binsuffix}
cp target/debug/deps/${libprefix}phx${libsuffix} bin/${libprefix}phx${libsuffix}
else
cargo build --release
cargo test --release
cp target/release/ltr${binsuffix} bin/lt64${binsuffix}
cp target/release/deps/${libprefix}phx${libsuffix} bin/${libprefix}phx${libsuffix}
fi
2 changes: 2 additions & 0 deletions engine/bin/ltr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ edition.workspace = true
phx.workspace = true

# external crates
build-time = "0.1"
clap = { version = "4.4", features = ["derive"] }
git-version = "0.3"
libc = "0.2"

[build-dependencies]
Expand Down
11 changes: 11 additions & 0 deletions engine/bin/ltr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use std::ffi::CString;

use clap::Parser;

const BUILD_TIME: &str = build_time::build_time_utc!("%Y-%m-%d / %H:%M:%S UTC");
const GIT_VERSION: &str = git_version::git_version!(args = ["--tags", "--always", "--dirty=M"]);

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
Expand Down Expand Up @@ -41,6 +44,14 @@ extern "C" {
}

pub fn main() {
println!(
"App: {}, ver: {}, git: {}, build time: {}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
GIT_VERSION,
BUILD_TIME
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will show in a log string like this:

App: ltr, ver: 0.1.0, git: latest-380-g03a57d95, build time: 2023-11-21 / 12:19:42 UTC


let cli = Cli::parse();

let entry_point = CString::new(cli.entry_point)
Expand Down
7 changes: 7 additions & 0 deletions engine/lib/phx/script/ffi_ext/Engine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local libphx = require('libphx').lib

function onDef_Engine(t, mt)
t.GetVersion = function()
return ffi.string(libphx.Engine_GetVersion())
end
end
4 changes: 4 additions & 0 deletions script/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function InitSystem()
GlobalRestrict.On()

dofile('./script/Config/Version.lua')
if Config.gameVersion ~= "0.0.0" and Config.gameVersion ~= Engine.GetVersion() then
Log.Error("Engine and script version mismatch. Engine: %s. Script: %s.", Engine.GetVersion(), Config.gameVersion)
end

dofile('./script/Config/App.lua')

-- Load Enums
Expand Down