Notes on Conan
I will continuously update this article as soon as I have something in my mind
Overview
Conan provides a well-established client to ease the use of packages. Comparing to Nuget, Conan offers ability to automatically create, deploy and install packages, which is much better than Nuget. I have used Nuget for two years in my previous company, it proved to be a nightmare to use Nuget(you need to write your own script to install the downloaded packages to the right location for Nuget).
Install by pip
For windows need to call chcp 866
to change the code page to 866 in command line otherwise wrapt cannot be installed successfully.
While calling conan on command line, wrapt.wrapper
module cannot be found error will be reported. No solution yet.
It seems that the installer for Windows x86_x64 works fine. I can use conan command line without any problem.
Bincrafter and adding remote
Literally, bincrafter sounds like a game. But it is a public repository for Conan with much more packages than conan-center. To use bincrafter the correct URL needs to be added. The syntax is quite similar as Git's:
conan remote add bincrafters "https://api.bintray.com/conan/bincrafters/public-conan"
More information on how to use Bincrafter could be found on this. I just successfully downloaded boost::asio
. The good news is that you do not need to download the whole boost library, just the parts you need for your project.
Integration
My way to use the Conan is to create a pkg package under the project folder. Normally my projects have the following folder structure:
MyProject
|--src
|--test
|-- unit test
|-- system test
|--pkg
src folder contains all source codes, test folder all test cases, ** pkg** folder Conan package recipes. In this way, I could easily create a Conan package and manage the corresponding recipes in Git along with the source codes.
Packaging
To create your own package, you need to first create the package recipe by calling command conan new
. About the using of the usage of the conan command could be found on official site. After the running of conan new
command, the recipe file - conanfile.py will be generate, say, in my case, it locates in pkg folder. However, the conanfile.py is just some default settings, if you want it to work as your expectation, you need to tweak it a bit:
- You need to correct the path, including the git repo path, source folder path, etc. The default path is Hello.
- You need to add requires manually if your package depends on other conan packages. At the beginning I expected the conan could automatically analyze the conanfile.txt, but it would't.
Uploading
Because my team only has 5 members(a really small team), we could use the officially provided conan_server as local package server. I installed a Ubuntu server on VirtualBox and conan_server as well . Just enter conan_server
the server will be launched at port 9300. Tweaks needs to be done to assure the working of conan_server:
- Configure the port mapping between VBox and its host
- Edit
~/.conan_server/server.conf
, changing Write Permission to allow the write access, changing host_name to the IP of VBox host. - You can add your own account instead of default demo:demo, but make sure configure the write permission and read permission correctly.
网友评论