Benefits of using Conan in software development

Our client's team started working on a new service application. Preparation of CI/CD process for it was required. The process contained some repeatable manual steps for each new service and during maintenance. It took up to three days for this process to be completed. Infogain's team saw opportunity for improvement.

Better quality code and optimizing costs are top priorities for software developers. Finding the right tools to streamline projects can be a game-changer when using C++. Conan, a package manager, enhances the development, build, and deployment process. It also helps achieve optimal results and saves time.

Let's discuss how this tool can be an asset for software developers.

The package manager as an important tool

In recent years, C++ has experienced significant growth and dynamic development. Beyond periodic language standard updates and improvements to the Standard Template Library (STL), the C++ ecosystem has seen the emergence of powerful development tools dedicated to enhancing code quality. These tools include static code analyzers, code sanitizers, and performance analyzers.

One such important tool is the package manager. While package managers have long been a staple in other programming languages, they have been underutilized in C++. Notable options, such as NuGet, Vcpkg, and Conan, offer solutions for managing dependencies and simplifying library preparation during deployment.

Conan has gained recognition as a standard choice among developers for its efficiency and versatility. Conan's availability on multiple platforms, compatibility with any build systems, and numerous external libraries make it a compelling option. If you want to know more, please visit this page https://conan.io

Benefits of using Conan in the CI/CD process

When establishing the CI/CD process for a new service, there are inevitably some inefficiencies and areas for improvement. Creating a new Docker image for each new service and the manual installation of service-specific dependencies by developers was the norm. These images also required ongoing maintenance as new dependencies emerge in the future.

benefits of using conan

Instead of maintaining individual Docker images for each service, a unified Docker image for C++ projects, complete with the Conan application, is more advantageous. This image, when employed during the Jenkins job execution, would fetch the project's specific dependencies from a conanfile.py located within the project repository.

This solution fosters standardization across different projects' CI processes, enhancing consistency and efficiency.

When a developer using Conan in the CI/CD process can count on the following benefits:

  • No need to prepare Docker image for each new service, we have one able to build them all.
  • Less time preparing and maintaining CI/CD processes.
  • Automatic resolve and download external dependencies.
  • Automation and simplification of processes of preparing dependencies for deployment.
  • Faster transition to new operating system versions.

benefits of using conan

How Conan can improve your development environment preparation

The same base Docker image with Conan used in CI/CD process can be used by a Python script, which will automatically prepare local development environment on developer PC. It just automatically installs and starts the Docker service on local PC, download base Docker image, install a ssh key to access the git repository, also install some tools which will help with development and run a Local Development Environment container.

The developer needs just to download a C++ project from git repository and call command conan build. Thanks to the specification file placed in repository, Conan will automatically provide all required dependencies for our environment and trigger compilation of your project.

Now we have one common development environment in which we can code any C++ project that uses Conan instead of preparing a new one for each new project.

benefits of using conan

So, thanks to this we have:

Cost savings

Developers can work without a virtual machine from a cloud such as Google Cloud Platform (GCP). While this may not be feasible for big projects due to computing limitations, it is invaluable for small and mid-sized projects. Implementing this solution can translate into cost savings for the company.

Effortless environment setup

Just run the Python script.

Saving time

The Python script takes care of the main tasks of setting up the work environment, allowing developers to focus on coding and development rather than dealing with environment setup intricacies.

Environment consistency and ease of use

The development environment can be employed across various C++ projects using the same build system and compiler. New images with a newer version of the compiler can be provided as required. This consistency minimizes the risk of compatibility.

Local success translates to pipeline success

When developers build a project locally, they operate in the same environment used during the CI/CD process. This alignment ensures that if a build succeeds locally, it is highly likely to succeed in the CI pipeline, providing an extra layer of confidence in the code.

Collaborative environment

All team members work in an identical environment, eliminating discrepancies and promoting better collaboration. This reduces troubleshooting, enabling the team to focus on the task.

Future opportunities

The versatility of this environment opens the door for many improvement possibilities. Adding static code analyzers like Clang-Tidy, preparing the environment for Fuzz testing, code debugging using IDEs, or staying updated with the latest compiler versions and language standards are just some of the many enhancements possible, which, in turn, can lead to higher software quality.

Integrating a package manager into your software development process offers an array of advantages, from time and cost savings to enhanced consistency and collaboration. It simplifies the development environment setup and paves the way for continuous improvements, ensuring the development process remains agile, efficient, and resilient.

About the Author

Maciej Lamparski

Maciej Lamparski

Maciej Lamparski is a Senior Software Systems Engineer at Infogain. He has over 16 years of experience in software development, mostly as a C++ developer in public transport industries or with CAD application extensions.

Maciej has been working for a travel technology company client for over two years. He is passionate about designing stable and simple solutions and implementing them in the form of clean code. He also likes to follow the ecosystem of C++ tools and use them in his work to simplify the code development process and improve its quality.