diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py new file mode 100644 index 000000000..18a613bab --- /dev/null +++ b/.ycm_extra_conf.py @@ -0,0 +1,13 @@ +from os.path import dirname, realpath, join, exists + +_PROJ_ROOT = dirname(realpath(__file__)) + + +def Settings(**kwargs): + venv_interpreter = join(_PROJ_ROOT, "venv", "bin", "python") + + if not exists(venv_interpreter): + parent_root = dirname(dirname(_PROJ_ROOT)) + venv_interpreter = join(parent_root, "venv", "bin", "python") + + return {"interpreter_path": venv_interpreter} diff --git a/CMakeLists.txt b/CMakeLists.txt index a4994be3d..137f8d295 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Library funcs if (FAABRIC_STATIC_LIBS) @@ -34,8 +35,8 @@ endif () # https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/CMakeLists.txt include(FindProtobuf) set(protobuf_MODULE_COMPATIBLE TRUE) - find_package(Protobuf REQUIRED) + message(STATUS "Using protobuf \ ${PROTOBUF_LIBRARY} \ ${PROTOBUF_PROTOC_LIBRARY} \ diff --git a/src/endpoint/CMakeLists.txt b/src/endpoint/CMakeLists.txt index 66880ca48..592f1fc6d 100644 --- a/src/endpoint/CMakeLists.txt +++ b/src/endpoint/CMakeLists.txt @@ -11,4 +11,4 @@ set(LIB_FILES faabric_private_lib(endpoint "${LIB_FILES}") -target_link_libraries(endpoint pistache pthread) +target_link_libraries(endpoint pistache pthread util) diff --git a/src/endpoint/Endpoint.cpp b/src/endpoint/Endpoint.cpp index e042b9d47..df7810e17 100644 --- a/src/endpoint/Endpoint.cpp +++ b/src/endpoint/Endpoint.cpp @@ -55,4 +55,4 @@ namespace faabric::endpoint { httpEndpoint.shutdown(); } -} \ No newline at end of file +} diff --git a/tasks/__init__.py b/tasks/__init__.py index 2302c521f..18fbe09b4 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -2,9 +2,11 @@ from . import build from . import container +from . import dev ns = Collection( build, container, + dev, ) diff --git a/tasks/dev.py b/tasks/dev.py new file mode 100644 index 000000000..650cb05c5 --- /dev/null +++ b/tasks/dev.py @@ -0,0 +1,59 @@ +from os import makedirs +from shutil import rmtree +from os.path import join, exists +from subprocess import run + +from invoke import task + +from tasks.util.env import PROJ_ROOT + + +_BUILD_DIR = join(PROJ_ROOT, "build", "cmake") +_BIN_DIR = join(_BUILD_DIR, "bin") + + +@task +def cmake(ctx, clean=False): + if clean and exists(_BUILD_DIR): + rmtree(_BUILD_DIR) + + if not exists(_BUILD_DIR): + makedirs(_BUILD_DIR) + + cmd = [ + "cmake", + "-GNinja", + "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_CXX_COMPILER=/usr/bin/clang++-10", + "-DCMAKE_C_COMPILER=/usr/bin/clang-10", + "../..", + ] + + run(" ".join(cmd), shell=True, cwd=_BUILD_DIR) + + +@task +def cc(ctx, target): + run("cmake --build . --target {}".format(target), cwd=_BUILD_DIR, shell=True) + + +@task +def r(ctx, target): + run( + "./{}".format(target), + cwd=_BIN_DIR, + shell=True, + ) + + +@task +def test(ctx, name, debug=False): + test_exe = join(_BUILD_DIR, "bin", "tests") + + cmd = [ + test_exe, + "-r console", + name, + ] + + run(" ".join(cmd), shell=True, cwd=PROJ_ROOT)