diff --git a/crates/gosub-bindings/Makefile b/crates/gosub-bindings/Makefile index d49c252d8..e4f0cc63f 100644 --- a/crates/gosub-bindings/Makefile +++ b/crates/gosub-bindings/Makefile @@ -1,15 +1,36 @@ # "global" compile settings + +# compilation mode Release or Debug +MODE?=Release + CFLAGS_DEBUG := -std=c99 -g -Wall -Wextra -O0 CFLAGS_RELEASE := -std=c99 -Wall -Wextra -O2 -CFLAGS := $(CFLAGS_RELEASE) # *** CONFIGURE RELEASE OR DUBUG MODE *** + +TARGET_DIR_RELEASE := ../../target/release +TARGET_DIR_DEBUG := ../../target/debug + +ifeq ($(MODE), Release) +$(info ***** COMPILING IN RELEASE MODE *****) +CFLAGS = $(CFLAGS_RELEASE) +TARGET_DIR = $(TARGET_DIR_RELEASE) +else ifeq ($(MODE), Debug) +$(info ***** COMPILING IN DEBUG MODE *****) +CFLAGS = $(CFLAGS_DEBUG) +TARGET_DIR = $(TARGET_DIR_DEBUG) +else +$(warning ***** UNKNOWN MODE. DEFAULTING TO RELEASE MODE *****) +CFLAGS = $(CFLAGS_RELEASE) +TARGET_DIR = $(TARGET_DIR_RELEASE) +endif + +CC := gcc INCLUDE_DIR := include SRC_DIR := src +NODE_SRC_DIR := $(SRC_DIR)/nodes + CPPFLAGS := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/nodes -CC := gcc -TARGET_DIR := ../../target/debug LDFLAGS := -L$(TARGET_DIR) -NODE_SRC_DIR := $(SRC_DIR)/nodes bindings: # build gosub static library to be used externally $(CC) $(CFLAGS) $(CPPFLAGS) -c $(SRC_DIR)/gosub_api.c $(SRC_DIR)/nodes.c $(NODE_SRC_DIR)/text.c diff --git a/crates/gosub-bindings/README.md b/crates/gosub-bindings/README.md new file mode 100644 index 000000000..f084b7f10 --- /dev/null +++ b/crates/gosub-bindings/README.md @@ -0,0 +1,18 @@ +# Gosub Bindings +These are the bindings the expose some of Gosub's engine to the world via a C API. Typically these will be used by user agents. + +## Building +By default, the bindings will be built in release mode. You can modify this by specifying a `MODE` variable: +```text +export MODE=Debug # or MODE=Release (default) +make bindings +make test +``` + +or alternatively specify it manually (not recommended) +```text +make bindings MODE=Debug +make test MODE=Debug +``` + +This approach is not recommended because if you forget to specify it, it will default to release mode and you may be using the wrong version.