From e95a6ae24620da87fd6c30b8cd15959279954741 Mon Sep 17 00:00:00 2001 From: nekobit Date: Fri, 17 Mar 2023 03:13:03 +0000 Subject: [PATCH] Play around with Premake build system should be in a separate branch, but oh well... FossilOrigin-Name: 7fefec89a8a466b83c7ca066106fcce2b18376ec390d6a1a6a1ecc6fd3497744 --- .fossil-settings/ignore-glob | 3 + CMakeLists.txt | 129 --------------------------------- README.md | 24 +++++- cmake/MastodontConfig.cmake.in | 10 --- cmake/mastodont-config.cmake | 21 ------ premake5.lua | 22 ++++++ tests/CMakeLists.txt | 31 -------- 7 files changed, 45 insertions(+), 195 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 cmake/MastodontConfig.cmake.in delete mode 100644 cmake/mastodont-config.cmake create mode 100644 premake5.lua delete mode 100644 tests/CMakeLists.txt diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index 9710c2d..a066f58 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -4,3 +4,6 @@ src/*.o docs/html/ docs/latex/ build/ +obj/ +Mastodont.make +Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 4655617..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,129 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(mastodont - VERSION 0.1 - DESCRIPTION "Library for Mastodon, Pleroma, Wormhole, etc." - LANGUAGES C) - -# BEGIN cmake package config info -include(CMakePackageConfigHelpers) -set(INCLUDE_INSTALL_DIR include/mastodont/) -set(LIB_INSTALL_DIR lib/) -# This feels... UNIX-y -set(LIB_INSTALL_PATH lib/libmastodont.a) -# END cmake package config info - -# Useful -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -find_package(PkgConfig REQUIRED) -find_package(CURL REQUIRED) -# Find the real cJSON -pkg_check_modules(CJSON libcjson) - -# Includes test programs... unit tests -add_subdirectory(tests) - -if (NOT (CJSON_FOUND AND CJSON_VERSION VERSION_GREATER_EQUAL 1.7.14)) - # This was a workaround to some distributions providing an older cJSON - message("CJSON not found or CJSON_VERSION < 1.7.14, falling back to header-only.") - list(APPEND SRC_FILES libs/cjson/cJSON.c) -endif() - - -set(HEADER_FILES - include/mastodont_account.h - include/mastodont_announcement.h - include/mastodont_application.h - include/mastodont_attachment.h - include/mastodont_chats.h - include/mastodont_codes.h - include/mastodont_emoji.h - include/mastodont_error.h - include/mastodont_fetch.h - include/mastodont_generate.h - include/mastodont_history.h - include/mastodont_hooks.h - include/mastodont_instance.h - include/mastodont_json_helper.h - include/mastodont_list.h - include/mastodont_mention.h - include/mastodont_nodeinfo.h - include/mastodont_notif_types.h - include/mastodont_notification.h - include/mastodont_pleroma.h - include/mastodont_query.h - include/mastodont_relationship.h - include/mastodont_request.h - include/mastodont_scrobbles.h - include/mastodont_search.h - include/mastodont_status.h - include/mastodont_tag.h - include/mastodont_timeline.h - include/mastodont_types.h - include/mastodont_uri.h - include/mastodont_visibility_types.h - include/mastodont.h -) - -list(APPEND SRC_FILES - src/account.c - src/application.c - src/attachment.c - src/chats.c - src/emoji.c - src/error.c - src/fetch.c - src/history.c - src/hooks.c - src/instance.c - src/json_helper.c - src/list.c - src/mastodont.c - src/nodeinfo.c - src/notification.c - src/pleroma.c - src/query.c - src/relationship.c - src/request.c - src/scrobbles.c - src/search.c - src/status.c - src/tag.c - src/timeline.c - src/uri.c) - -add_library(mastodont STATIC ${HEADER_FILES}) -target_sources(mastodont PRIVATE ${SRC_FILES}) - -target_compile_options(mastodont PUBLIC - -Wall -Wextra -std=c99 - -Wshadow -Wcast-align -Wstrict-prototypes -) - -target_link_options(mastodont PUBLIC - ${CURL_LDFLAGS_OTHER} -) - -target_include_directories(mastodont PUBLIC - include/ - ${CURL_INCLUDE_DIRS} - PRIVATE - libs/ -) - -# Install -if(CJSON_FOUND AND CJSON_VERSION VERSION_GREATER_EQUAL 1.7.14) - install(FILES ${HEADER_FILES} DESTINATION - include/mastodont/) - install(TARGETS mastodont - LIBRARY DESTINATION lib) - - configure_package_config_file(cmake/MastodontConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/mastodont-config.cmake - INSTALL_DESTINATION lib/cmake/mastodont - PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR LIB_INSTALL_PATH) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mastodont-config.cmake DESTINATION lib/cmake/mastodont) -else() - message("Since CJSON wasn't found or your distribution doesn't provide correct version, you can still use cmake/mastodont-config.cmake and check for it in your package. You _probably_ don't want this") -endif() diff --git a/README.md b/README.md index d7b86b3..ef91e16 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,27 @@ -# Mastodont-c +# Mastodont-c + + - *NOTE:* API is not stable yet. Please be patient. Mastodont-c is a C library to access the Mastodon API and it's variants (Pleroma, Akkoma, Soapbox). It was written in C due to it's portability. It's designed to be used in -Treebird, but it can be used in other programs as well. +Treebird, but it can be used in other programs as well. In fact, there are +tests specifically designed to showcase it's power -# Documentation +# Build system -Documentation is essentially non-existant, but this will improve over time. \ No newline at end of file +Mastodont-c uses a pretty quirky build system called Premake5 mainly just + to make me happy and for portability. I plan on writing some neat little + Java bindings for this library someday to see if I can expand it onto other + platforms :-) + +#### On UNIX-like systems... + + $ premake5 gmake + +(Silly systems can use `--os bsd` to force it) + +# Documentation + +Documentation is essentially non-existant, but this will improve over time. diff --git a/cmake/MastodontConfig.cmake.in b/cmake/MastodontConfig.cmake.in deleted file mode 100644 index c249d02..0000000 --- a/cmake/MastodontConfig.cmake.in +++ /dev/null @@ -1,10 +0,0 @@ -set(MASTODONT_VERSION 0.0.1) - -@PACKAGE_INIT@ - -set_and_check(MASTODONT_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") -set_and_check(MASTODONT_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") -set_and_check(MASTODONT_LIBRARIES "@PACKAGE_LIB_INSTALL_PATH@") -#set_and_check(MASTODONT_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@") - -check_required_components(mastodont) diff --git a/cmake/mastodont-config.cmake b/cmake/mastodont-config.cmake deleted file mode 100644 index 5600324..0000000 --- a/cmake/mastodont-config.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Get CFLAGS -set(MASTODONT_FOUND) -set(MASTODONT_VERSION 0.1) - -# Get parent directory of this config file -find_package(CURL REQUIRED) -find_package(PkgConfig REQUIRED) -# TODO account for built-in cjson lib -pkg_check_modules(MSTDNT_CJSON libcjson) - -set(MASTODONT_INCLUDE_DIRS - ../include - ../libs -) - -set(MASTODONT_LIBRARIES - mastodont - ${MSTDNT_CJSON_LIBRARIES} - ${CURL_LIBRARIES} -) - diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..a5749a3 --- /dev/null +++ b/premake5.lua @@ -0,0 +1,22 @@ +workspace("Mastodont"); +configurations { "Debug", "Release" }; + +-- BEGIN Mastodont project +project("Mastodont"); +kind("StaticLib"); +language("C"); +files { "include/*.h", "src/*.c" }; +includedirs { "include/" }; + +filter { "system:linux or bsd or macosx", "action:gmake" } + linkoptions { "`curl-config --libs`" } + linkoptions { "`pkg-config --libs cjson`" } + +filter { "configurations:Debug" }; + defines { "DEBUG" }; + symbols("On"); + +filter { "configurations:Release" }; + defines { "NDEBUG" }; + optimize("On"); +-- END Mastodont-c diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 4c14e1b..0000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -include(../cmake/mastodont-config.cmake) - -add_executable(get_feed get_feed.c) -target_compile_options(get_feed PUBLIC -std=c99 -Wall) -target_link_libraries(get_feed PUBLIC - ${MASTODONT_LIBRARIES} -) -target_include_directories(get_feed PUBLIC - ${MASTODONT_INCLUDE_DIRS} -) - - -# GUI demo -pkg_check_modules(EFL_ECORE efl-core) -if (EFL_ECORE_FOUND) - # EFL is clearly installed... - pkg_check_modules(EFL_ELEMENTARY elementary) - - add_executable(get_feed_efl get_feed_efl.c) - target_compile_options(get_feed_efl PUBLIC -std=c99 -Wall) - target_link_libraries(get_feed_efl PUBLIC - ${MASTODONT_LIBRARIES} - ${EFL_ECORE_LIBRARIES} - ${EFL_ELEMENTARY_LIBRARIES} - ) - target_include_directories(get_feed_efl PUBLIC - ${MASTODONT_INCLUDE_DIRS} - ${EFL_ECORE_INCLUDE_DIRS} - ${EFL_ELEMENTARY_INCLUDE_DIRS} - ) -endif(EFL_ECORE_FOUND)