jgsogo/talk-meetup-bcn-2019 Javier G. Sogo | Senior software developer | JFrog LTD | Conan C/C++ Package Manager

C++ experience (+10y)*

*before joining JFrog

UPM intern

  • It's own framework
  • xxx::shared_ptr
  • SVN monorepo
  • without a CI
  • VS projects
  • ~100 projects

Quant developer

  • It's own framework
  • yyy::shared_ptr
  • SVN monorepo
  • CI
  • CMake
  • ~400 projects
Image: https://howmuchismysideprojectworth.com/

Side projects!

Let's do some WWW

C++ PHP Python

NLP

Python

  • Web (backend)
  • Scraping
  • Orchestration
  • Data preparation
  • DB layer

C++

  • Read CSV
  • Process data
  • Write CSV

Twitter bot

Scrape, classify (NLP), monitor, tweet  

Telegram bot

Commands, scrape, bot  

ADIF + Renfe

C++ side projects

All speculative

   make && sudo make install

 ?

I want my job done!

Act. II

I had a dream

Face recognition

Face recognition

Find a nice how-to

It uses opencv/3.4.5

Piece of cake!

Posting to Twitter

Here it is something promising

C libraries, different build systems,...

Child's play!

Photo: Inception (Christopher Nolan, 2010)

My dream


Someone else's work

Act. III

Conan, C/C++ package manager

Conan.io


Development team:

Join us! We are hiring!


Main features

Reuse binaries (if you want)

Integrates with any build system

3rd parties & your libraries

Non intrusive

Key components

Reference

Package ID


name/version:package_id


Reference

'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'

Package ID

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...

Other components

  • Profiles
  • Generators
  • Build helpers

example!

Hello world! application

Consume some libraries ( | )


                            [requires]
                            hellolib/0.1
                            fmt/6.0.0
                        

using CMake


                            [generators]
                            cmake_find_package
                        

Contribute your packages

conanfile.py

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"
                        

conanfile.py

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")
                        

conanfile.py

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")
                        

conanfile.py

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")
                        

conanfile.py

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()
                        

conanfile.py

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)
                        

conanfile.py

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"]
                        

Publish your package (CI)

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
                        

Act. IV

Conan at your company

Major pains

  • Divide your monolith
  • Developers: less to compile
  • DevOps: reduce CI times
  • Traceability and reproducibility

What Conan offers

  • Take advantage of community contributed recipes
  • Package your own libraries
  • Keep using your existing build system
  • Integrate with Artifactory, all your binaries together

C++ ecosystem is ready

and you?

Thank you!

Spread the word