Restore filec compilation in makefiles

FossilOrigin-Name: a6559f6e98a925371e2c75272f054c4069c89437b9872c80d641d92b800aac37
This commit is contained in:
nekobit 2022-08-22 12:11:55 +00:00
parent 1b347848e8
commit 50e76ae712
3 changed files with 10 additions and 65 deletions

View File

@ -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

View File

@ -22,66 +22,6 @@
#include <stdlib.h>
#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;

View File

@ -21,9 +21,6 @@
#include <mastodont.h>
#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);