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
|
||||
|
||||
CXX := gcc -xc++ -lstdc++ -shared-libgcc
|
||||
include ../config.mk
|
||||
|
||||
BUILD := build
|
||||
DEPS := imgui
|
||||
SYNC := $(addsuffix -sync, $(DEPS))
|
||||
INCLUDE := include
|
||||
DEPS := imgui hammer
|
||||
|
||||
# imgui_impl_allegro5.o imgui_impl_android.o imgui_impl_dx9.o
|
||||
# imgui_impl_dx10.o imgui_impl_dx11.o imgui_impl_dx12.o
|
||||
# imgui_impl_glfw.o imgui_impl_glut.o imgui_impl_opengl2.o
|
||||
# imgui_impl_opengl3.o imgui_impl_sdl2.o imgui_impl_sdl3.o
|
||||
# imgui_impl_sdlgpu3.o imgui_impl_sdlrenderer2.o imgui_impl_sdlrenderer3.o
|
||||
# imgui_impl_vulkan.o imgui_impl_wgpu.o imgui_impl_win32.o
|
||||
# Dear ImGui
|
||||
IMGUI_UPSTREAM := https://github.com/ocornut/imgui.git
|
||||
IMGUI_BRANCH := docking
|
||||
IMGUI_REF := v1.92.3-docking
|
||||
IMGUI_SRC := imgui
|
||||
|
||||
# === 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
|
||||
# android glut sdlrenderer2
|
||||
# dx9 opengl2 sdlrenderer3
|
||||
|
|
@ -22,37 +32,107 @@ SYNC := $(addsuffix -sync, $(DEPS))
|
|||
# dx12 sdl3 win32
|
||||
IMGUI_ENABLE_BACKENDS := sdl3 opengl3
|
||||
|
||||
# Dear ImGui
|
||||
IMGUI_UPSTREAM := https://github.com/ocornut/imgui.git
|
||||
IMGUI_BRANCH := docking
|
||||
IMGUI_TAG := v1.92.3-docking
|
||||
# = HAMMER - VALID PARSERS =
|
||||
# = parsers/%.o =
|
||||
# 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_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 ===
|
||||
all: $(BUILD) $(STATICLIBS)
|
||||
$(BUILD):
|
||||
mkdir -p $(addprefix $(BUILD)/, $(DEPS))
|
||||
$(BUILD): $(addprefix $(BUILD)/, $(DEPS))
|
||||
$(BUILD)/imgui:
|
||||
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))
|
||||
ar rcs $@ $(filter %.o, $^)
|
||||
libhammer.a: hammer $(addprefix $(BUILD)/hammer/, $(HAMMER_OBJS))
|
||||
ar rcs $@ $(filter %.o, $^)
|
||||
|
||||
$(BUILD)/imgui/imgui_stdlib.o: $(IMGUI_SRC)/misc/cpp/imgui_stdlib.cpp
|
||||
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||
$(BUILD)/imgui/imgui_freetype.o: $(IMGUI_SRC)/misc/freetype/imgui_freetype.cpp
|
||||
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||
$(BUILD)/imgui/%.o: $(IMGUI_SRC)/%.cpp
|
||||
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||
$(BUILD)/imgui/backends/%.o: $(IMGUI_SRC)/backends/%.cpp
|
||||
$(CXX) -c $^ -o $@ -I$(IMGUI_SRC)
|
||||
|
||||
$(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
|
||||
|
||||
$(BUILD)/imgui/imgui_stdlib.o: imgui/misc/cpp/imgui_stdlib.cpp
|
||||
$(CXX) -c $^ -o $@ -Iimgui
|
||||
$(BUILD)/imgui/imgui_freetype.o: imgui/misc/freetype/imgui_freetype.cpp
|
||||
$(CXX) -c $^ -o $@ -Iimgui
|
||||
$(BUILD)/imgui/backends/%.o: imgui/backends/%.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) -c $^ -o $@ -Iimgui
|
||||
$(BUILD)/imgui/%.o: imgui/%.cpp
|
||||
$(CXX) -c $^ -o $@
|
||||
|
||||
# === SYNC TARGETS ===
|
||||
.PHONY: sync $(SYNC)
|
||||
|
|
@ -60,16 +140,33 @@ sync: $(SYNC)
|
|||
|
||||
imgui:
|
||||
mkdir -p $@
|
||||
- git -C $@ init
|
||||
- git -C $@ remote add upstream $(IMGUI_UPSTREAM)
|
||||
git -C $@ init
|
||||
git -C $@ remote add upstream $(IMGUI_UPSTREAM)
|
||||
$(MAKE) $@-sync
|
||||
imgui-sync: imgui
|
||||
git -C $< fetch upstream --tags
|
||||
git -C $< -c advice.detachedHead=false checkout $(IMGUI_TAG)
|
||||
git -C $< fetch upstream --tags --verbose
|
||||
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 ===
|
||||
.PHONY: clean purge
|
||||
clean:
|
||||
rm -rf $(BUILD) $(STATICLIBS)
|
||||
purge: clean
|
||||
CLEAN_DEP = $(@:clean-%=%)
|
||||
.PHONY: clean clean-%
|
||||
clean: $(CLEAN_DEPS)
|
||||
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)
|
||||
purge-%: clean-%
|
||||
rm -rf $(PURGE_DEP)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue