-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
279 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/build.yml' | ||
- 'src/**/*' | ||
- 'Cargo.toml' | ||
- 'package.sh' | ||
- 'package.ps1' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/build.yml' | ||
- 'src/**/*' | ||
- 'Cargo.toml' | ||
- 'package.sh' | ||
- 'package.ps1' | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.platform }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [windows-latest, ubuntu-latest, macos-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
./target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Build | ||
run: cargo build --release | ||
|
||
# - name: Package | ||
# if: matrix.platform != 'windows-latest' | ||
# run: chmod +x ./package.sh && ./package.sh | ||
# env: | ||
# LIB_FILE: ${{ matrix.platform != 'windows-latest' && 'lib' || '' }}file_metadata${{ matrix.platform == 'windows-latest' && '.dll' || matrix.platform == 'macos-latest' && '.dylib' || '.so' }} | ||
|
||
# - name: Package | ||
# if: matrix.platform == 'windows-latest' | ||
# run: ./package.ps1 | ||
# env: | ||
# LIB_FILE: ${{ matrix.platform != 'windows-latest' && 'lib' || '' }}file_metadata${{ matrix.platform == 'windows-latest' && '.dll' || matrix.platform == 'macos-latest' && '.dylib' || '.so' }} | ||
|
||
- name: Upload binary | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: lib-${{ matrix.platform }} | ||
# Find exec based on platform | ||
path: target/release/${{ matrix.platform != 'windows-latest' && 'lib' || '' }}file_metadata${{ matrix.platform == 'windows-latest' && '.dll' || matrix.platform == 'macos-latest' && '.dylib' || '.so' }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Code quality and formatting | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/backend.yml' | ||
- 'src/**' | ||
- 'Cargo.toml' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/backend.yml' | ||
- 'src/**' | ||
- 'Cargo.toml' | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
rustfmt: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --manifest-path ./Cargo.toml --all -- --check | ||
|
||
clippy: | ||
runs-on: ${{ matrix.platform }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [windows-latest, ubuntu-latest, macos-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --manifest-path ./Cargo.toml --all -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/test.yml' | ||
- 'src/**/*' | ||
- 'Cargo.toml' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/test.yml' | ||
- 'src/**/*' | ||
- 'Cargo.toml' | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.platform }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [windows-latest, ubuntu-latest, macos-latest] | ||
|
||
# Setup | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
./target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
# Build the library | ||
- name: Build | ||
run: cargo build --release | ||
|
||
# Build test/test.c | ||
- name: Build test | ||
run: gcc -o test/testlib test/test.c -L target/release -lfile_metadata | ||
|
||
# Run test/test.c | ||
- name: Run | ||
if: matrix.platform == 'macos-latest' | ||
run: ./test/testlib | ||
|
||
- name: Run | ||
if: matrix.platform == 'ubuntu-latest' | ||
run: LD_LIBRARY_PATH=target/release ./test/testlib | ||
|
||
- name: Run | ||
if: matrix.platform == 'windows-latest' | ||
run: move target\release\file_metadata.dll file_metadata.dll && test\testlib.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "gm-sysinfo" | ||
version = "1.0.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
sysinfo = "0.29.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# gms-sysinfo | ||
Get memory, CPU, and someday GPU info within your GameMaker game. | ||
<div align="center"> | ||
<h1>GM Sysinfo</h1> | ||
<p> | ||
Profile your game, and get it's (and the systems) resource usage! | ||
</p> | ||
</div> | ||
|
||
# Examples | ||
|
||
Below are some basic examples of the functionality in this extension | ||
|
||
## Display memory usage | ||
```gml | ||
// Get max memory of the system | ||
var max_mem = sysinfo_sys_mem_max(); | ||
|
||
// Get the memory usage of the game | ||
var mem = sysinfo_mem_usage(); | ||
|
||
// Display the cur / max (pct%) | ||
var max_mb = max_mem / 1024 / 1024; | ||
var mem_mb = mem / 1024 / 1024; | ||
|
||
draw_text(0, 0, string(mem_mb) + " / " + string(max_mb) + " (" + string(mem / max_mem * 100) + "%)"); | ||
``` | ||
## Display CPU usage | ||
```gml | ||
// Get the CPU and memory usage of the game | ||
var cpu_name = sysinfo_cpu_name(); | ||
var cpu = sysinfo_cpu_usage(); | ||
// Display the % | ||
draw_text(0, 0, cpu_name + ": " + string(cpu) + "%"); | ||
``` | ||
|
||
# TODO | ||
|
||
- [ ] CPU usage | ||
- [ ] Memory usage | ||
- [ ] System name/hostname | ||
- [ ] GPU usage(?) | ||
|
||
# Documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use sysinfo::{ | ||
System, | ||
SystemExt, | ||
Process, | ||
ProcessExt, | ||
Cpu, | ||
CpuExt, | ||
User, | ||
UserExt | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdio.h> | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
// Include winbase on Windows | ||
#include <stdio.h> /* defines FILENAME_MAX */ | ||
#ifdef _WIN32 | ||
#include <direct.h> | ||
#define GetCurrentDir _getcwd | ||
#else | ||
#include <unistd.h> | ||
#define GetCurrentDir getcwd | ||
#endif | ||
|
||
// Function prototypes for Rust functions | ||
// extern | ||
|
||
int main() { | ||
printf("All tests passed!\n"); | ||
|
||
return 0; | ||
} |