BAPI - spacemandmm dmm reading (#19118)

More bapi work, docs, etc.


The actual changes seen from DM side, is that all maps are parsed and
checked by spacemandmm. It does not really add much safety for us, as
everyone uses strongdmm anyways (which uses spacemandmm), but I will
need to do that anyways in future work.

The bapi call is on every map in the maploader, so if it does not work,
if it crashes or panics or whatever, we'll see it immediately (cause the
maps don't load). It should work fine, though, unless the setup is
wrong. I wrote more about safety and other things in readme text file in
rust/bapi dir.


So, yeah. The point of this PR is to do something meaningful with bapi,
and see if the whole workflow and setup and everything works correctly,
before doing any further work in future PRs.

---------

Co-authored-by: DreamySkrell <>
Co-authored-by: AuroraBuildBot <action@github.com>
This commit is contained in:
DreamySkrell
2024-05-23 19:23:38 +00:00
committed by GitHub
co-authored by DreamySkrell <> AuroraBuildBot
parent a40c981263
commit a78701f553
10 changed files with 688 additions and 32 deletions
+15 -9
View File
@@ -1,9 +1,10 @@
// Default automatic .dll/.so detection.
// Look for it in the build location first, then in `.`, then in standard places.
// ------------------------------------------- .dll/.so detection
/// Global var set to bapi .dll/.so location.
/* This comment bypasses grep checks */ /var/__bapi
/// Look for .dll/.so in the build location first, then in `.`, then in standard places.
/proc/__detect_bapi()
if(world.system_type == UNIX)
#ifdef CIBUILDING
@@ -12,17 +13,20 @@
return __bapi = "tools/ci/libbapi_ci.so"
#endif
// First check if it's built in the usual place.
if(fexists("./bapi/target/i686-unknown-linux-gnu/release/libbapi.so"))
return __bapi = "./bapi/target/i686-unknown-linux-gnu/release/libbapi.so"
if(fexists("./rust/bapi/target/i686-unknown-linux-gnu/release/libbapi.so"))
return __bapi = "./rust/bapi/target/i686-unknown-linux-gnu/release/libbapi.so"
// Then check in the current directory.
if(fexists("./libbapi.so"))
return __bapi = "./libbapi.so"
// And elsewhere.
return __bapi = "libbapi.so"
else
// First check if it's built in the usual place.
// First check if it's built in the usual place when working on it locally.
if(fexists("./rust/bapi/target/i686-pc-windows-msvc/release/bapi.dll"))
return __bapi = "./rust/bapi/target/i686-pc-windows-msvc/release/bapi.dll"
// Also check the debug location if compiled without optimizations.
if(fexists("./rust/bapi/target/i686-pc-windows-msvc/debug/bapi.dll"))
return __bapi = "./rust/bapi/target/i686-pc-windows-msvc/debug/bapi.dll"
// Then check in the current directory.
if(fexists("./bapi.dll"))
return __bapi = "./bapi.dll"
@@ -31,9 +35,11 @@
#define BAPI (__bapi || __detect_bapi())
#define BAPI_CALL(func, args...) call_ext(BAPI, "byond:[#func]_ffi")(args)
#define BAPI_CALL(func, args...) call_ext(BAPI, "byond:[#func]")(args)
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// ------------------------------------------- bapi functions callable from dm
// Should only call functions ending with `_ffi`.
#define bapi_hello_world(arg) BAPI_CALL(hello_world, arg)
#define bapi_read_dmm_file(arg) BAPI_CALL(read_dmm_file_ffi, arg)
// ------------------------------------------- fin
+2 -1
View File
@@ -1,4 +1,5 @@
/// gives us the stack trace from CRASH() without ending the current proc.
/// Gives us the stack trace from CRASH() without ending the current proc.
/// Do not call directly, use the [stack_trace] macro instead.
/// May also be used by other tooling like from rust.
/proc/_stack_trace(message, file, line)
CRASH("[message] ([file]:[line])")
+2 -1
View File
@@ -50,7 +50,8 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new)
/dmm_suite/proc/load_map_impl(dmm_file, x_offset, y_offset, z_offset, cropMap, measureOnly, no_changeturf, x_lower = -INFINITY, x_upper = INFINITY, y_lower = -INFINITY, y_upper = INFINITY)
var/tfile = dmm_file//the map file we're creating
if(isfile(tfile))
tfile = file2text(tfile)
// tfile = file2text(tfile)
tfile = bapi_read_dmm_file("[tfile]") // `tfile` is of type `File`, this makes it into just a string of its path
if(!x_offset)
x_offset = 1