December 11th, 2019
C++ Programmer Meetup (BCN)
Javier García Sogo
C++/Python/DevOps... engineer
@jgsogo
Javier G. Sogo
Software | Conan.io | JFrog™
jgsogo @jgsogo
xxx::shared_ptr
yyy::shared_ptr
C++ PHP Python
Scrape, classify (NLP), monitor, tweet
Commands, scrape, bot
All speculative
make && sudo make install
?
I want my job done!
Find a nice how-to
It uses opencv/3.4.5
Piece of cake!
Here it is something promising
C libraries, different build systems,...
Child's play!
Development team:
Join us! We are hiring!
Reuse binaries (if you want)
Integrates with any build system
3rd parties & your libraries
Non intrusive
Reference
Package ID
name/version:package_id
'name'
and 'version'
of the library
boost/1.71.0
openssl/1.1.1d
*Use only 'name/version@user/channel'
to avoid collisions
*Recipes are versioned using 'name/version#recipe_revision'
Unique identifier of the binaries
Linux, x86_64, GCC 6, Release, shared=True,...:
openssl/1.1.1d:008f1a2b119556f550c11...
Linux, x86_64, GCC 6, Debug, shared=False,...:
openssl/1.1.1d:160c0f76fcf1ad0d80837...
[requires]
hellolib/0.1
fmt/6.0.0
using CMake
[generators]
cmake_find_package
1) Declare your settings and dependencies
from conans import ConanFile, CMake
class HelloLib(ConanFile):
name = "hellolib"
version = "1.0"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False]}
default_options = {"shared": False}
requires = "fmt/6.0.0"
2) Where to get the sources
from conans import ConanFile, CMake
class HelloLib(ConanFile):
...
exports_sources = "include/*", "src/*", "CMakeLists.txt", "README.md"
# scm = {"type": "git",
# "revision": "auto",
# "url": "auto"}
# def source(self):
# # Write your own function
# tools.get(url="...", sha1="...")
# os.rename("name-version", "source_folder")
2) Where to get the sources
from conans import ConanFile, CMake
class HelloLib(ConanFile):
...
# exports_sources = "include/*", "src/*", "CMakeLists.txt", "README.md"
scm = {"type": "git",
"revision": "auto",
"url": "auto"}
# def source(self):
# # Write your own function
# tools.get(url="...", sha1="...")
# os.rename("name-version", "source_folder")
2) Where to get the sources
from conans import ConanFile, CMake
class HelloLib(ConanFile):
...
# exports_sources = "include/*", "src/*", "CMakeLists.txt", "README.md"
# scm = {"type": "git",
# "revision": "auto",
# "url": "auto"}
def source(self):
# Write your own function
tools.get(url="...", sha1="...")
os.rename("name-version", "source_folder")
3) How to build your library
from conans import ConanFile, CMake, tools
class HelloLib(ConanFile):
...
generators = "cmake", "cmake_find_package"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
4) What files to package
from conans import ConanFile, CMake, tools
class HelloLib(ConanFile):
...
def package(self):
cmake = CMake(self)
cmake.configure()
cmake.install() # Or copy the files yourself
self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder)
5) Information for consumers/generators
from conans import ConanFile, CMake, tools
class HelloLib(ConanFile):
...
def package_info(self):
self.cpp_info.libs = ["hellolib"]
self.cpp_info.defines = ["WITH_HELLO_LIB"]
Create/test the package
conan create path/to/conanfile.py --profile=macos-11-release
Upload to your server
conan upload name/version@ --all --remote=my-private
Spread the word
December 11th, 2019
C++ Programmer Meetup (BCN)
Javier García Sogo
C++/Python/DevOps... engineer
@jgsogo