CMake: Added support for compiling the agent with CMake. Review: https://reviews.apache.org/r/38756
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d4a970e6 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d4a970e6 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d4a970e6 Branch: refs/heads/master Commit: d4a970e64376a2df523f2d820f29f8a79d67dcc2 Parents: 96b25d8 Author: Alex Clemmer <[email protected]> Authored: Sun Sep 27 15:41:36 2015 -0700 Committer: Joris Van Remoortere <[email protected]> Committed: Sun Sep 27 16:24:26 2015 -0700 ---------------------------------------------------------------------- CMakeLists.txt | 11 ++- cmake/MesosConfigure.cmake | 27 +++++++ src/CMakeLists.txt | 129 ++++++++++++++++++++++++++++++ src/cmake/MesosProtobuf.cmake | 102 +++++++++++++++++++++++ src/slave/cmake/SlaveConfigure.cmake | 71 ++++++++++++++++ 5 files changed, 339 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/d4a970e6/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index ba209c8..c866f6d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,13 @@ cmake_minimum_required(VERSION 2.8) project(Mesos) -set(MESOS_PACKAGE_VERSION 0.22.1) +set(MESOS_MAJOR_VERSION 0) +set(MESOS_MINOR_VERSION 26) +set(MESOS_PATCH_VERSION 0) +set(PACKAGE_VERSION + ${MESOS_MAJOR_VERSION}.${MESOS_MINOR_VERSION}.${MESOS_PATCH_VERSION}) + +set(MESOS_PACKAGE_VERSION ${PACKAGE_VERSION}) set(MESOS_PACKAGE_SOVERSION 0) # MESOS BUILD CONFIGURATION OPTIONS. @@ -75,6 +81,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/cmake) list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/cmake/macros) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/slave/cmake) # Macros. include(Common) @@ -89,3 +97,4 @@ include(MesosConfigure) # SUBDIRECTORIES. ################# add_subdirectory(3rdparty) +add_subdirectory(src) http://git-wip-us.apache.org/repos/asf/mesos/blob/d4a970e6/cmake/MesosConfigure.cmake ---------------------------------------------------------------------- diff --git a/cmake/MesosConfigure.cmake b/cmake/MesosConfigure.cmake index 2f4c412..9a4fdb5 100755 --- a/cmake/MesosConfigure.cmake +++ b/cmake/MesosConfigure.cmake @@ -62,3 +62,30 @@ if (WIN32) string(REPLACE ";" " " MESOS_BUILD_CMD "${MESOS_BUILD_CMD}") file(WRITE ${CMAKE_BINARY_DIR}/make.bat ${MESOS_BUILD_CMD}) endif (WIN32) + +# DEFINE DIRECTORY STRUCTURE MESOS PROJECT. +########################################### +set(MESOS_SRC_DIR ${CMAKE_SOURCE_DIR}/src) +set(MESOS_BIN ${CMAKE_BINARY_DIR}) +set(MESOS_BIN_SRC_DIR ${MESOS_BIN}/src) + +# Convenience variables for include directories of third-party dependencies. +set(MESOS_PUBLIC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) +set(MESOS_BIN_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) + +# Make directories that generated Mesos code goes into. +add_custom_target( + make_bin_include_dir ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${MESOS_BIN_INCLUDE_DIR}) + +add_custom_target( + make_bin_src_dir ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${MESOS_BIN_SRC_DIR}) + +# CONFIGURE AGENT. +################## +include(SlaveConfigure) + +# MESOS LIBRARY CONFIGURATION. +############################## +set(MESOS_TARGET mesos-${MESOS_PACKAGE_VERSION}) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mesos/blob/d4a970e6/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..891f951 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,129 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# COMPILE PROTOBUF STRUCTS REQUIRED TO BUILD MESOS. +################################################### +include(MesosProtobuf) + +# Build the protobuf structs. +PROTOC_TO_INCLUDE_DIR(MESOS mesos/mesos) +PROTOC_TO_INCLUDE_DIR(V1_MESOS mesos/v1/mesos) +PROTOC_TO_INCLUDE_DIR(AUTHENTICATION mesos/authentication/authentication) +PROTOC_TO_INCLUDE_DIR(AUTHORIZATION mesos/authorizer/authorizer) +PROTOC_TO_INCLUDE_DIR(CONTAINERIZER mesos/containerizer/containerizer) +PROTOC_TO_INCLUDE_DIR(EXECUTOR mesos/executor/executor) +PROTOC_TO_INCLUDE_DIR(V1_EXECUTOR mesos/v1/executor/executor) +PROTOC_TO_INCLUDE_DIR(FETCHER mesos/fetcher/fetcher) +PROTOC_TO_INCLUDE_DIR(MAINTENANCE mesos/maintenance/maintenance) +PROTOC_TO_INCLUDE_DIR(ALLOCATOR mesos/master/allocator) +PROTOC_TO_INCLUDE_DIR(MODULE mesos/module/module) +PROTOC_TO_INCLUDE_DIR(SCHEDULER mesos/scheduler/scheduler) +PROTOC_TO_INCLUDE_DIR(V1_SCHEDULER mesos/v1/scheduler/scheduler) +PROTOC_TO_INCLUDE_DIR(ISOLATOR mesos/slave/isolator) +PROTOC_TO_INCLUDE_DIR(OVERSUBSCRIPTION mesos/slave/oversubscription) + +PROTOC_TO_SRC_DIR(MESSAGES messages/messages) +PROTOC_TO_SRC_DIR(FLAGS messages/flags) + +set(MESOS_PROTOBUF_SRC + ${MESOS_PROTO_CC} + ${V1_MESOS_PROTO_CC} + ${AUTHENTICATION_PROTO_CC} + ${AUTHORIZATION_PROTO_CC} + ${CONTAINERIZER_PROTO_CC} + ${EXECUTOR_PROTO_CC} + ${V1_EXECUTOR_PROTO_CC} + ${FETCHER_PROTO_CC} + ${MAINTENANCE_PROTO_CC} + ${ALLOCATOR_PROTO_CC} + ${MODULE_PROTO_CC} + ${SCHEDULER_PROTO_CC} + ${V1_SCHEDULER_PROTO_CC} + ${MESSAGES_PROTO_CC} + ${FLAGS_PROTO_CC} + ${ISOLATOR_PROTO_CC} + ${OVERSUBSCRIPTION_PROTO_CC} + ) + +# Configure Mesos files. +######################## +configure_file( + ${MESOS_PUBLIC_INCLUDE_DIR}/mesos/version.hpp.in + ${MESOS_BIN_INCLUDE_DIR}/mesos/version.hpp + ) + +# SOURCE FILES FOR THE MESOS LIBRARY. +##################################### +set(AGENT_SRC + slave/constants.cpp + slave/gc.cpp + slave/flags.cpp + slave/http.cpp + slave/metrics.cpp + slave/monitor.cpp + slave/paths.cpp + slave/qos_controller.cpp + slave/qos_controllers/noop.cpp + slave/resource_estimator.cpp + slave/slave.cpp + slave/state.cpp + slave/status_update_manager.cpp + slave/containerizer/containerizer.cpp + slave/containerizer/composing.cpp + slave/containerizer/composing.hpp + slave/containerizer/docker.cpp + slave/containerizer/docker.hpp + slave/containerizer/external_containerizer.cpp + slave/containerizer/fetcher.cpp + slave/containerizer/isolator.cpp + slave/containerizer/isolators/filesystem/posix.cpp + slave/containerizer/isolators/posix/disk.cpp + slave/containerizer/launcher.cpp + slave/containerizer/mesos/containerizer.cpp + slave/containerizer/mesos/launch.cpp + slave/containerizer/provisioner/paths.cpp + slave/containerizer/provisioner/provisioner.cpp + slave/containerizer/provisioner/store.cpp + slave/containerizer/provisioner/appc/paths.cpp + slave/containerizer/provisioner/appc/spec.cpp + slave/containerizer/provisioner/appc/store.cpp + slave/containerizer/provisioner/backend.cpp + slave/containerizer/provisioner/backends/copy.cpp + slave/containerizer/provisioner/docker/registry_client.cpp + slave/containerizer/provisioner/docker/token_manager.cpp + slave/resource_estimators/noop.cpp + ) + +set(MESOS_SRC + ${MESOS_SRC} + ${AGENT_SRC} + ${MESOS_PROTOBUF_SRC} + ) + +# INCLUDE DIRECTIVES FOR MESOS LIBRARY (generates, e.g., -I/path/to/thing +# on Linux). +######################################################################### +include_directories(${AGENT_INCLUDE_DIRS}) + +# THE MESOS LIBRARY (generates, e.g., libmesos.so, etc., on Linux). +################################################################### +add_library(${MESOS_TARGET} ${MESOS_SRC}) +set_target_properties( + ${MESOS_TARGET} PROPERTIES + VERSION ${MESOS_PACKAGE_VERSION} + SOVERSION ${MESOS_PACKAGE_SOVERSION} + ) +add_dependencies(${MESOS_TARGET} ${AGENT_DEPENDENCIES}) http://git-wip-us.apache.org/repos/asf/mesos/blob/d4a970e6/src/cmake/MesosProtobuf.cmake ---------------------------------------------------------------------- diff --git a/src/cmake/MesosProtobuf.cmake b/src/cmake/MesosProtobuf.cmake new file mode 100644 index 0000000..d5e1e13 --- /dev/null +++ b/src/cmake/MesosProtobuf.cmake @@ -0,0 +1,102 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# PROTO_TO_INCLUDE_DIR is a convenience function that will: (1) compile .proto +# files found in the Mesos public-facing `include/` directory, (2) place the +# generated files in the build folder, but with an identical directory +# structure, and (3) export variables holding the fully-qualified path to the +# generated files, based on a name structure the user specifies with the +# `BASE_NAME` and `BASE_DIR_STRUCTURE` parameters. +# +# For example, if suppose wish to compile `include/mesos/mesos.proto`. We might +# pass in the following values for the parameters: +# +# BASE_NAME: MESOS (i.e., basis for the exported var names) +# BASE_DIR_STRUCTURE: mesos/mesos (i.e., where `mesos/mesos.proto` would be +# the relative path to the .proto file, we'd +# use this "root name" to generate files +# like `mesos/mesos.pb.cc` +# +# In this case, this function would: +# +# (1) compile the `include/mesos/mesos.proto`, which would generate the files +# `build/include/mesos/mesos.pb.h` and `build/include/mesos/mesos.pb.cc` +# (2) export the following variables, based on the `BASE_NAME` parameter +# (a) MESOS_PROTO: ${MESOS_ROOT}/include/mesos/mesos.proto +# (b) MESOS_PROTO_CC: ${MESOS_ROOT}/build/include/mesos/mesos.pb.cc +# (a) MESOS_PROTO_H: ${MESOS_ROOT}/build/include/mesos/mesos.pb.h +function(PROTOC_TO_INCLUDE_DIR BASE_NAME BASE_DIR_STRUCTURE) + + set(TO_INCLUDE_DIR + -I${MESOS_PUBLIC_INCLUDE_DIR} + -I${MESOS_SRC_DIR} + --cpp_out=${MESOS_BIN_INCLUDE_DIR}) + + # Names of variables we will be publicly exporting. + set(PROTO_VAR ${BASE_NAME}_PROTO) # e.g., MESOS_PROTO + set(CC_VAR ${BASE_NAME}_PROTO_CC) # e.g., MESOS_PROTO_CC + set(H_VAR ${BASE_NAME}_PROTO_H) # e.g., MESOS_PROTO_H + + # Fully qualified paths for the input .proto files and the output C files. + set(PROTO ${MESOS_PUBLIC_INCLUDE_DIR}/${BASE_DIR_STRUCTURE}.proto) + set(CC ${MESOS_BIN_INCLUDE_DIR}/${BASE_DIR_STRUCTURE}.pb.cc) + set(H ${MESOS_BIN_INCLUDE_DIR}/${BASE_DIR_STRUCTURE}.pb.h) + + # Export variables holding the target filenames. + set(${PROTO_VAR} ${PROTO} PARENT_SCOPE) # e.g., mesos/mesos.proto + set(${CC_VAR} ${CC} PARENT_SCOPE) # e.g., mesos/mesos.pb.cc + set(${H_VAR} ${H} PARENT_SCOPE) # e.g., mesos/mesos.pb.h + + # Compile the .proto file. + ADD_CUSTOM_COMMAND( + OUTPUT ${CC} ${H} + COMMAND ${PROTOC} ${TO_INCLUDE_DIR} ${PROTO} + DEPENDS make_bin_include_dir + WORKING_DIRECTORY ${MESOS_BIN}) +endfunction() + +# PROTO_TO_SRC_DIR is similar to `PROTO_TO_INCLUDE_DIR`, except it acts on the +# Mesos `src/` directory instead of the public-facing `include/` directory (see +# documentation for `PROTO_TO_INCLUDE_DIR` for details). +function(PROTOC_TO_SRC_DIR BASE_NAME BASE_DIR_STRUCTURE) + + set(TO_SRC_DIR + -I${MESOS_PUBLIC_INCLUDE_DIR} + -I${MESOS_SRC_DIR} + --cpp_out=${MESOS_BIN_SRC_DIR}) + + # Names of variables we will be publicly exporting. + set(PROTO_VAR ${BASE_NAME}_PROTO) # e.g., MESOS_PROTO + set(CC_VAR ${BASE_NAME}_PROTO_CC) # e.g., MESOS_PROTO_CC + set(H_VAR ${BASE_NAME}_PROTO_H) # e.g., MESOS_PROTO_H + + # Fully qualified paths for the input .proto files and the output C files. + set(PROTO ${MESOS_SRC_DIR}/${BASE_DIR_STRUCTURE}.proto) + set(CC ${MESOS_BIN_SRC_DIR}/${BASE_DIR_STRUCTURE}.pb.cc) + set(H ${MESOS_BIN_SRC_DIR}/${BASE_DIR_STRUCTURE}.pb.h) + + # Export variables holding the target filenames. + set(${PROTO_VAR} ${PROTO} PARENT_SCOPE) # e.g., mesos/mesos.proto + set(${CC_VAR} ${CC} PARENT_SCOPE) # e.g., mesos/mesos.pb.cc + set(${H_VAR} ${H} PARENT_SCOPE) # e.g., mesos/mesos.pb.h + + # Compile the .proto file. + ADD_CUSTOM_COMMAND( + OUTPUT ${CC} ${H} + COMMAND ${PROTOC} ${TO_SRC_DIR} ${PROTO} + DEPENDS make_bin_src_dir + WORKING_DIRECTORY ${MESOS_BIN}) +endfunction() http://git-wip-us.apache.org/repos/asf/mesos/blob/d4a970e6/src/slave/cmake/SlaveConfigure.cmake ---------------------------------------------------------------------- diff --git a/src/slave/cmake/SlaveConfigure.cmake b/src/slave/cmake/SlaveConfigure.cmake new file mode 100644 index 0000000..230e574 --- /dev/null +++ b/src/slave/cmake/SlaveConfigure.cmake @@ -0,0 +1,71 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Define process library dependencies. Tells the process library build targets +# download/configure/build all third-party libraries before attempting to build. +################################################################################ +set(AGENT_DEPENDENCIES + ${AGENT_DEPENDENCIES} + ${PROCESS_TARGET} + ${BOOST_TARGET} + ${GLOG_TARGET} + ${PICOJSON_TARGET} + ${ZOOKEEPER_TARGET} + make_bin_include_dir + make_bin_src_dir + ) + +# Define third-party include directories. Tells compiler toolchain where to get +# headers for our third party libs (e.g., -I/path/to/glog on Linux). +############################################################################### +set(AGENT_INCLUDE_DIRS + ${AGENT_INCLUDE_DIRS} + ${MESOS_PUBLIC_INCLUDE_DIR} + # Protobuf headers that depend on mesos.pb.h need this. + ${MESOS_PUBLIC_INCLUDE_DIR}/mesos + # Contains (e.g.) compiled *.pb.h files. + ${MESOS_BIN_INCLUDE_DIR} + ${MESOS_BIN_INCLUDE_DIR}/mesos + ${MESOS_BIN_SRC_DIR} + ${MESOS_SRC_DIR} + + ${PROCESS_INCLUDE_DIR} + ${STOUT_INCLUDE_DIR} + ${BOOST_INCLUDE_DIR} + ${GLOG_INCLUDE_DIR} + ${PICOJSON_INCLUDE_DIR} + ${PROTOBUF_INCLUDE_DIR} + ${ZOOKEEPER_INCLUDE_DIR} + ) + +# Define third-party lib install directories. Used to tell the compiler +# toolchain where to find our third party libs (e.g., -L/path/to/glog on +# Linux). +######################################################################## +set(AGENT_LIB_DIRS + ${AGENT_LIB_DIRS} + ${PROCESS_LIB_DIRS} + ${GLOG_LIB_DIR} + ${ZOOKEEPER_LIB_DIR} + ) + +# Define third-party libs. Used to generate flags that the linker uses to +# include our third-party libs (e.g., -lglog on Linux). +######################################################################### +set(AGENT_LIBS + ${PROCESS_LIBS} + ${GLOG_LFLAG} + )
