switch to cmake because this is 2019

This commit is contained in:
Tobe O 2019-09-29 00:13:22 -04:00
parent 591b0480b2
commit 4c0b8ecb17
9 changed files with 40 additions and 109 deletions

23
.gitignore vendored
View file

@ -28,4 +28,25 @@ doc/api/
*.obj
.vscode/
.idea/
.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

6
.gitmodules vendored Normal file
View file

@ -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

3
CMakeLists.txt Normal file
View file

@ -0,0 +1,3 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_dart_utils")
find_package(Dart REQUIRED)
add_subdirectory(lib/src)

View file

@ -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="$@" $<

View file

@ -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

1
cmake_dart_utils Submodule

@ -0,0 +1 @@
Subproject commit 315b1741fc59cd18faba32b604edf4eed0bd6e4b

9
configure vendored
View file

@ -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

7
lib/src/CMakeLists.txt Normal file
View file

@ -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}")

1
lib/src/http-parser Submodule

@ -0,0 +1 @@
Subproject commit 28f3c35c215ffbe0241685901338fad484660454