Skip to content

Commit ac8aee7

Browse files
HDDS-4844. Fixing build issue for some platforms. (#1935)
1 parent afcb289 commit ac8aee7

File tree

2 files changed

+151
-115
lines changed

2 files changed

+151
-115
lines changed
Lines changed: 115 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,115 @@
1-
#
2-
# Licensed to the Apache Software Foundation (ASF) under one or more
3-
# contributor license agreements. See the NOTICE file distributed with this
4-
# work for additional information regarding copyright ownership. The ASF
5-
# licenses this file to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
# <p>
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
# <p>
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,WITHOUT
13-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14-
# License for the specific language governing permissions and limitations under
15-
# the License.
16-
#
17-
# cmake build file for C++ failure_injection_service.
18-
# Assumes protobuf and gRPC have been installed using cmake.
19-
20-
cmake_minimum_required(VERSION 2.8)
21-
22-
project(FailureInjectionService C CXX)
23-
24-
set(BASE_DIR ".")
25-
set(FS_DIR "${BASE_DIR}/FileSystem")
26-
set(SRV_DIR "${BASE_DIR}/Service/cpp")
27-
28-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive -Wall")
29-
30-
# This assumes that gRPC and all its dependencies are already installed
31-
# on this system, so they can be located by find_package().
32-
33-
# Find Protobuf installation
34-
# Looks for protobuf-config.cmake file installed by Protobuf's cmake
35-
# installation.
36-
set(protobuf_MODULE_COMPATIBLE TRUE)
37-
find_package(Protobuf CONFIG REQUIRED)
38-
message(STATUS "Using protobuf ${protobuf_VERSION}")
39-
40-
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
41-
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
42-
43-
# Find gRPC installation
44-
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
45-
find_package(gRPC CONFIG REQUIRED)
46-
message(STATUS "Using gRPC ${gRPC_VERSION}")
47-
48-
set(_GRPC_GRPCPP_UNSECURE gRPC::grpc++_unsecure)
49-
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
50-
51-
# Proto file
52-
get_filename_component(hw_proto
53-
"${BASE_DIR}/Service/protos/failure_injection_service.proto"
54-
ABSOLUTE)
55-
get_filename_component(hw_proto_path "${hw_proto}" PATH)
56-
57-
# Generated sources
58-
set(hw_proto_srcs
59-
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.cc")
60-
set(hw_proto_hdrs
61-
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.h")
62-
set(hw_grpc_srcs
63-
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.cc")
64-
set(hw_grpc_hdrs
65-
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.h")
66-
add_custom_command(
67-
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}"
68-
"${hw_grpc_srcs}" "${hw_grpc_hdrs}"
69-
COMMAND ${_PROTOBUF_PROTOC}
70-
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
71-
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
72-
-I "${hw_proto_path}"
73-
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
74-
"${hw_proto}"
75-
DEPENDS "${hw_proto}")
76-
77-
# Include generated *.pb.h files
78-
include_directories("${CMAKE_CURRENT_BINARY_DIR}"
79-
"${FS_DIR}"
80-
"${SRV_DIR}")
81-
82-
#add_compile_options("-fpermissive")
83-
84-
# Build server
85-
add_executable(failure_injector_svc_server
86-
${FS_DIR}/failure_injector_fs.cc ${FS_DIR}/failure_injector.cc
87-
${SRV_DIR}/failure_injector_svc_server.cc ${SRV_DIR}/run_grpc_service.cc
88-
${hw_proto_srcs}
89-
${hw_grpc_srcs})
90-
target_link_libraries(failure_injector_svc_server
91-
${_GRPC_GRPCPP_UNSECURE}
92-
fuse3
93-
${_PROTOBUF_LIBPROTOBUF})
94-
95-
# Build client
96-
add_executable(failure_injector_svc_client
97-
"${SRV_DIR}/failure_injector_svc_client.cc"
98-
${hw_proto_srcs}
99-
${hw_grpc_srcs})
100-
target_link_libraries(failure_injector_svc_client
101-
${_GRPC_GRPCPP_UNSECURE}
102-
${_PROTOBUF_LIBPROTOBUF})
103-
104-
# Build unit tests
105-
set(CPP_UNIT_FUSE cpp_unit)
106-
foreach(_target
107-
TestFilePathFailures
108-
TestFailureInjector)
109-
add_executable(${_target}
110-
"${FS_DIR}/${CPP_UNIT_FUSE}/${_target}.cc"
111-
${FS_DIR}/failure_injector.cc)
112-
target_link_libraries(${_target}
113-
cppunit)
114-
endforeach()
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with this
4+
# work for additional information regarding copyright ownership. The ASF
5+
# licenses this file to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# <p>
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
# <p>
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations under
15+
# the License.
16+
#
17+
# cmake build file for C++ failure_injection_service.
18+
# Assumes protobuf and gRPC have been installed using cmake.
19+
20+
cmake_minimum_required(VERSION 2.8)
21+
22+
project(FailureInjectionService C CXX)
23+
24+
set(BASE_DIR ".")
25+
set(FS_DIR "${BASE_DIR}/FileSystem")
26+
set(SRV_DIR "${BASE_DIR}/Service/cpp")
27+
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive -Wall")
29+
30+
# This assumes that gRPC and all its dependencies are already installed
31+
# on this system, so they can be located by find_package().
32+
33+
# Find Protobuf installation
34+
# Looks for protobuf-config.cmake file installed by Protobuf's cmake
35+
# installation.
36+
set(protobuf_MODULE_COMPATIBLE TRUE)
37+
find_package(Protobuf CONFIG REQUIRED)
38+
message(STATUS "Using protobuf ${protobuf_VERSION}")
39+
40+
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
41+
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
42+
43+
# Find gRPC installation
44+
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
45+
find_package(gRPC CONFIG REQUIRED)
46+
message(STATUS "Using gRPC ${gRPC_VERSION}")
47+
48+
set(_GRPC_GRPCPP_UNSECURE gRPC::grpc++_unsecure)
49+
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
50+
51+
# Proto file
52+
get_filename_component(hw_proto
53+
"${BASE_DIR}/Service/protos/failure_injection_service.proto"
54+
ABSOLUTE)
55+
get_filename_component(hw_proto_path "${hw_proto}" PATH)
56+
57+
# Generated sources
58+
set(hw_proto_srcs
59+
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.cc")
60+
set(hw_proto_hdrs
61+
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.h")
62+
set(hw_grpc_srcs
63+
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.cc")
64+
set(hw_grpc_hdrs
65+
"${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.h")
66+
add_custom_command(
67+
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}"
68+
"${hw_grpc_srcs}" "${hw_grpc_hdrs}"
69+
COMMAND ${_PROTOBUF_PROTOC}
70+
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
71+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
72+
-I "${hw_proto_path}"
73+
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
74+
"${hw_proto}"
75+
DEPENDS "${hw_proto}")
76+
77+
# Include generated *.pb.h files
78+
include_directories("${CMAKE_CURRENT_BINARY_DIR}"
79+
"${FS_DIR}"
80+
"${SRV_DIR}")
81+
82+
#add_compile_options("-fpermissive")
83+
84+
# Build server
85+
find_package(Threads)
86+
add_executable(failure_injector_svc_server
87+
${FS_DIR}/failure_injector_fs.cc ${FS_DIR}/failure_injector.cc
88+
${SRV_DIR}/failure_injector_svc_server.cc ${SRV_DIR}/run_grpc_service.cc
89+
${hw_proto_srcs}
90+
${hw_grpc_srcs})
91+
target_link_libraries(failure_injector_svc_server
92+
${_GRPC_GRPCPP_UNSECURE}
93+
fuse3
94+
${_PROTOBUF_LIBPROTOBUF})
95+
96+
# Build client
97+
add_executable(failure_injector_svc_client
98+
"${SRV_DIR}/failure_injector_svc_client.cc"
99+
${hw_proto_srcs}
100+
${hw_grpc_srcs})
101+
target_link_libraries(failure_injector_svc_client
102+
${_GRPC_GRPCPP_UNSECURE}
103+
${_PROTOBUF_LIBPROTOBUF})
104+
105+
# Build unit tests
106+
set(CPP_UNIT_FUSE cpp_unit)
107+
foreach(_target
108+
TestFilePathFailures
109+
TestFailureInjector)
110+
add_executable(${_target}
111+
"${FS_DIR}/${CPP_UNIT_FUSE}/${_target}.cc"
112+
${FS_DIR}/failure_injector.cc)
113+
target_link_libraries(${_target}
114+
cppunit)
115+
endforeach()

tools/fault-injection-service/README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,43 @@ Dependencies
2727
built/installed from sources
2828
- cppunit & cppunit-devel
2929

30+
Building Dependencies
31+
======================
32+
33+
Building libfuse3 from the sources
34+
------------------------------------
35+
- You can get it from https://github.com/libfuse/libfuse/releases/
36+
* https://github.com/libfuse/libfuse/releases/tag/fuse-3.10.2
37+
- follow the README.md for building libfuse
38+
- you may need to get "meson-0.42.0" or above to build this.
39+
40+
CMAKE
41+
======
42+
- this will need cmake-3.14.0 or higher
43+
- if required build from the sources. (tested with cmake-3.14.0 and
44+
cmake-3.6.2)
45+
46+
Building grpc from the sources
47+
------------------------------------
48+
- https://grpc.io/docs/languages/cpp/quickstart/
49+
- sudo apt install -y build-essential autoconf libtool pkg-config
50+
- git clone --recurse-submodules -b v1.35.0 https://github.com/grpc/grpc
51+
- Follow build instructions
52+
- mkdir -p cmake/build
53+
- pushd cmake/build
54+
- cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF\
55+
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR ../..
56+
- make -j
57+
- make install
58+
59+
Finally
60+
-------
61+
- Make sure all the dependencies are in $PATH.
62+
- This build was last tested on (debian 4.18.5-1.el7.elrepo.x86_64
63+
GNU/Linux) and Ubuntu 18:0.1.0.0-4.
64+
3065
Installation
31-
------------
66+
=============
3267
mkdir Build
3368
cd Build
3469
do 'cmake ..'

0 commit comments

Comments
 (0)