feat: refactor Value union to uint64_t and add C++98 compatibility for Wren VM
- Replace Value union with plain uint64_t typedef under WREN_NAN_TAGGING, removing num/bits field access - Add wrenValueToNum and wrenNumToValue helper functions for double conversion - Remove wrenValuesEqual function from wren_value.c as bitwise comparison is now direct - Update Makefile with CPPFLAGS for C++98 compilation and add release-cpp build target - Add wren-cpp and libwren-cpp.a to .gitignore for C++ build artifacts
This commit is contained in:
@@ -2,6 +2,7 @@ AR = ar rcu
|
||||
# Compiler flags.
|
||||
CFLAGS = -std=c99 -Wall -Werror
|
||||
# TODO: Add -Wextra.
|
||||
CPPFLAGS = -std=c++98 -Wall -Werror
|
||||
DEBUG_CFLAGS = -O0 -DDEBUG -g
|
||||
RELEASE_CFLAGS = -Os
|
||||
|
||||
@@ -11,9 +12,13 @@ HEADERS = $(wildcard src/*.h)
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
# Don't include main.c in the shared library.
|
||||
DEBUG_OBJECTS = $(subst build/debug/main.o,,$(addprefix build/debug/, $(notdir $(OBJECTS))))
|
||||
RELEASE_OBJECTS = $(subst build/release/main.o,,$(addprefix build/release/, $(notdir $(OBJECTS))))
|
||||
DEBUG_OBJECTS = $(addprefix build/debug/, $(notdir $(OBJECTS)))
|
||||
RELEASE_OBJECTS = $(addprefix build/release/, $(notdir $(OBJECTS)))
|
||||
RELEASE_CPP_OBJECTS = $(addprefix build/release-cpp/, $(notdir $(OBJECTS)))
|
||||
|
||||
DEBUG_LIB_OBJECTS = $(subst build/debug/main.o,,$(DEBUG_OBJECTS))
|
||||
RELEASE_LIB_OBJECTS = $(subst build/release/main.o,,$(RELEASE_OBJECTS))
|
||||
RELEASE_CPP_LIB_OBJECTS = $(subst build/release-cpp/main.o,,$(RELEASE_CPP_OBJECTS))
|
||||
|
||||
.PHONY: all clean test builtin docs watchdocs
|
||||
|
||||
@@ -23,38 +28,53 @@ clean:
|
||||
@rm -rf build wren wrend libwren.a libwrend.a
|
||||
|
||||
prep:
|
||||
@mkdir -p build/debug build/release
|
||||
@mkdir -p build/debug build/release build/release-cpp
|
||||
|
||||
# Debug build.
|
||||
debug: prep wrend
|
||||
debug: prep wrend libwrend.a
|
||||
|
||||
# Debug shared lib
|
||||
libwrend.a: $(DEBUG_OBJECTS)
|
||||
# Debug shared library.
|
||||
libwrend.a: $(DEBUG_LIB_OBJECTS)
|
||||
$(AR) $@ $^
|
||||
|
||||
# Debug command-line interpreter.
|
||||
wrend: build/debug/main.o libwrend.a
|
||||
$(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o wrend $^ -lm
|
||||
wrend: $(DEBUG_OBJECTS)
|
||||
$(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $^ -lm
|
||||
|
||||
# Debug object files.
|
||||
build/debug/%.o: src/%.c include/wren.h $(HEADERS)
|
||||
$(CC) -c -fPIC $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $<
|
||||
|
||||
# Release build.
|
||||
release: prep wren
|
||||
release: prep wren libwren.a
|
||||
|
||||
# Release shared lib
|
||||
libwren.a: $(RELEASE_OBJECTS)
|
||||
# Release shared library.
|
||||
libwren.a: $(RELEASE_LIB_OBJECTS)
|
||||
$(AR) $@ $^
|
||||
|
||||
# Release command-line interpreter.
|
||||
wren: build/release/main.o libwren.a
|
||||
$(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o wren $^ -lm
|
||||
wren: $(RELEASE_OBJECTS)
|
||||
$(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ $^ -lm
|
||||
|
||||
# Release object files.
|
||||
build/release/%.o: src/%.c include/wren.h $(HEADERS)
|
||||
$(CC) -c -fPIC $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ $<
|
||||
|
||||
# Release C++ build.
|
||||
release-cpp: prep wren-cpp libwren-cpp.a
|
||||
|
||||
# Release C++ shared lib
|
||||
libwren-cpp.a: $(RELEASE_CPP_LIB_OBJECTS)
|
||||
$(AR) $@ $^
|
||||
|
||||
# Release C++ command-line interpreter.
|
||||
wren-cpp: $(RELEASE_CPP_OBJECTS)
|
||||
$(CC) $(CPPFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ $^ -lm
|
||||
|
||||
# Release C++ object files.
|
||||
build/release-cpp/%.o: src/%.c include/wren.h $(HEADERS)
|
||||
$(CC) -c -fPIC $(CPPFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ -x c++ $<
|
||||
|
||||
# Run the tests against the debug build of Wren.
|
||||
test: debug
|
||||
@./script/test.py $(suite)
|
||||
|
||||
Reference in New Issue
Block a user