From 4c0b8ecb17dce8ffa417393f7a7b63e5c1378a67 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 29 Sep 2019 00:13:22 -0400 Subject: [PATCH] switch to cmake because this is 2019 --- .gitignore | 23 +++++++++++++++++- .gitmodules | 6 +++++ CMakeLists.txt | 3 +++ Makefile | 44 --------------------------------- Makefile.old | 55 ------------------------------------------ cmake_dart_utils | 1 + configure | 9 ------- lib/src/CMakeLists.txt | 7 ++++++ lib/src/http-parser | 1 + 9 files changed, 40 insertions(+), 109 deletions(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 Makefile.old create mode 160000 cmake_dart_utils delete mode 100755 configure create mode 100644 lib/src/CMakeLists.txt create mode 160000 lib/src/http-parser diff --git a/.gitignore b/.gitignore index c40e7bad..f7a3b87c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,25 @@ doc/api/ *.obj .vscode/ -.idea/ \ No newline at end of file +.idea/ +# Created by https://www.gitignore.io/api/cmake +# Edit at https://www.gitignore.io/?templates=cmake + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +# End of https://www.gitignore.io/api/cmake diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..6b6d60b5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "cmake_dart_utils"] + path = cmake_dart_utils + url = https://github.com/thosakwe/cmake_dart_utils.git +[submodule "lib/src/http-parser"] + path = lib/src/http-parser + url = https://github.com/nodejs/http-parser.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..49587b28 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_dart_utils") +find_package(Dart REQUIRED) +add_subdirectory(lib/src) diff --git a/Makefile b/Makefile deleted file mode 100644 index 74ecabdc..00000000 --- a/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -CXXFLAGS := $(CXXFLAGS) --std=c++14 -fPIC -DDART_SHARED_LIB=1 -I $(DART_SDK)/include \ - -I .dart_tool -objects := lib/src/angel_wings.o lib/src/wings_socket.o \ -lib/src/bind.o lib/src/util.o lib/src/http.o \ -.dart_tool/http-parser/http_parser.o - -.PHONY: distclean clean - -distclean: clean - rm -rf .dart_tool/http-parser - -clean: - find . -type f -name '*.o' -delete - find . -type f -name '*.obj' -delete - find . -type f -name '*.so' -delete - find . -type f -name '*.dylib' -delete - find . -type f -name '*.dill' -delete - -%-run: % example/main.dill - dart example/main.dill - -mac: libangel_wings.dylib - -linux: lib/src/libangel_wings.so - -libangel_wings.dylib: lib/src/libangel_wings.dylib - cp $< $@ - -lib/src/libangel_wings.dylib: $(objects) - -%.dylib: $(objects) - $(CXX) -shared -Wl,-undefined -Wl,dynamic_lookup -o $@ $^ - -%.so: $(objects) - $(CXX) -shared -o $@ $^ - -%.o: %.cc lib/src/angel_wings.h - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o: %.cc lib/src/angel_wings.h %.h - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.dill: %.dart - dart --snapshot="$@" $< \ No newline at end of file diff --git a/Makefile.old b/Makefile.old deleted file mode 100644 index 1a49f460..00000000 --- a/Makefile.old +++ /dev/null @@ -1,55 +0,0 @@ -CXX=clang -HTTP_PARSER=.dart_tool/build_native/third_party/angel_wings.http_parser -CXX_INCLUDES=-I$(HTTP_PARSER) -I$(DART_SDK)/include - -.PHONY: clean debug macos all - -all: - printf 'Available targets:\n'\ - ' * `debug` - Builds a debug library on MacOS\n'\ - ' * `example` - Runs example/main.dart in LLDB on MacOS\n'\ - ' * `macos` - Builds a release-mode library on MacOS\n' - -clean: - find lib -name "*.a" -delete - find lib -name "*.o" -delete - find lib -name "*.dylib" -delete - -debug: - $(MAKE) lib/src/libwings.dylib CXXFLAGS="-g -DDEBUG=1" - -macos: - $(MAKE) lib/src/libwings.dylib - -example: debug - lldb -o "target create dart" \ - -o "process launch --stop-at-entry example/main.dart" \ - -o "process handle SIGINT -p true" \ - -o "continue" \ - -lib/src/bind_socket.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/bind_socket.o lib/src/bind_socket.cc - -lib/src/http_listener.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/http_listener.o lib/src/http_listener.cc - -lib/src/http_parser.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -c -o lib/src/http_parser.o $(HTTP_PARSER)/http_parser.c - -lib/src/send.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/send.o lib/src/send.cc - -lib/src/util.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/util.o lib/src/util.cc - -lib/src/wings.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/wings.o lib/src/wings.cc - -lib/src/worker_thread.o: - $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -std=c++11 -c -o lib/src/worker_thread.o lib/src/worker_thread.cc - -lib/src/libwings.dylib: lib/src/bind_socket.o lib/src/http_listener.o lib/src/http_parser.o lib/src/send.o lib/src/util.o lib/src/wings.o lib/src/worker_thread.o - $(CXX) $(CXXFLAGS) -shared -o lib/src/libwings.dylib -undefined dynamic_lookup -DDART_SHARED_LIB -Wl -fPIC -m64 \ - lib/src/bind_socket.o lib/src/http_listener.o \ - lib/src/http_parser.o lib/src/send.o lib/src/util.o \ - lib/src/wings.o lib/src/worker_thread.o \ No newline at end of file diff --git a/cmake_dart_utils b/cmake_dart_utils new file mode 160000 index 00000000..315b1741 --- /dev/null +++ b/cmake_dart_utils @@ -0,0 +1 @@ +Subproject commit 315b1741fc59cd18faba32b604edf4eed0bd6e4b diff --git a/configure b/configure deleted file mode 100755 index 2e5d957b..00000000 --- a/configure +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -HTTP_PARSER_DIR=.dart_tool/http-parser - -if [ ! -d "$HTTP_PARSER_DIR" ] -then - git clone --depth 1 https://github.com/nodejs/http-parser.git "$HTTP_PARSER_DIR" - exit $? -fi - diff --git a/lib/src/CMakeLists.txt b/lib/src/CMakeLists.txt new file mode 100644 index 00000000..a9ea0ce7 --- /dev/null +++ b/lib/src/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories(http-parser) +add_dart_native_extension(angel_wings + http-parser/http_parser.c + angel_wings.h angel_wings.cc + bind.cc http.cc + util.cc) +install(TARGETS angel_wings LIBRARY DESTINATION "${CMAKE_CURRENT_LIST_DIR}") diff --git a/lib/src/http-parser b/lib/src/http-parser new file mode 160000 index 00000000..28f3c35c --- /dev/null +++ b/lib/src/http-parser @@ -0,0 +1 @@ +Subproject commit 28f3c35c215ffbe0241685901338fad484660454