Skip to content

Commit e624198

Browse files
committed
initial code
1 parent e6c069b commit e624198

38 files changed

+1414
-0
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM dockcross/linux-armv7
2+
ENV DEFAULT_DOCKCROSS_IMAGE conanclass/linux-armv7
3+
ADD . /work

catchup.sh

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
#!/bin/bash
2+
3+
curdir=$(pwd)
4+
RED='\033[0;51;30m'
5+
STD='\033[0;0;39m'
6+
APIKEY='AKCp2WWshJKjZjguhB3vD2u3RMwHA7gmxWUohWVhs1FqacHBAzKaiL2pp24NNUEhWHm5Dd4JY'
7+
8+
consumer() {
9+
echo "performing Exercise 2 (consumer, with CMake)"
10+
cd consumer
11+
rm -rf build
12+
mkdir -p build
13+
cd build
14+
conan install ..
15+
cmake .. -DCMAKE_BUILD_TYPE=Release
16+
cmake --build .
17+
cd bin
18+
./timer
19+
conan search
20+
conan search zlib/1.2.11@conan/stable
21+
}
22+
23+
consumer_debug() {
24+
echo "performing Exercise 3 (consumer, with build_type Debug)"
25+
cd consumer
26+
rm -rf build
27+
mkdir -p build
28+
cd build
29+
conan install .. -s build_type=Debug
30+
cmake .. -DCMAKE_BUILD_TYPE=Debug
31+
cmake --build .
32+
cd bin
33+
./timer
34+
conan search
35+
conan search zlib/1.2.11@conan/stable
36+
}
37+
38+
consumer_gcc() {
39+
echo "performing Exercise 4 (consumer, with GCC)"
40+
cd consumer_gcc
41+
conan install . -g gcc
42+
g++ timer.cpp @conanbuildinfo.gcc -o timer --std=c++11
43+
./timer
44+
}
45+
46+
create() {
47+
echo "performing Exercise 5 (Create a Conan Package)"
48+
cd create
49+
conan new Hello/0.1
50+
conan create . user/testing
51+
conan search
52+
conan search Hello/0.1@user/testing
53+
conan create . user/testing -s build_type=Debug
54+
conan search Hello/0.1@user/testing
55+
conan new Hello/0.1 -t
56+
conan create . user/testing
57+
}
58+
59+
create_sources() {
60+
echo "performing Exercise 6 (Create Package with sources)"
61+
cd create_sources
62+
conan new Hello/0.1 -t -s
63+
conan create . user/testing
64+
conan create . user/testing -s build_type=Debug
65+
}
66+
67+
upload_artifactory() {
68+
echo "performing Exercise 7 (Upload packages to artifactory)"
69+
conan upload Hello/0.1@user/testing -r artifactory --all
70+
conan search -r=artifactory
71+
conan search Hello/0.1@user/testing -r=artifactory
72+
conan remove Hello/0.1@user/testing -f
73+
cd create_sources
74+
conan test test_package Hello/0.1@user/testing
75+
conan test test_package Hello/0.1@user/testing -s build_type=Debug
76+
conan upload "*" -r=artifactory --all --confirm
77+
conan remove "*" -f
78+
cd ../consumer/build
79+
conan install ..
80+
}
81+
82+
cross_build_hello(){
83+
cd create_sources
84+
less ../profile_arm/arm_gcc_debug.profile
85+
conan create . user/testing -pr=../profile_arm/arm_gcc_debug.profile
86+
conan search
87+
conan search Hello/0.1@user/testing
88+
}
89+
90+
profile_arm_compiler() {
91+
cd profile_arm
92+
rm -rf build
93+
mkdir -p build
94+
cd build
95+
conan install .. --profile ../arm_gcc_debug.profile
96+
conan install .. -pr=../arm_gcc_debug.profile --build missing
97+
conan search zlib/1.2.11@conan/stable
98+
conan build ..
99+
ls bin/example && echo "Example built ok!"
100+
}
101+
102+
package_header_only(){
103+
cd header_only
104+
conan new picojson/1.3.0 -i -t
105+
cp example.cpp test_package
106+
107+
echo 'from conans import ConanFile
108+
109+
class PicojsonConan(ConanFile):
110+
name = "picojson"
111+
version = "1.3.0"
112+
license = "The 2-Clause BSD License"
113+
url = "https://github.com/kazuho/picojson"
114+
# No settings/options are necessary, this is header only
115+
116+
def source(self):
117+
self.run("git clone https://github.com/kazuho/picojson.git")
118+
119+
def package(self):
120+
self.copy("*.h", "include")' > conanfile.py
121+
122+
conan create . user/testing
123+
}
124+
125+
gtest() {
126+
conan remote add conan-center https://conan.bintray.com
127+
cd gtest/package
128+
conan create . user/testing
129+
cd ../consumer
130+
conan install .
131+
conan remove "gtest*" -f
132+
conan install .
133+
}
134+
135+
gtest_build_require() {
136+
cd gtest/package
137+
conan create . user/testing
138+
conan remove "gtest*" -f
139+
cd ../consumer
140+
conan install .
141+
}
142+
143+
cmake_build_require() {
144+
cd gtest/package
145+
echo 'message(STATUS "CMAKE VERSION ${CMAKE_VERSION}")' >> CMakeLists.txt
146+
conan create . user/testing
147+
echo 'include(default)
148+
[build_requires]
149+
cmake_installer/3.3.2@conan/stable' > myprofile
150+
conan create . user/testing -pr=myprofile
151+
}
152+
153+
read_options(){
154+
local choice
155+
cd ${curdir}
156+
read -p "Enter choice: " choice
157+
case $choice in
158+
2) consumer ;;
159+
3) consumer_debug ;;
160+
4) consumer_gcc ;;
161+
5) create ;;
162+
6) create_sources ;;
163+
7) upload_artifactory ;;
164+
8) cross_build_hello ;;
165+
9) profile_arm_compiler ;;
166+
11) gtest ;;
167+
12) gtest_build_require ;;
168+
13) cmake_build_require ;;
169+
14) package_header_only ;;
170+
-1) exit 0 ;;
171+
*) echo -e "${RED}Not valid option! ${STD}" && sleep 2
172+
esac
173+
}
174+
175+
176+
# function to display menus
177+
show_menus() {
178+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~"
179+
echo " Automation Catch Up Menu "
180+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~"
181+
echo "2. Exercise 2 (Consume with CMake)"
182+
echo "3. Exercise 3 (Consume with CMake, with different build_type, Debug)"
183+
echo "4. Exercise 4 (Consume with GCC)"
184+
echo "5. Exercise 5 (Create a conan package)"
185+
echo "6. Exercise 6 (Create package with sources)"
186+
echo "7. Exercise 7 (Upload packages to artifactory)"
187+
echo "8. Exercise 8 (Cross build to ARM - RPI)"
188+
echo "9. Exercise 9 (Cross build zlib dependency to ARM)"
189+
echo "11. Exercise 11 (Use Gtest as a require)"
190+
echo "12. Exercise 12 (Use Gtest as a build_require)"
191+
echo "13. Exercise 13 (CMake as build require)"
192+
echo "14. Exercise 14 (Create a package for a header only library)"
193+
echo "-1. Exit"
194+
}
195+
196+
while true
197+
do
198+
show_menus
199+
read_options
200+
done

