Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 3ff254f

Browse files
committed
Added install script on Ubuntu
1 parent d5da87b commit 3ff254f

File tree

6 files changed

+228
-20
lines changed

6 files changed

+228
-20
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111
- docker run -dt --name "worker-box" -e TEST_TYPE -e GTEST_ROOT -v ${TRAVIS_BUILD_DIR}/:/${TRAVIS_REPO_SLUG} for-worker-box bash
1212
script:
1313
- docker exec -ti worker-box bash -c "cd /${TRAVIS_REPO_SLUG} && git submodule update --init"
14-
- docker exec -ti worker-box bash -c "cd /${TRAVIS_REPO_SLUG} && ./install_deps_centos.sh"
14+
- docker exec -ti worker-box bash -c "cd /${TRAVIS_REPO_SLUG} && ./install_deps_ubuntu.sh"
1515
- docker exec -ti worker-box bash -c "cd /${TRAVIS_REPO_SLUG} && ./test.sh"
1616
after_script:
1717
- docker rm -fv worker-box

Docker/Dockerfile.travis

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
FROM centos:7
19-
RUN yum update -y
20-
RUN yum groupinstall -y base
21-
RUN yum install -y git cmake mc tmux autoconf automake python-devel libtool zlib-devel openssl-devel curl make unzip wget golang clang bzip2-devel gcc-c++ protobuf-compiler libprotobuf-dev libprotoc-dev centos-release-scl-rh
22-
RUN yum install -y devtoolset-4-gcc devtoolset-4-gcc-c++
23-
RUN scl enable devtoolset-4 bash
24-
RUN export PATH=/opt/rh/devtoolset-4/root/usr/bin/:$PATH
18+
FROM ubuntu:xenial
19+
20+
RUN apt-get update && apt-get upgrade -yq
21+
RUN apt-get install g++-4.9 gcc-4.9 protobuf-compiler libprotobuf-dev libprotoc-dev libboost-dev libcppnetlib-dev libspdlog-dev git curl cmake golang-go autoconf libtool ca-certificates unzip software-properties-common golang-go -yq

Vagrant/Vagrantfile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Vagrant.configure("2") do |config|
1313

1414
# Every Vagrant development environment requires a box. You can search for
1515
# boxes at https://atlas.hashicorp.com/search.
16-
config.vm.box = "centos/7"
16+
config.vm.box = "ubuntu/xenial64"
1717

1818
config.vm.synced_folder "..", "/home/vagrant/snap-plugin-collector-rdt", :mount_options => ["umask=0022,dmask=0022,fmask=0022"]
1919

@@ -79,14 +79,11 @@ Vagrant.configure("2") do |config|
7979
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
8080
# documentation for more information about their specific syntax and use.
8181
config.vm.provision "shell", inline: <<-SHELL
82-
sudo yum update -y
83-
sudo yum install -y git cmake mc tmux autoconf automake libtool zlib-devel openssl-devel curl make unzip wget golang clang gcc-c++ protobuf-compiler libprotobuf-dev libprotoc-dev centos-release-scl-rh
84-
sudo yum install -y devtoolset-4-gcc devtoolset-4-gcc-c++
85-
sudo scl enable devtoolset-4 bash
86-
export PATH=/opt/rh/devtoolset-4/root/usr/bin/:$PATH
87-
cd snap-plugin-collector-rdt
82+
sudo apt-get update && sudo apt-get upgrade -yq
83+
sudo apt-get install g++-4.9 gcc-4.9 protobuf-compiler libprotobuf-dev libprotoc-dev libboost-dev libcppnetlib-dev libspdlog-dev git curl cmake golang-go autoconf libtool ca-certificates unzip software-properties-common golang-go -yq
84+
cd /home/vagrant/snap-plugin-collector-rdt
8885
git submodule update --init
89-
./install_deps_centos.sh
86+
./install_deps_ubuntu.sh
9087
./build.sh
9188
SHELL
9289
end

build.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/usr/bin/env bash
22

3-
export CC=/opt/rh/devtoolset-4/root/usr/bin/gcc
4-
export CXX=/opt/rh/devtoolset-4/root/usr/bin/g++
5-
export PATH=/opt/rh/devtoolset-4/root/usr/bin/:$PATH
6-
gcc --version
73
mkdir -p build
84
cd build
95
cmake ..

