Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6 from AffectedArc07/version-operator
Browse files Browse the repository at this point in the history
Adds version property
  • Loading branch information
variableundefined authored Feb 2, 2021
2 parents b786233 + 6ed3a6b commit 426f80c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-g"
edition = "2018"
version = "0.4.5-P"
version = "0.4.5-P2"
authors = ["Bjorn Neergaard <[email protected]>"]
repository = "https://github.com/ParadiseSS13/rust-g"
license-file = "LICENSE"
Expand Down
62 changes: 23 additions & 39 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,15 @@ fn main() {
// header
write!(
f,
r#"// rust_g.dm - DM API for rust_g extension library
//
// To configure, create a `rust_g.config.dm` and set what you care about from
// the following options:
//
// #define RUST_G "path/to/rust_g"
// Override the .dll/.so detection logic with a fixed path or with detection
// logic of your own.
//
// #define RUSTG_OVERRIDE_BUILTINS
// Enable replacement rust-g functions for certain builtins. Off by default.
#ifndef RUST_G
// Default automatic RUST_G detection.
// On Windows, looks in the standard places for `rust_g.dll`.
// On Linux, looks in `.`, `$LD_LIBRARY_PATH`, and `~/.byond/bin` for either of
// `librust_g.so` (preferred) or `rust_g` (old).
/* This comment bypasses grep checks */ /var/__rust_g
/proc/__detect_rust_g()
if (world.system_type == UNIX)
if (fexists("./librust_g.so"))
// No need for LD_LIBRARY_PATH badness.
return __rust_g = "./librust_g.so"
else if (fexists("./rust_g"))
// Old dumb filename.
return __rust_g = "./rust_g"
else if (fexists("[world.GetConfig("env", "HOME")]/.byond/bin/rust_g"))
// Old dumb filename in `~/.byond/bin`.
return __rust_g = "rust_g"
else
// It's not in the current directory, so try others
return __rust_g = "librust_g.so"
else
return __rust_g = "rust_g"
#define RUST_G (__rust_g || __detect_rust_g())
r#"#ifndef RUST_G
/// Locator for the RUSTG DLL or SO depending on system type. Override if needed.
#define RUST_G (world.system_type == UNIX ? "./librust_g.so" : "./rust_g.dll")
#endif
// Gets the version of RUSTG
/proc/rustg_get_version() return call(RUST_G, "get_version")()
// Defines for internal job subsystem //
#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
#define RUSTG_JOB_ERROR "JOB PANICKED"
Expand All @@ -64,6 +33,7 @@ fn main() {
// module: dmi
if enabled!("DMI") {
write!(f, r#"
// DMI related operations //
#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)
#define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data)
"#).unwrap();
Expand All @@ -72,6 +42,7 @@ fn main() {
// module: noise
if enabled!("NOISE") {
write!(f, r#"
// Noise related operations //
#define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y)
"#).unwrap()
}
Expand All @@ -81,6 +52,7 @@ fn main() {
write!(
f,
r#"
// File related operations //
#define rustg_file_read(fname) call(RUST_G, "file_read")(fname)
#define rustg_file_write(text, fname) call(RUST_G, "file_write")(text, fname)
#define rustg_file_append(text, fname) call(RUST_G, "file_append")(text, fname)
Expand All @@ -99,6 +71,7 @@ fn main() {
write!(
f,
r#"
// Git related operations //
#define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev)
#define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev)
"#
Expand All @@ -109,6 +82,7 @@ fn main() {
// module: hash
if enabled!("HASH") {
write!(f, r#"
// Hash related operations //
#define rustg_hash_string(algorithm, text) call(RUST_G, "hash_string")(algorithm, text)
#define rustg_hash_file(algorithm, fname) call(RUST_G, "hash_file")(algorithm, fname)
Expand All @@ -128,7 +102,8 @@ fn main() {
write!(
f,
r#"
#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format)
// Logging stuff //
#define rustg_log_write(fname, text) call(RUST_G, "log_write")(fname, text)
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
"#
)
Expand All @@ -140,6 +115,7 @@ fn main() {
write!(
f,
r#"
// URL encoding stuff
#define rustg_url_encode(text) call(RUST_G, "url_encode")(text)
#define rustg_url_decode(text) call(RUST_G, "url_decode")(text)
Expand All @@ -155,6 +131,7 @@ fn main() {
// module: http
if enabled!("HTTP") {
write!(f, r#"
// HTTP library stuff //
#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
#define RUSTG_HTTP_METHOD_DELETE "delete"
Expand All @@ -172,6 +149,7 @@ fn main() {
// module: sql
if enabled!("SQL") {
write!(f, r#"
// SQL stuff //
#define rustg_sql_connect_pool(options) call(RUST_G, "sql_connect_pool")(options)
#define rustg_sql_query_async(handle, query, params) call(RUST_G, "sql_query_async")(handle, query, params)
#define rustg_sql_query_blocking(handle, query, params) call(RUST_G, "sql_query_blocking")(handle, query, params)
Expand All @@ -180,4 +158,10 @@ fn main() {
#define rustg_sql_check_query(job_id) call(RUST_G, "sql_check_query")("[job_id]")
"#).unwrap();
}

// Version footer
write!(f, "
// RUSTG Version //
#define RUST_G_VERSION \"{}\""
, env!("CARGO_PKG_VERSION")).unwrap();
}
5 changes: 5 additions & 0 deletions src/byond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,8 @@ macro_rules! byond_fn {
}
};
}

// Easy version checker. Its in this file so its included no matter what
byond_fn! { get_version() {
Some(env!("CARGO_PKG_VERSION"))
} }

0 comments on commit 426f80c

Please sign in to comment.