Skip to content

Commit

Permalink
Lwsbuild (#374)
Browse files Browse the repository at this point in the history
* cmake
* inc source
* static build
* clean
  • Loading branch information
joente authored Apr 9, 2024
1 parent 20a6aab commit d877759
Show file tree
Hide file tree
Showing 614 changed files with 221,858 additions and 3,009 deletions.
58 changes: 48 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ dkms.conf
.project
.settings/

# Binaries
Debug/tindb
Release/tindb
MacOS/tindb

# Python
.pyc
__pycache__/
Expand All @@ -73,11 +68,6 @@ __pycache__/
# Visual Studio Code
.vscode/

# Build
Debug/thingsdb
Release/thingsdb
MacOS/thingsdb

# Python building
connectors/python3/build/
connectors/python3/*-info/
Expand All @@ -94,3 +84,51 @@ kube/

# Local files
target/

# CMake
CMakeFiles/
CMakeCache.txt
Makefile
cmake_install.cmake
CPackConfig.cmake
CPackSourceConfig.cmake

# Build
thingsdb

# libwebsockets build
libwebsockets-build/
libwebsockets/.gitignore
libwebsockets/CTestTestfile.cmake
libwebsockets/DartConfiguration.tcl
libwebsockets/LibwebsocketsTargets.cmake
libwebsockets/LwsCheckRequirements.cmake
libwebsockets/lib/CTestTestfile.cmake
libwebsockets/lib/core-net/CTestTestfile.cmake
libwebsockets/lib/core/CTestTestfile.cmake
libwebsockets/lib/event-libs/CTestTestfile.cmake
libwebsockets/lib/event-libs/libuv/CTestTestfile.cmake
libwebsockets/lib/event-libs/poll/CTestTestfile.cmake
libwebsockets/lib/misc/CTestTestfile.cmake
libwebsockets/lib/plat/unix/CTestTestfile.cmake
libwebsockets/lib/roles/CTestTestfile.cmake
libwebsockets/lib/roles/h1/CTestTestfile.cmake
libwebsockets/lib/roles/h2/CTestTestfile.cmake
libwebsockets/lib/roles/http/CTestTestfile.cmake
libwebsockets/lib/roles/listen/CTestTestfile.cmake
libwebsockets/lib/roles/raw-file/CTestTestfile.cmake
libwebsockets/lib/roles/raw-skt/CTestTestfile.cmake
libwebsockets/lib/roles/ws/CTestTestfile.cmake
libwebsockets/lib/secure-streams/CTestTestfile.cmake
libwebsockets/lib/secure-streams/serialized/client/CTestTestfile.cmake
libwebsockets/lib/system/CTestTestfile.cmake
libwebsockets/lib/system/metrics/CTestTestfile.cmake
libwebsockets/lib/system/smd/CTestTestfile.cmake
libwebsockets/lib/tls/CTestTestfile.cmake
libwebsockets/libwebsockets-config-version.cmake
libwebsockets/libwebsockets-config.cmake
libwebsockets/libwebsockets_static.pc
libwebsockets/lws_config.h
libwebsockets/lws_config_private.h
libwebsockets/lwsws/CTestTestfile.cmake
libwebsockets/plugins/CTestTestfile.cmake
267 changes: 267 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
#
# thingsdb - node
#
# Selecting between DEBUG / RELEASE, use -DCMAKE_BUILD_TYPE=Debug or =Release
# debug builds include source level debug info and extra logging

project(thingsdb C)
cmake_minimum_required(VERSION 3.13)
include_directories(inc)


if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

# Less debug info for Release build
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions(NDEBUG)
endif()

# Set C11 standard
set(CMAKE_C_STANDARD 11)

# Optimize flags based on build type
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_C_FLAGS_RELEASE "-O3")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-limit=4000")

# Include directories for MacOS build
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(
AFTER
/opt/homebrew/opt/libuv/include
/opt/homebrew/opt/pcre2/include
/opt/homebrew/opt/yajl/include
/opt/homebrew/opt/curl/include
)
endif()

# Set CMAKE_POLICY_DEFAULT_CMP0077 before add_subdirectory()
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

# Technically LWS_WITH_LIBUV and LWS_WITH_PLUGINS are not required as we make
# a static build (LWS_WITH_SHARED=0).

set(LWS_WITH_LIBUV 1)
set(LWS_WITH_PLUGINS 1)
set(LWS_WITH_TLS 1)

set(LWS_WITHOUT_TESTAPPS 1)
set(LWS_WITHOUT_TEST_SERVER 1)
set(LWS_WITHOUT_TEST_CLIENT 1)
set(LWS_WITHOUT_TEST_PING 1)

set(LWS_WITH_SHARED 0)
set(LWS_WITH_LWSWS 0)
set(LWS_WITH_MINIMAL_EXAMPLES 0)

# Create a build directory for libwebsockets
set(LWS_BUILD_DIR "${CMAKE_BINARY_DIR}/libwebsockets-build")
add_subdirectory(libwebsockets ${LWS_BUILD_DIR})

# Define all the sources
set(SOURCES
main.c
src/ex.c
src/ti.c
src/langdef/compat.c
src/langdef/langdef.c
src/langdef/translate.c
src/cleri/choice.c
src/cleri/cleri.c
src/cleri/dup.c
src/cleri/expecting.c
src/cleri/grammar.c
src/cleri/keyword.c
src/cleri/kwcache.c
src/cleri/list.c
src/cleri/node.c
src/cleri/olist.c
src/cleri/optional.c
src/cleri/parse.c
src/cleri/prio.c
src/cleri/ref.c
src/cleri/regex.c
src/cleri/repeat.c
src/cleri/rule.c
src/cleri/sequence.c
src/cleri/this.c
src/cleri/token.c
src/cleri/tokens.c
src/cleri/version.c
src/ti/access.c
src/ti/api.c
src/ti/archfile.c
src/ti/archive.c
src/ti/args.c
src/ti/async.c
src/ti/auth.c
src/ti/away.c
src/ti/backup.c
src/ti/backups.c
src/ti/build.c
src/ti/cfg.c
src/ti/change.c
src/ti/changes.c
src/ti/clients.c
src/ti/closure.c
src/ti/collection.c
src/ti/collections.c
src/ti/condition.c
src/ti/connect.c
src/ti/counters.c
src/ti/cpkg.c
src/ti/ctask.c
src/ti/datetime.c
src/ti/deep.c
src/ti/do.c
src/ti/dump.c
src/ti/enum.c
src/ti/enums.c
src/ti/evars.c
src/ti/export.c
src/ti/field.c
src/ti/flags.c
src/ti/fmt.c
src/ti/fn.c
src/ti/forloop.c
src/ti/future.c
src/ti/fwd.c
src/ti/gc.c
src/ti/index.c
src/ti/item.c
src/ti/mapping.c
src/ti/member.c
src/ti/method.c
src/ti/module.c
src/ti/modules.c
src/ti/name.c
src/ti/names.c
src/ti/ncache.c
src/ti/nil.c
src/ti/node.c
src/ti/nodes.c
src/ti/opr.c
src/ti/pipe.c
src/ti/pkg.c
src/ti/preopr.c
src/ti/proc.c
src/ti/procedure.c
src/ti/procedures.c
src/ti/prop.c
src/ti/proto.c
src/ti/qbind.c
src/ti/qcache.c
src/ti/query.c
src/ti/quorum.c
src/ti/raw.c
src/ti/regex.c
src/ti/req.c
src/ti/restore.c
src/ti/room.c
src/ti/rooms.c
src/ti/rpkg.c
src/ti/scope.c
src/ti/signals.c
src/ti/spec.c
src/ti/store.c
src/ti/stream.c
src/ti/syncarchive.c
src/ti/sync.c
src/ti/syncer.c
src/ti/syncevents.c
src/ti/syncfull.c
src/ti/task.c
src/ti/tasks.c
src/ti/tcp.c
src/ti/template.c
src/ti/thing.c
src/ti/things.c
src/ti/token.c
src/ti/ttask.c
src/ti/type.c
src/ti/types.c
src/ti/tz.c
src/ti/user.c
src/ti/users.c
src/ti/val.c
src/ti/varr.c
src/ti/vbool.c
src/ti/verror.c
src/ti/version.c
src/ti/vfloat.c
src/ti/vint.c
src/ti/vset.c
src/ti/vtask.c
src/ti/warn.c
src/ti/watch.c
src/ti/web.c
src/ti/wrap.c
src/ti/write.c
src/ti/ws.c
src/ti/mod/expose.c
src/ti/mod/github.c
src/ti/mod/manifest.c
src/ti/mod/work.c
src/ti/store/storeaccess.c
src/ti/store/storecollection.c
src/ti/store/storecollections.c
src/ti/store/storeenums.c
src/ti/store/storegcollect.c
src/ti/store/storemodules.c
src/ti/store/storenames.c
src/ti/store/storeprocedures.c
src/ti/store/storestatus.c
src/ti/store/storetasks.c
src/ti/store/storethings.c
src/ti/store/storetypes.c
src/ti/store/storeusers.c
src/util/argparse.c
src/util/buf.c
src/util/cfgparser.c
src/util/cryptx.c
src/util/fx.c
src/util/guid.c
src/util/imap.c
src/util/iso8601.c
src/util/link.c
src/util/lock.c
src/util/logger.c
src/util/olist.c
src/util/omap.c
src/util/osarch.c
src/util/queue.c
src/util/rbuf.c
src/util/smap.c
src/util/strx.c
src/util/syncpart.c
src/util/util.c
src/util/vec.c
inc/lib/http_parser.c
)

# Create the binary
add_executable(thingsdb ${SOURCES})

# Set include directories for libwebsockets
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwebsockets/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwebsockets/include)

# Link libraries, including the static websockets
target_link_libraries(
thingsdb
PUBLIC
pcre2-8
m
yajl
curl
websockets
uv
)
Binary file removed Debug/.fact.py.swp
Binary file not shown.
1 change: 0 additions & 1 deletion Debug/cleantest

This file was deleted.

1 change: 0 additions & 1 deletion Debug/inc/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions Debug/inc/lib/subdir.mk

This file was deleted.

Loading

0 comments on commit d877759

Please sign in to comment.