Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared object build #36

Merged
merged 13 commits into from
Dec 8, 2020
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [master]
pull_request:
branches: [master]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
tests:
Expand All @@ -15,7 +16,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric-cli:0.0.13
image: faasm/faabric-cli:0.0.14
defaults:
run:
working-directory: /code/faabric
Expand Down
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.13.0)
project(faabric)

option(FAABRIC_WASM_BUILD "Build Faabric wasm library" OFF)
option(FAABRIC_STATIC_LIBS "Statically link Faabric libs" ON)
option(FAABRIC_BUILD_TESTS "Build Faabric tests" ON)

# Top-level CMake config
Expand All @@ -18,20 +17,20 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(THIRD_PARTY_INSTALL_DIR ${CMAKE_BINARY_DIR}/third-party)

# Library funcs
if (FAABRIC_STATIC_LIBS)
if (BUILD_SHARED_LIBS)
function(faabric_public_lib lib_name lib_deps)
add_library(${lib_name} STATIC ${lib_deps})
add_library(${lib_name} SHARED ${lib_deps})
endfunction()
function(faabric_private_lib lib_name lib_deps)
add_library(${lib_name} STATIC ${lib_deps})
target_compile_options(${lib_name} PRIVATE "-fPIC")
endfunction()
else ()
function(faabric_public_lib lib_name lib_deps)
add_library(${lib_name} SHARED ${lib_deps})
add_library(${lib_name} STATIC ${lib_deps})
endfunction()
function(faabric_private_lib lib_name lib_deps)
add_library(${lib_name} STATIC ${lib_deps})
target_compile_options(${lib_name} PRIVATE "-fPIC")
endfunction()
endif ()

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.13
0.0.14
2 changes: 1 addition & 1 deletion docker/faabric.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM faasm/grpc-root:0.0.12
FROM faasm/grpc-root:0.0.14
ARG FAABRIC_VERSION

# Note - the version of grpc-root here can be quite behind as it's rebuilt very
Expand Down
14 changes: 13 additions & 1 deletion docker/grpc-root.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,22 @@ RUN wget -q -O \
RUN sh cmake-linux.sh -- --skip-license --prefix=/usr/local

# gRPC, protobuf etc.
# Static libs
RUN git clone --recurse-submodules -b v1.31.0 https://github.com/grpc/grpc
WORKDIR /setup/grpc/cmake/build
WORKDIR /setup/grpc/cmake/build-static
RUN cmake -GNinja \
-DgRPC_INSTALL=ON \
-DBUILD_SHARED_LIBS=OFF \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
../..
RUN ninja install

# Shared libs
WORKDIR /setup/grpc/cmake/build-shared
RUN cmake -GNinja \
-DgRPC_INSTALL=ON \
-DBUILD_SHARED_LIBS=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
../..
Expand Down
6 changes: 3 additions & 3 deletions src/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ set(LIB_FILES
${OUTPUT_FILES}
)

if(FAABRIC_STATIC_LIBS)
faabric_private_lib(proto "${LIB_FILES}")
else()
if(BUILD_SHARED_LIBS)
faabric_public_lib(proto "${LIB_FILES}")
else()
faabric_private_lib(proto "${LIB_FILES}")
endif()

add_dependencies(proto spdlog_ext)
Expand Down
3 changes: 2 additions & 1 deletion tasks/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@task
def cmake(ctx, clean=False):
def cmake(ctx, clean=False, shared=False):
"""
Configures the build
"""
Expand All @@ -30,6 +30,7 @@ def cmake(ctx, clean=False):
"-GNinja",
"-DCMAKE_INSTALL_PREFIX={}".format(_INSTALL_PREFIX),
"-DCMAKE_BUILD_TYPE=Debug",
"-DBUILD_SHARED_LIBS={}".format("ON" if shared else "OFF"),
"-DCMAKE_CXX_COMPILER=/usr/bin/clang++-10",
"-DCMAKE_C_COMPILER=/usr/bin/clang-10",
PROJ_ROOT,
Expand Down