From 50e76ae71277877202cceabf781ded30ce627389 Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 22 Aug 2022 12:11:55 +0000 Subject: [PATCH] Restore filec compilation in makefiles FossilOrigin-Name: a6559f6e98a925371e2c75272f054c4069c89437b9872c80d641d92b800aac37 --- Makefile | 12 +++++++-- src/emoji_reaction.c | 60 -------------------------------------------- src/emoji_reaction.h | 3 --- 3 files changed, 10 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 8157407..c3b4497 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpc SRC = $(wildcard src/*.c) OBJ = $(patsubst %.c,%.o,$(SRC)) HEADERS = $(wildcard src/*.h) config.h -PAGES_DIR = static +TMPL_DIR = templates +TMPLS = $(wildcard $(TMPL_DIR)/*.tt) +TMPLS_C = $(patsubst %.tt,%.ctt,$(TMPLS)) TEST_DIR = test/unit TESTS = $(wildcard $(TEST_DIR)/t*.c) UNIT_TESTS = $(patsubst %.c,%.bin,$(TESTS)) @@ -25,6 +27,7 @@ MASTODONT_URL = https://fossil.nekobit.net/mastodont-c all: $(MAKE) dep_build $(MAKE) filec + $(MAKE) make_tmpls $(MAKE) $(TARGET) install_deps: @@ -40,6 +43,11 @@ emojitoc: scripts/emoji-to.o $(CC) -o emojitoc $< $(LDFLAGS) ./emojitoc meta/emoji.json > src/emoji_codes.h +$(TMPL_DIR)/%.ctt: $(TMPL_DIR)/%.tt + ./filec $< data_$(notdir $*)_tt > $@ + +make_tmpls: $(TMPLS_C) + $(MASTODONT_DIR): cd ..; fossil clone $(MASTODONT_URL) || true cd treebird; ln -s ../mastodont-c . @@ -66,7 +74,7 @@ dep_build: clean: rm -f $(OBJ) src/file-to-c/main.o - rm -f $(PAGES_CMP) + rm -f $(TMPLS_C) rm -f test/unit/*.bin rm -f filec ctemplate rm $(TARGET) || true diff --git a/src/emoji_reaction.c b/src/emoji_reaction.c index 62502ac..d73aecd 100644 --- a/src/emoji_reaction.c +++ b/src/emoji_reaction.c @@ -22,66 +22,6 @@ #include #include "easprintf.h" - -struct construct_emoji_reactions_args -{ - struct mstdnt_emoji_reaction* emojis; - char* id; -}; - -char* construct_emoji_reaction(char* id, struct mstdnt_emoji_reaction* emo, size_t* str_size) -{ - char* ret; - char* emoji = emo->name; - if (emo->url) - { - struct custom_emoji_reaction_template c_data = { - .url = emo->url, - }; - emoji = tmpl_gen_custom_emoji_reaction(&c_data, NULL); - } - - struct emoji_reaction_template data = { - .prefix = config_url_prefix, - .status_id = id, - .custom_emoji = emo->url ? "custom-emoji-container" : NULL, - .emoji = emo->name, - .emoji_display = emoji, - .emoji_active = emo->me ? "active" : NULL, - .emoji_count = emo->count - }; - - ret = tmpl_gen_emoji_reaction(&data, str_size); - if (emoji != emo->name) - free(emoji); - return ret; -} - -static char* construct_emoji_reactions_voidwrap(void* passed, size_t index, size_t* res) -{ - struct construct_emoji_reactions_args* args = passed; - return construct_emoji_reaction(args->id, args->emojis + index, res); -} - -char* construct_emoji_reactions(char* id, struct mstdnt_emoji_reaction* emos, size_t emos_len, size_t* str_size) -{ - size_t elements_size; - struct construct_emoji_reactions_args args = { - .emojis = emos, - .id = id - }; - char* elements = construct_func_strings(construct_emoji_reactions_voidwrap, &args, emos_len, &elements_size); - char* emos_view; - - struct emoji_reactions_template data = { - .emojis = elements - }; - emos_view = tmpl_gen_emoji_reactions(&data, str_size); - // Cleanup - free(elements); - return emos_view; -} - HV* perlify_emoji_reaction(struct mstdnt_emoji_reaction* const emoji) { if (!emoji) return NULL; diff --git a/src/emoji_reaction.h b/src/emoji_reaction.h index bd7f12c..bacaa14 100644 --- a/src/emoji_reaction.h +++ b/src/emoji_reaction.h @@ -21,9 +21,6 @@ #include #include "global_perl.h" -char* construct_emoji_reaction(char* id, struct mstdnt_emoji_reaction* emo, size_t* str_len); -char* construct_emoji_reactions(char* id, struct mstdnt_emoji_reaction* emos, size_t emos_len, size_t* str_len); - // Perl HV* perlify_emoji_reaction(struct mstdnt_emoji_reaction* const emoji); AV* perlify_emoji_reactions(struct mstdnt_emoji_reaction* const emos, size_t len);