package hammer parsing library
This commit is contained in:
parent
3bc2ef9dbf
commit
8ca1d135cf
1 changed files with 137 additions and 40 deletions
177
deps/Makefile
vendored
177
deps/Makefile
vendored
|
|
@ -1,19 +1,29 @@
|
||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
CXX := gcc -xc++ -lstdc++ -shared-libgcc
|
include ../config.mk
|
||||||
|
|
||||||
BUILD := build
|
BUILD := build
|
||||||
DEPS := imgui
|
INCLUDE := include
|
||||||
SYNC := $(addsuffix -sync, $(DEPS))
|
DEPS := imgui hammer
|
||||||
|
|
||||||
# imgui_impl_allegro5.o imgui_impl_android.o imgui_impl_dx9.o
|
# Dear ImGui
|
||||||
# imgui_impl_dx10.o imgui_impl_dx11.o imgui_impl_dx12.o
|
IMGUI_UPSTREAM := https://github.com/ocornut/imgui.git
|
||||||
# imgui_impl_glfw.o imgui_impl_glut.o imgui_impl_opengl2.o
|
IMGUI_BRANCH := docking
|
||||||
# imgui_impl_opengl3.o imgui_impl_sdl2.o imgui_impl_sdl3.o
|
IMGUI_REF := v1.92.3-docking
|
||||||
# imgui_impl_sdlgpu3.o imgui_impl_sdlrenderer2.o imgui_impl_sdlrenderer3.o
|
IMGUI_SRC := imgui
|
||||||
# imgui_impl_vulkan.o imgui_impl_wgpu.o imgui_impl_win32.o
|
|
||||||
|
|
||||||
# === DEAR IMGUI = VALID BACKENDS ===
|
# Hammer
|
||||||
|
# HAMMER_UPSTREAM := https://github.com/UpstandingHackers/hammer.git
|
||||||
|
# HAMMER_BRANCH := master
|
||||||
|
# HAMMER_REF := cc733ffb77cb13071322353d0e17a7e57a15ebe6
|
||||||
|
# XXX: WARNING: pin HAMMER_REF to avoid bad commits breaking enby
|
||||||
|
HAMMER_UPSTREAM := https://forge.imbored.dev/emileclarkb/hammer.git
|
||||||
|
HAMMER_BRANCH := main
|
||||||
|
HAMMER_REF := $(HAMMER_BRANCH)
|
||||||
|
HAMMER_SRC := hammer/src
|
||||||
|
|
||||||
|
# = DEARIMGUI - VALID BACKENDS =
|
||||||
|
# = backends/imgui_impl_%.o =
|
||||||
# allegro5 glfw sdlgpu3
|
# allegro5 glfw sdlgpu3
|
||||||
# android glut sdlrenderer2
|
# android glut sdlrenderer2
|
||||||
# dx9 opengl2 sdlrenderer3
|
# dx9 opengl2 sdlrenderer3
|
||||||
|
|
@ -22,54 +32,141 @@ SYNC := $(addsuffix -sync, $(DEPS))
|
||||||
# dx12 sdl3 win32
|
# dx12 sdl3 win32
|
||||||
IMGUI_ENABLE_BACKENDS := sdl3 opengl3
|
IMGUI_ENABLE_BACKENDS := sdl3 opengl3
|
||||||
|
|
||||||
# Dear ImGui
|
# = HAMMER - VALID PARSERS =
|
||||||
IMGUI_UPSTREAM := https://github.com/ocornut/imgui.git
|
# = parsers/%.o =
|
||||||
IMGUI_BRANCH := docking
|
# action and attr_bool bind
|
||||||
IMGUI_TAG := v1.92.3-docking
|
# bits butnot ch charset
|
||||||
|
# choice difference end endianness
|
||||||
|
# epsilon ignore ignoreseq indirect
|
||||||
|
# int_range many not nothing
|
||||||
|
# optional permutation sequence token
|
||||||
|
# unimplemented whitespace xor value
|
||||||
|
HAMMER_ENABLE_PARSERS := action and attr_bool bind \
|
||||||
|
bits butnot ch charset \
|
||||||
|
choice difference end endianness \
|
||||||
|
epsilon ignore ignoreseq indirect \
|
||||||
|
int_range many not nothing \
|
||||||
|
optional permutation sequence token \
|
||||||
|
unimplemented whitespace xor value
|
||||||
|
# = HAMMER - VALID BACKENDS =
|
||||||
|
# = backends/%.o =
|
||||||
|
# packrat llk regex glr lalr lr lr0
|
||||||
|
HAMMER_ENABLE_BACKENDS = packrat llk regex glr lalr lr lr0
|
||||||
|
|
||||||
IMGUI_BACKENDS := $(foreach backend, $(IMGUI_ENABLE_BACKENDS), imgui_impl_$(backend).o)
|
|
||||||
|
|
||||||
IMGUI_OBJS := imgui.o imgui_demo.o \
|
|
||||||
imgui_draw.o imgui_tables.o imgui_widgets.o \
|
|
||||||
imgui_freetype.o imgui_stdlib.o \
|
|
||||||
$(addprefix backends/, $(IMGUI_BACKENDS))
|
|
||||||
|
|
||||||
STATICLIBS := $(foreach dep, $(DEPS), lib$(dep).a)
|
IMGUI_BACKENDS := $(foreach backend, $(IMGUI_ENABLE_BACKENDS), backends/imgui_impl_$(backend).o)
|
||||||
|
|
||||||
|
IMGUI_OBJS := imgui.o imgui_demo.o \
|
||||||
|
imgui_draw.o imgui_tables.o imgui_widgets.o \
|
||||||
|
imgui_freetype.o imgui_stdlib.o \
|
||||||
|
$(IMGUI_BACKENDS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HAMMER_PARSERS := $(foreach parser, $(HAMMER_ENABLE_PARSERS), parsers/$(parser).o)
|
||||||
|
HAMMER_BACKENDS := $(foreach backend, $(HAMMER_ENABLE_BACKENDS), backends/$(backend).o)
|
||||||
|
|
||||||
|
HAMMER_TESTS := t_benchmark t_bitreader t_bitwriter t_parser \
|
||||||
|
t_grammar t_regression t_mm t_misc
|
||||||
|
|
||||||
|
HAMMER_HEADERS := hammer.h glue.h allocator.h \
|
||||||
|
backends/regex.h backends/contextfree.h platform.h \
|
||||||
|
internal.h parsers/parser_internal.h compiler_specifics.h
|
||||||
|
|
||||||
|
HAMMER_OBJS = hammer.o glue.o benchmark.o \
|
||||||
|
cfgrammar.o desugar.o registry.o \
|
||||||
|
allocator.o system_allocator.o sloballoc.o \
|
||||||
|
bitreader.o bitwriter.o pprint.o \
|
||||||
|
datastructures.o $(HAMMER_PARSERS) $(HAMMER_BACKENDS)
|
||||||
|
ifeq ($(PLATFORM), WINDOWS_NT)
|
||||||
|
HAMMER_OBJS += platform_win32.o tsearch.o
|
||||||
|
else
|
||||||
|
HAMMER_OBJS += platform_bsdlike.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# === MACRO DEFINITIONS ===
|
||||||
|
define libpath =
|
||||||
|
$(addprefix lib, $(1).a)
|
||||||
|
endef
|
||||||
|
|
||||||
|
SYNC := $(addsuffix -sync, $(DEPS))
|
||||||
|
STATICLIBS := $(foreach dep, $(DEPS), $(call libpath, $(dep)))
|
||||||
|
|
||||||
# === BUILD TARGETS ===
|
# === BUILD TARGETS ===
|
||||||
all: $(BUILD) $(STATICLIBS)
|
$(BUILD): $(addprefix $(BUILD)/, $(DEPS))
|
||||||
$(BUILD):
|
$(BUILD)/imgui:
|
||||||
mkdir -p $(addprefix $(BUILD)/, $(DEPS))
|
mkdir -p $@ $@/backends
|
||||||
|
$(BUILD)/hammer:
|
||||||
|
mkdir -p $@ $@/parsers $@/backends
|
||||||
|
$(INCLUDE): $(INCLUDE)/hammer
|
||||||
|
$(INCLUDE)/hammer: $(addprefix $(HAMMER_SRC)/, $(HAMMER_HEADERS))
|
||||||
|
mkdir -p $@
|
||||||
|
cp $^ $@
|
||||||
|
|
||||||
|
$(IMGUI_SRC)/%: imgui
|
||||||
|
test -f $@
|
||||||
|
$(HAMMER_SRC)/%: hammer
|
||||||
|
test -f $@
|
||||||
|
|
||||||
|
# NOTE: $(INCLUDE) will force gmake to call the sync target
|
||||||
|
all: $(BUILD) $(INCLUDE) $(STATICLIBS)
|
||||||
libimgui.a: imgui $(addprefix $(BUILD)/imgui/, $(IMGUI_OBJS))
|
libimgui.a: imgui $(addprefix $(BUILD)/imgui/, $(IMGUI_OBJS))
|
||||||
ar rcs $@ $(filter %.o, $^)
|
ar rcs $@ $(filter %.o, $^)
|
||||||
|
libhammer.a: hammer $(addprefix $(BUILD)/hammer/, $(HAMMER_OBJS))
|
||||||
|
ar rcs $@ $(filter %.o, $^)
|
||||||
|
|
||||||
$(BUILD)/imgui/imgui_stdlib.o: imgui/misc/cpp/imgui_stdlib.cpp
|
$(BUILD)/imgui/imgui_stdlib.o: $(IMGUI_SRC)/misc/cpp/imgui_stdlib.cpp
|
||||||
$(CXX) -c $^ -o $@ -Iimgui
|
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||||
$(BUILD)/imgui/imgui_freetype.o: imgui/misc/freetype/imgui_freetype.cpp
|
$(BUILD)/imgui/imgui_freetype.o: $(IMGUI_SRC)/misc/freetype/imgui_freetype.cpp
|
||||||
$(CXX) -c $^ -o $@ -Iimgui
|
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||||
$(BUILD)/imgui/backends/%.o: imgui/backends/%.cpp
|
$(BUILD)/imgui/%.o: $(IMGUI_SRC)/%.cpp
|
||||||
mkdir -p $(dir $@)
|
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||||
$(CXX) -c $^ -o $@ -Iimgui
|
$(BUILD)/imgui/backends/%.o: $(IMGUI_SRC)/backends/%.cpp
|
||||||
$(BUILD)/imgui/%.o: imgui/%.cpp
|
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||||
$(CXX) -c $^ -o $@
|
|
||||||
|
|
||||||
|
$(BUILD)/hammer/%.o: $(HAMMER_SRC)/%.c
|
||||||
|
$(CC) -c $^ -o $@ -I$(HAMMER_SRC)
|
||||||
|
$(BUILD)/hammer/parsers/%.o: $(HAMMER_SRC)/parsers/%.c
|
||||||
|
$(CC) -c $^ -o $@ -I$(HAMMER_SRC) -I$(HAMMER_SRC)/parsers
|
||||||
|
$(BUILD)/hammer/backends/%.o: $(HAMMER_SRC)/backends/%.c
|
||||||
|
$(CC) -c $^ -o $@ -I$(HAMMER_SRC) -I$(HAMMER_SRC)/backends
|
||||||
|
|
||||||
|
|
||||||
# === SYNC TARGETS ===
|
# === SYNC TARGETS ===
|
||||||
.PHONY: sync $(SYNC)
|
.PHONY: sync $(SYNC)
|
||||||
sync: $(SYNC)
|
sync: $(SYNC)
|
||||||
|
|
||||||
imgui:
|
imgui:
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
- git -C $@ init
|
git -C $@ init
|
||||||
- git -C $@ remote add upstream $(IMGUI_UPSTREAM)
|
git -C $@ remote add upstream $(IMGUI_UPSTREAM)
|
||||||
$(MAKE) $@-sync
|
$(MAKE) $@-sync
|
||||||
imgui-sync: imgui
|
imgui-sync: imgui
|
||||||
git -C $< fetch upstream --tags
|
git -C $< fetch upstream --tags --verbose
|
||||||
git -C $< -c advice.detachedHead=false checkout $(IMGUI_TAG)
|
git -C $< -c advice.detachedHead=false checkout $(IMGUI_REF)
|
||||||
|
|
||||||
|
hammer:
|
||||||
|
mkdir -p $@
|
||||||
|
git -C $@ init
|
||||||
|
git -C $@ remote add upstream $(HAMMER_UPSTREAM)
|
||||||
|
$(MAKE) $@-sync
|
||||||
|
hammer-sync: hammer
|
||||||
|
git -C $< fetch upstream --verbose
|
||||||
|
git -C $< -c advice.detachedHead=false checkout $(HAMMER_REF)
|
||||||
|
|
||||||
# === UTILITY TARGETS ===
|
# === UTILITY TARGETS ===
|
||||||
.PHONY: clean purge
|
CLEAN_DEP = $(@:clean-%=%)
|
||||||
clean:
|
.PHONY: clean clean-%
|
||||||
rm -rf $(BUILD) $(STATICLIBS)
|
clean: $(CLEAN_DEPS)
|
||||||
purge: clean
|
rm -rf $(INCLUDE) $(BUILD) $(STATICLIBS)
|
||||||
|
clean-%:
|
||||||
|
rm -rf $(INCLUDE)/$(CLEAN_DEP) $(BUILD)/$(CLEAN_DEP) $(call libpath, $(CLEAN_DEP))
|
||||||
|
|
||||||
|
PURGE_DEP = $(@:purge-%=%)
|
||||||
|
.PHONY: purge purge-%
|
||||||
|
purge: $(PURGE_DEPS) clean
|
||||||
rm -rf $(DEPS)
|
rm -rf $(DEPS)
|
||||||
|
purge-%: clean-%
|
||||||
|
rm -rf $(PURGE_DEP)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue