Skip to content

Commit d3f4edc

Browse files
authored
Merge pull request #10 from JoyStream/development
dev to master
2 parents 5d47cad + ff70c3b commit d3f4edc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+205
-39
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
build/
2-
conanbuildinfo.*
3-
conaninfo.txt
4-
2+
*.pyc

README.md

Lines changed: 28 additions & 0 deletions

conan_package/base.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
class ProtocolSessionBase(ConanFile):
5+
name = "ProtocolSession"
6+
version = "0.1.1"
7+
license = "(c) JoyStream Inc. 2016-2017"
8+
url = "https://github.com/JoyStream/protocol_session-conan.git"
9+
git_repo = "git@github.com:JoyStream/protocol_session-cpp.git"
10+
settings = "os", "compiler", "build_type", "arch"
11+
generators = "cmake"
12+
requires = "ProtocolStateMachine/0.1.1@joystream/stable"
13+
build_policy = "missing"
14+
15+
def source(self):
16+
raise Exception("abstract base package was exported")
17+
18+
def build(self):
19+
cmake = CMake(self.settings)
20+
self.run('cmake repo/sources %s' % (cmake.command_line))
21+
self.run("cmake --build . %s" % cmake.build_config)
22+
23+
def package(self):
24+
self.copy("*.hpp", dst="include", src="repo/sources/include/")
25+
self.copy("*.cpp", dst="include", src="repo/sources/include/") #template defenitions
26+
self.copy("*.a", dst="lib", keep_path=False)
27+
self.copy("*.lib", dst="lib", keep_path=False)
28+
29+
def package_info(self):
30+
self.cpp_info.libs = ["protocol_session"]

conan_package/conanfile.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import os
2+
import shutil
3+
from distutils.dir_util import copy_tree
4+
from base import ProtocolSessionBase
5+
6+
# The reason the local package is named conanfile.py and not testing.py is to we can run
7+
# the test_pacakge command (it doesn't accept a --filename arg)
8+
# This way the "default mode" of working with the pacakges is with the testing channels
9+
10+
# By default conan export uses the testing channel if not specified so it is also convenient to just run
11+
# `conan export joystream` for local development
12+
13+
LOCAL_REPO_PATH_ENV = "PROTOCOL_SESSION_LOCAL_REPO_PATH"
14+
15+
class ProtocolSessionTesting(ProtocolSessionBase):
16+
# No real version is defined when working with a package on the testing channel
17+
# Keep at at 0.0.0 to detect accidentally exporting to stable branch
18+
# It would be nice to have a method that conan calls when the recipie is being exported
19+
version = "0.0.0"
20+
21+
exports = "base.py"
22+
23+
exports_sources = "../sources*"
24+
25+
# override base policy
26+
build_policy="always"
27+
28+
def source(self):
29+
repo_path = os.getenv(LOCAL_REPO_PATH_ENV)
30+
31+
if (repo_path):
32+
os.makedirs("repo/sources")
33+
copy_tree("%s/sources" % repo_path, "repo/sources")
34+
else:
35+
os.mkdir("repo")
36+
shutil.move("sources", "repo/")
37+
38+
def requirements(self):
39+
self.requires("gtest/1.8.0@lasote/stable")
40+
41+
def configure(self):
42+
self.options["gtest"].shared=False
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from base import ProtocolSessionBase
2+
3+
# Use this recipe when creating recipies for uploading to joystream conan repo on stable channel
4+
# Source will be fetched from github repo
5+
6+
class ProtocolSessionRelease(ProtocolSessionBase):
7+
exports = "base.py"
8+
9+
# make extra sure no sources are exported by base package
10+
exports_sources = ""
11+
12+
def source(self):
13+
self.run("git clone %s repo" % self.git_repo)
14+
self.run("cd repo && git checkout v%s" % self.version)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import shutil
3+
from base import ProtocolSessionBase
4+
5+
# Use this recipe when checking out a tagged version locally and you wish to use it in your projects
6+
# on the stable channel. Source will be copied to cache from local folder
7+
# do not upload the recipie if you don't want to include source files with the recipe
8+
9+
class ProtocolSessionRelease(ProtocolSessionBase):
10+
exports = "base.py"
11+
12+
exports_sources = "../sources*"
13+
14+
def source(self):
15+
os.mkdir("repo")
16+
shutil.move("sources", "repo/")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PROJECT(PackageTest)
2+
cmake_minimum_required(VERSION 2.8.12)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
6+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7+
conan_basic_setup()
8+
9+
ADD_EXECUTABLE(example example.cpp)
10+
TARGET_LINK_LIBRARIES(example ${CONAN_LIBS})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from conans import ConanFile, CMake
2+
import os
3+
4+
class ProtocolSessionTestConan(ConanFile):
5+
settings = "os", "compiler", "build_type", "arch"
6+
requires = "ProtocolSession/0.0.0@%s/%s" % ("joystream", "testing")
7+
generators = "cmake"
8+
9+
def build(self):
10+
cmake = CMake(self.settings)
11+
self.run('cmake "%s" %s' % (self.conanfile_directory, cmake.command_line))
12+
self.run("cmake --build . %s" % cmake.build_config)
13+
14+
def imports(self):
15+
self.copy("*.dll", "bin", "bin")
16+
self.copy("*.dylib", "bin", "bin")
17+
18+
def test(self):
19+
os.chdir("bin")
20+
self.run(".%sexample" % os.sep)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <protocol_session/protocol_session.hpp>
2+
3+
int main() {
4+
5+
return 0;
6+
}

conanfile.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)