consumer/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

consumer/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
project(BoostPoco)
3+
add_compile_options(-std=c++11)
4+
5+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
6+
conan_basic_setup()
7+
8+
add_executable(timer timer.cpp)
9+
target_link_libraries(timer ${CONAN_LIBS})
10+
11+
12+
# if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
13+
# include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
14+
# conan_basic_setup()
15+
# endif()
16+
17+
# But we could use CMake find_package as well, or link with libraries individually
18+
#find_package(Boost REQUIRED regex)
19+
20+
#if(Boost_FOUND)
21+
# include_directories(${Boost_INCLUDE_DIRS})
22+
# target_link_libraries(timer ${Boost_LIBRARIES})
23+
#endif()
24+
25+
#target_link_libraries(timer ${CONAN_LIBS_POCO})

consumer/conanfile.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[requires]
2+
boost/1.67.0@conan/stable
3+
Poco/1.9.0@pocoproject/stable
4+
5+
[generators]
6+
cmake
7+
8+
[options]
9+
Boost:shared=False
10+
Poco:shared=False

consumer/timer.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "Poco/Timer.h"
2+
#include "Poco/Thread.h"
3+
#include "Poco/Stopwatch.h"
4+
5+
#include <boost/regex.hpp>
6+
#include <string>
7+
#include <iostream>
8+
9+
using Poco::Timer;
10+
using Poco::TimerCallback;
11+
using Poco::Thread;
12+
using Poco::Stopwatch;
13+
14+
class TimerExample{
15+
public:
16+
TimerExample(){ _sw.start();}
17+
void onTimer(Timer& timer){
18+
std::cout << "Callback called after " << _sw.elapsed()/1000 << " milliseconds." << std::endl;
19+
}
20+
private:
21+
Stopwatch _sw;
22+
};
23+
24+
int main(int argc, char** argv){
25+
TimerExample example;
26+
Timer timer(250, 500);
27+
timer.start(TimerCallback<TimerExample>(example, &TimerExample::onTimer));
28+
29+
Thread::sleep(3000);
30+
timer.stop();
31+
32+
std::string s = "[email protected]", s2="bademail";
33+
boost::regex expr{"\\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b"};
34+
std::cout << std::boolalpha << boost::regex_match(s, expr) << '\n';
35+
std::cout << std::boolalpha << boost::regex_match(s2, expr) << '\n';
36+
37+
return 0;
38+
}

