Skip to content

Commit

Permalink
ReStructure dirs for -> frontend < - > backend
Browse files Browse the repository at this point in the history
Fix some bugs
  • Loading branch information
badcast committed Dec 21, 2023
1 parent 9c477b2 commit 3d8eaf8
Show file tree
Hide file tree
Showing 51 changed files with 80 additions and 75 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
server-php/users/*
server-php/messages/*
server-backend/php/users
server-backend/php/messages
.vscode
CMakeLists.txt.user
CMakeLists.txt.user*
72 changes: 1 addition & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,3 @@
cmake_minimum_required(VERSION 3.10)

# READ VERSION
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DRAGON_TEA_VERSION)

string(STRIP "${DRAGON_TEA_VERSION}" DRAGON_TEA_VERSION)

project(
DragonTea
VERSION ${DRAGON_TEA_VERSION}
LANGUAGES C)

find_package(PkgConfig REQUIRED)
pkg_check_modules(gtk3ui REQUIRED gtk+-3.0)
pkg_check_modules(libcurl REQUIRED libcurl)
pkg_check_modules(json REQUIRED json-c)
pkg_check_modules(gthread REQUIRED gthread-2.0)

file(GLOB_RECURSE DRAGONTEA_SOURCES "${CMAKE_SOURCE_DIR}/src/*.c"
"${CMAKE_SOURCE_DIR}/include/*.h")

add_executable(dragontea)

# COMPILE BUILTIN SERVERS
set(BUILTIN_TEMPLATE_FILE "${CMAKE_BINARY_DIR}/builtin_template.c")

file(GLOB BUILTIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/builtin/*.url")
list(LENGTH BUILTIN_FILES BF_LENGTH)

if(NOT EXISTS "${BUILTIN_TEMPLATE_FILE}")
if(BF_LENGTH GREATER 0)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/builtin/builtin_template.c"
DESTINATION ${CMAKE_BINARY_DIR})

foreach(F ${BUILTIN_FILES})
file(READ ${F} F_CONTENT)
string(STRIP ${F_CONTENT} F_CONTENT)
file(APPEND ${BUILTIN_TEMPLATE_FILE} "\"${F_CONTENT}\",\n")
endforeach()
file(APPEND ${BUILTIN_TEMPLATE_FILE} "};")
endif()
endif()

if(EXISTS "${BUILTIN_TEMPLATE_FILE}")
list(APPEND DRAGONTEA_SOURCES ${BUILTIN_TEMPLATE_FILE})
target_compile_definitions(dragontea PUBLIC BUILTIN_SERVERS=ON
BUILTIN_SERVERS_N=${BF_LENGTH})
endif()

target_sources(dragontea PUBLIC ${DRAGONTEA_SOURCES})

target_include_directories(
dragontea
PUBLIC "${CMAKE_SOURCE_DIR}/include/" ${gtk3ui_INCLUDE_DIRS}
${gthread_INCLUDE_DIRS} ${libcurl_INCLUDE_DIRS} ${json_INCLUDE_DIRS})

target_link_libraries(dragontea ${gtk3ui_LIBRARIES} ${libcurl_LIBRARIES}
${json_LIBRARIES} ${gthread_LIBRARIES})

target_compile_definitions(dragontea
PUBLIC DRAGON_TEA_VERSION="${DRAGON_TEA_VERSION}")

if(UNIX OR LINUX)
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale")
target_compile_definitions(dragontea
PUBLIC DRAGON_TEA_LOCALE_DIR="${LOCALE_DIR}")

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/localization/locale"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share")

install(FILES "${CMAKE_BINARY_DIR}/dragontea"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/")
endif()
add_subdirectory(client-frontend/dragon-tea)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Dragon Tea. Free Messenger
## How to customization server?
-----

```Server (backend):``` The file located at [server_config](./server-php/server_config.php) contains the server configuration settings.
```Server (backend):``` The file located at [server_config](./server-backend/php/server_config.php) contains the server configuration settings.

```Client (frontend):``` The file located at ```$HOME/.config/DragonTea/tea-config.json``` contains the client configuration settings

Expand Down
74 changes: 74 additions & 0 deletions client-frontend/dragon-tea/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# READ VERSION
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DRAGON_TEA_VERSION)

string(STRIP "${DRAGON_TEA_VERSION}" DRAGON_TEA_VERSION)

project(
DragonTea
VERSION ${DRAGON_TEA_VERSION}
LANGUAGES C)

find_package(PkgConfig REQUIRED)
pkg_check_modules(gtk3ui REQUIRED gtk+-3.0)
pkg_check_modules(libcurl REQUIRED libcurl)
pkg_check_modules(json REQUIRED json-c)
pkg_check_modules(gthread REQUIRED gthread-2.0)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

file(GLOB_RECURSE DRAGONTEA_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

add_executable(dragontea)

# COMPILE BUILTIN SERVERS
set(BUILTIN_TEMPLATE_FILE "${CMAKE_BINARY_DIR}/builtin_template.c")

file(GLOB BUILTIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/builtin/*.url")
list(LENGTH BUILTIN_FILES BF_LENGTH)

if(NOT EXISTS "${BUILTIN_TEMPLATE_FILE}")
if(BF_LENGTH GREATER 0)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/builtin/builtin_template.c"
DESTINATION ${CMAKE_BINARY_DIR})

foreach(F ${BUILTIN_FILES})
file(READ ${F} F_CONTENT)
string(STRIP ${F_CONTENT} F_CONTENT)
file(APPEND ${BUILTIN_TEMPLATE_FILE} "\"${F_CONTENT}\",\n")
endforeach()
file(APPEND ${BUILTIN_TEMPLATE_FILE} "};")
endif()
endif()

if(EXISTS "${BUILTIN_TEMPLATE_FILE}")
list(APPEND DRAGONTEA_SOURCES ${BUILTIN_TEMPLATE_FILE})
target_compile_definitions(dragontea PUBLIC BUILTIN_SERVERS=ON
BUILTIN_SERVERS_N=${BF_LENGTH})
endif()

target_sources(dragontea PUBLIC ${DRAGONTEA_SOURCES})

target_include_directories(
dragontea
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/" ${gtk3ui_INCLUDE_DIRS}
${gthread_INCLUDE_DIRS} ${libcurl_INCLUDE_DIRS} ${json_INCLUDE_DIRS})

target_link_libraries(dragontea ${gtk3ui_LIBRARIES} ${libcurl_LIBRARIES}
${json_LIBRARIES} ${gthread_LIBRARIES})

target_compile_definitions(dragontea
PUBLIC DRAGON_TEA_VERSION="${DRAGON_TEA_VERSION}")

if(UNIX OR LINUX)
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale")
target_compile_definitions(dragontea
PUBLIC DRAGON_TEA_LOCALE_DIR="${LOCALE_DIR}")

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/localization/locale"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share")

install(FILES "${CMAKE_BINARY_DIR}/dragontea"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/")
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion run-server-php.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/sh

php -S localhost:8000 -t ./server-backend/php
xdg-open localhost:8000/api/auth.php
php -S localhost:8000 -t ./server-php
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3d8eaf8

Please sign in to comment.