include/snap/flags.h

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
http://www.apache.org/licenses/LICENSE-2.0.txt
3+
Copyright 2017 Intel Corporation
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
#pragma once
15+
16+
#include <boost/program_options.hpp>
17+
#include <fstream>
18+
#include <iostream>
19+
#include <iterator>
20+
#include <map>
21+
#include <spdlog/spdlog.h>
22+
#include <snap/rpc/plugin.pb.h>
23+
24+
25+
#define COMMAND_DESC "COMMANDS"
26+
#define GLOBAL_DESC "GLOBAL OPTIONS"
27+
#define ADDITIONAL_DESC ""
28+
29+
namespace po = boost::program_options;
30+
namespace spd = spdlog;
31+
32+
using namespace std;
33+
34+
35+
namespace Plugin {
36+
//helper function to simplify main part
37+
template<class T>
38+
ostream& operator<<(ostream& os, const vector<T>& v) {
39+
copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
40+
return os;
41+
};
42+
43+
class Flags {
44+
private:
45+
std::shared_ptr<spd::logger> _logger;
46+
47+
po::variables_map _flags;
48+
49+
// Initial option descriptions
50+
po::options_description _command{COMMAND_DESC}, _global{GLOBAL_DESC};
51+
po::options_description _hidden, _additional{ADDITIONAL_DESC};
52+
53+
// Combined option descriptions
54+
po::options_description _visible, _command_line, _config_file;
55+
56+
// Default variables
57+
int _log_level, _stand_alone_port, _max_collect_duration;
58+
std::string _options_file, _listen_port, _listen_addr, _cert_path, _key_path, _root_cert_paths;
59+
int64_t _max_metrics_buffer;
60+
61+
bool _framework_json_parsed;
62+
63+
public:
64+
enum FlagType {
65+
Bool,
66+
Int,
67+
String
68+
};
69+
70+
enum FlagLevel {
71+
Command,
72+
Global,
73+
Hidden,
74+
Custom
75+
};
76+
77+
Flags() {
78+
_logger = spdlog::stderr_logger_mt("flags");
79+
}
80+
81+
Flags(const int &argc, char **argv) :
82+
_framework_json_parsed(false) {
83+
std::string logger_name = argc > 0 ? "flags_" + std::string(argv[0]) : "flags";
84+
_logger = spdlog::stderr_logger_mt(logger_name);
85+
this->SetFlags();
86+
this->ParseFlags(argc, argv);
87+
}
88+
89+
int addDefaultCommandFlags();
90+
int addDefaultGlobalFlags();
91+
int addDefaultHiddenFlags();
92+
int SetDefaultFlags();
93+
94+
int addBoolFlag(const char *optionName, const char *description,
95+
FlagLevel flagLevel);
96+
int addIntFlag(const char *optionName, const char *description,
97+
FlagLevel flagLevel);
98+
int addStringFlag(const char *optionName, const char *description,
99+
FlagLevel flagLevel);
100+
int AddFlag(const char *optionName, const char *description,
101+
FlagType flagType, FlagLevel flagLevel);
102+
103+
int setVisibleFlags();
104+
int setCommandLineFlags();
105+
int setConfigFileFlags();
106+
int SetCombinedFlags();
107+
108+
int SetFlags() {
109+
if (SetDefaultFlags() != 0) return 1;
110+
if (SetCombinedFlags() != 0) return 1;
111+
return 0;
112+
}
113+
114+
int parseCommandLineFlags(const int &argc, char **argv);
115+
int parsejsonFlags(const int &argc, char **argv);
116+
int parseConfigFileFlags(std::string filePathAndName = "");
117+
int ParseFlags(const int &argc, char **argv, std::string filePathAndName = "");
118+
119+
120+
void ShowVariablesMap();
121+
bool IsParsedFlag(const char *flagKey) { return _flags.count(flagKey); }
122+
po::variables_map GetFlagsVM() { return _flags; }
123+
const bool IsConfigFromFramework() const {return _framework_json_parsed; }
124+
125+
bool GetFlagBoolValue(const char *flagKey);
126+
int GetFlagIntValue(const char *flagKey);
127+
int64_t GetFlagInt64Value(const char *flagKey);
128+
std::string GetFlagStrValue(const char *flagKey);
129+
130+
void SetFlagsLogLevel(const int &logLevel = 2);
131+
132+
int helpFlagCalled() {
133+
std::cout << _visible << std::endl;
134+
return 0;
135+
}
136+
137+
po::options_description GetCommandOptions() { return _command; }
138+
void PrintCommandOptions() { std::cout << _command << std::endl; }
139+
140+
po::options_description GetGlobalOptions() { return _global; }
141+
void PrintGlobalOptions() { std::cout << _global << std::endl; }
142+
143+
po::options_description GetHiddenOptions() { return _hidden; }
144+
void PrintHiddenOptions() { std::cout << _hidden << std::endl; }
145+
146+
po::options_description GetAdditionalOptions() { return _additional; }
147+
void PrintAdditionalOptions() { std::cout << _additional << std::endl; }
148+
149+
po::options_description GetVisibleOptions() { return _visible; }
150+
void PrintVisibleOptions() { std::cout << _visible << std::endl; }
151+
152+
po::options_description GetCommandLineOptions() { return _command_line; }
153+
void PrintCommandLineOptions() { std::cout << _command_line << std::endl; }
154+
155+
po::options_description GetConfigFileOptions() { return _config_file; }
156+
void PrintConfigFileOptions() { std::cout << _config_file << std::endl; }
157+
158+
const rpc::ConfigMap GenerateConfigMapFromCommandJson();
159+
};
160+
} // namespace Plugin

install_deps_ubuntu.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2017 Intel Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
pushd `pwd`
17+
cd third_party/intel-cmt-cat/lib/
18+
make SHARED=n
19+
cp libpqos.a ../../../lib/
20+
popd
21+
22+
pushd `pwd`
23+
cd ./third_party/googletest
24+
cmake CMakeLists.txt
25+
make -j2
26+
make install
27+
cp googlemock/libgmock.a ../../lib
28+
cp googlemock/gtest/libgtest.a ../../lib
29+
popd
30+
31+
pushd `pwd`
32+
cd ./third_party/grpc
33+
git checkout tags/v1.0.1
34+
git submodule update --init
35+
make -j2
36+
make install
37+
38+
pushd `pwd`
39+
cd ./third_party/protobuf
40+
make clean
41+
./autogen.sh
42+
./configure
43+
make -j2
44+
make install
45+
popd
46+
popd
47+
48+
pushd `pwd`
49+
cd ./third_party/snap-plugin-lib-cpp
50+
mkdir -p build
51+
./autogen.sh
52+
./configure -prefix=`pwd`/build
53+
make -j2
54+
make install
55+
cp build/lib/libsnap.a ../../lib
56+
popd
57+
58+
ldconfig -v

0 commit comments

Comments
 (0)