consumer_gcc/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
conanbuildinfo*
3+
conaninfo*
4+
timer

consumer_gcc/conanfile.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[requires]
2+
boost/1.67.0@conan/stable
3+
Poco/1.9.0@pocoproject/stable
4+
5+
[generators]
6+
cmake
7+
8+
[options]
9+
Boost:shared=False
10+
Poco:shared=False

consumer_gcc/timer.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "Poco/Timer.h"
2+
#include "Poco/Thread.h"
3+
#include "Poco/Stopwatch.h"
4+
5+
#include <boost/regex.hpp>
6+
#include <string>
7+
#include <iostream>
8+
9+
using Poco::Timer;
10+
using Poco::TimerCallback;
11+
using Poco::Thread;
12+
using Poco::Stopwatch;
13+
14+
class TimerExample{
15+
public:
16+
TimerExample(){ _sw.start();}
17+
void onTimer(Timer& timer){
18+
std::cout << "Callback called after " << _sw.elapsed()/1000 << " milliseconds." << std::endl;
19+
}
20+
private:
21+
Stopwatch _sw;
22+
};
23+
24+
int main(int argc, char** argv){
25+
TimerExample example;
26+
Timer timer(250, 500);
27+
timer.start(TimerCallback<TimerExample>(example, &TimerExample::onTimer));
28+
29+
Thread::sleep(3000);
30+
timer.stop();
31+
32+
std::string s = "[email protected]", s2="bademail";
33+
boost::regex expr{"\\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b"};
34+
std::cout << std::boolalpha << boost::regex_match(s, expr) << '\n';
35+
std::cout << std::boolalpha << boost::regex_match(s2, expr) << '\n';
36+
37+
return 0;
38+
}

create/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This folder is empty on purpose.
2+
Files will be created with "conan new" commmand
3+
Still the folder is necessary so "catchup" script works well.

0 commit comments

Comments
 (0)