Skip to content

Commit

Permalink
add variable to specify compilation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiyoshika committed Dec 2, 2023
1 parent eb2f1a2 commit f356027
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
29 changes: 25 additions & 4 deletions crates/gosub-bindings/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions crates/gosub-bindings/README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit f356027

Please sign in to comment.