CMP functions, some CMake that needs to be done
FossilOrigin-Name: 7d1d963fb8812052d9a10db0deb9b4d301d8666d79aba2dbbc3308ec012bf65c
This commit is contained in:
parent
37ec828fa2
commit
5ffd8efe04
5 changed files with 85 additions and 25 deletions
|
@ -20,7 +20,6 @@ else()
|
|||
endif()
|
||||
|
||||
|
||||
|
||||
add_executable(treebird ${SRC_FILES})
|
||||
|
||||
# Useful
|
||||
|
@ -29,11 +28,23 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
include(cmake/os_hacks.cmake)
|
||||
# List helper
|
||||
include(cmake/append_and_def.cmake)
|
||||
#find_package(PkgConfig REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# Link stuff
|
||||
find_package(CURL REQUIRED) # Required for mastodont-c (hack)
|
||||
|
||||
# For some reason the arguments from Perl are stored as a full string
|
||||
# Blame CMake(?), not me...
|
||||
find_package(PerlLibs REQUIRED)
|
||||
|
||||
# It returns in CMake terms, "the command", but we want ("the" "command").
|
||||
# `target_compile_options' wants this.
|
||||
# I'm still learning CMake, don't know why it stores lists like this, but it's
|
||||
# whatever
|
||||
string(REPLACE " " ";" _PERL_EXTRA_C_FLAGS ${PERL_EXTRA_C_FLAGS})
|
||||
# We could also use this somehow:
|
||||
# separate_arguments(_PERL_EXTRA_C_FLAGS UNIX_COMMAND
|
||||
# "${PERL_EXTRA_C_FLAGS}")
|
||||
|
||||
# Useful for GNU Emacs or VS Code
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
|
@ -41,12 +52,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
target_compile_options(treebird PUBLIC
|
||||
-Wall -Wextra -std=c99
|
||||
-Wshadow -Wcast-align -Wstrict-prototypes
|
||||
${PERL_EXTRA_C_FLAGS}
|
||||
${_PERL_EXTRA_C_FLAGS}
|
||||
$<$<CONFIG:DEBUG>:-Og>
|
||||
$<$<CONFIG:DEBUG>:-g>
|
||||
$<$<CONFIG:RELEASE>:-O2>
|
||||
)
|
||||
|
||||
|
||||
|
||||
# hack is on me
|
||||
target_link_options(treebird PUBLIC
|
||||
-lmastodont
|
||||
|
@ -71,7 +84,7 @@ set(SRC_FILES
|
|||
)
|
||||
|
||||
# Pages
|
||||
append_and_def(SRC_FILES
|
||||
append_and_def(treebird PUBLIC SRC_FILES
|
||||
src/about.c
|
||||
src/account.c
|
||||
src/applications.c
|
||||
|
@ -101,19 +114,18 @@ append_and_def(SRC_FILES
|
|||
src/status.c
|
||||
src/timeline.c
|
||||
)
|
||||
message("${COMPILE_DEFINITIONS}")
|
||||
|
||||
target_sources(treebird PUBLIC ${SRC_FILES})
|
||||
|
||||
message(${MASTODONT_INCLUDE_DIRS})
|
||||
|
||||
target_include_directories(treebird PUBLIC
|
||||
${PERL_INCLUDE_PATH}
|
||||
${PERL_INCLUDE_DIRS}
|
||||
${MASTODONT_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS})
|
||||
|
||||
# Build! Note the mastodont hack, this _should_ change soon.
|
||||
target_link_libraries(treebird PUBLIC
|
||||
${PERL_LIBRARY}
|
||||
${PERL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
${MASTODONT_LIBRARIES}
|
||||
mastodont-c/libmastodont.a)
|
||||
|
|
4
Makefile
4
Makefile
|
@ -34,7 +34,6 @@ CFLAGS += -DDEBUG
|
|||
endif
|
||||
|
||||
all:
|
||||
$(MAKE) dep_build
|
||||
$(MAKE) filec
|
||||
$(MAKE) make_tmpls
|
||||
$(MAKE) $(TARGET)
|
||||
|
@ -70,9 +69,6 @@ test: all $(UNIT_TESTS)
|
|||
@echo " ... Tests ready"
|
||||
@./test/test.pl
|
||||
|
||||
dep_build:
|
||||
make -C $(MASTODONT_DIR)
|
||||
|
||||
%.o: %.c %.h $(PAGES)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -2,8 +2,20 @@
|
|||
# the code doesn't compile correctly, for which you can do an `#ifdef' with the
|
||||
# C Preprocessor
|
||||
|
||||
function(append_and_def NAME)
|
||||
foreach(X IN ITEMS ARGV)
|
||||
list(APPEND NAME X)
|
||||
macro(append_and_def TARGET SCOPE NAME ...)
|
||||
|
||||
foreach(X IN ITEMS ${ARGN})
|
||||
# Convert to uppercase for the definition
|
||||
get_filename_component(TEMP ${X} NAME_WE)
|
||||
string(TOUPPER _TEMP ${TEMP})
|
||||
|
||||
get_target_property(
|
||||
targ_comp
|
||||
${TARGET}
|
||||
INTERFACE_COMPILE_DEFINITIONS)
|
||||
message(${_TEMP})
|
||||
target_compile_definitions(${TARGET} ${SCOPE}
|
||||
${targ_comp} -DCMP_ENABLE_${_TEMP})
|
||||
list(APPEND X ${_TEMP})
|
||||
endforeach()
|
||||
endfunction()
|
||||
endmacro()
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#ifndef GLOBAL_PERL_H
|
||||
#define GLOBAL_PERL_H
|
||||
|
||||
// Hack on my system... if this breaks anything, plz dig deeper
|
||||
#include <EXTERN.h>
|
||||
#include <perl.h>
|
||||
#include "memory.h"
|
||||
|
|
56
src/main.c
56
src/main.c
|
@ -52,12 +52,24 @@ static int exit_treebird(PATH_ARGS)
|
|||
* Path handling *
|
||||
******************/
|
||||
static struct path_info paths[] = {
|
||||
#ifdef CMP_ENABLE_CONFIG
|
||||
{ "/config/general", content_config_general },
|
||||
{ "/config/appearance", content_config_appearance },
|
||||
/* { "/config/account", content_config_account }, */
|
||||
//{ "/config/account", content_config_account },
|
||||
{ "/config", content_config },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_ATTACHMENTS
|
||||
// API
|
||||
{ "/treebird_api/v1/attachment", api_attachment_create },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_LOGIN
|
||||
{ "/login/oauth", content_login_oauth },
|
||||
{ "/login", content_login },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_ACCOUNT
|
||||
{ "/user/:/action/:", content_account_action },
|
||||
{ "/user/:", content_account_statuses },
|
||||
{ "/@:/scrobbles", content_account_scrobbles },
|
||||
|
@ -67,6 +79,12 @@ static struct path_info paths[] = {
|
|||
{ "/@:/followers", content_account_followers },
|
||||
{ "/@:/statuses", content_account_statuses },
|
||||
{ "/@:", content_account_statuses },
|
||||
{ "/favourites", content_account_favourites },
|
||||
{ "/blocked", content_account_blocked },
|
||||
{ "/muted", content_account_muted },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_STATUS
|
||||
{ "/status/:/react/:", content_status_react },
|
||||
{ "/status/:/react", status_emoji },
|
||||
{ "/status/create", content_status_create },
|
||||
|
@ -76,44 +94,64 @@ static struct path_info paths[] = {
|
|||
{ "/status/:/boosted_by", status_view_reblogs },
|
||||
{ "/status/:/reblogged_by", status_view_reblogs },
|
||||
{ "/status/:", status_view },
|
||||
#if 0
|
||||
{ "/notice/:", notice_redirect },
|
||||
{ "/treebird_api/v1/interact", api_status_interact },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_ABOUT
|
||||
{ "/about/license", content_about_license },
|
||||
{ "/about", content_about },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_SEARCH
|
||||
{ "/search/statuses", content_search_statuses },
|
||||
{ "/search/accounts", content_search_accounts },
|
||||
{ "/search/hashtags", content_search_hashtags },
|
||||
{ "/search", content_search_all },
|
||||
#endif
|
||||
|
||||
#if defined(CMP_ENABLE_EMOJI) && defined(CMP_ENABLE_EMOJI_REACTION)
|
||||
{ "/emoji_picker", content_emoji_picker },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_LISTS
|
||||
{ "/lists/edit/:", list_edit },
|
||||
{ "/lists/for/:", content_tl_list },
|
||||
{ "/lists", content_lists },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_TIMELINE
|
||||
{ "/local", content_tl_local },
|
||||
{ "/federated", content_tl_federated },
|
||||
{ "/direct", content_tl_direct },
|
||||
{ "/bookmarks", content_account_bookmarks },
|
||||
{ "/favourites", content_account_favourites },
|
||||
{ "/blocked", content_account_blocked },
|
||||
{ "/muted", content_account_muted },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_NOTIFICATIONS
|
||||
{ "/notifications_compact", content_notifications_compact },
|
||||
{ "/notification/:/read", content_notifications_read },
|
||||
{ "/notification/:/delete", content_notifications_clear },
|
||||
{ "/notifications/read", content_notifications_read },
|
||||
{ "/notifications/clear", content_notifications_clear },
|
||||
{ "/notifications", content_notifications },
|
||||
{ "/treebird_api/v1/notifications", api_notifications },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_HASHTAG
|
||||
{ "/tag/:", content_tl_tag },
|
||||
#endif
|
||||
|
||||
#ifdef CMP_ENABLE_CONVERSATIONS
|
||||
{ "/chats/:", content_chat_view },
|
||||
{ "/chats", content_chats },
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
{ "/quit", exit_treebird },
|
||||
{ "/exit", exit_treebird },
|
||||
#endif
|
||||
// Debug, but cool to see
|
||||
{ "/memory_stats", content_memory_stats },
|
||||
// API
|
||||
{ "/treebird_api/v1/notifications", api_notifications },
|
||||
{ "/treebird_api/v1/interact", api_status_interact },
|
||||
{ "/treebird_api/v1/attachment", api_attachment_create },
|
||||
};
|
||||
|
||||
static int application(mastodont_t* api, REQUEST_T req)
|
||||
|
|
Loading…
Reference in a new issue