In this week, I uploaded my SSGifier to a C++ package manager named conan
. It was quite a lot of learning I had this week in trying to understand how does conan work, how do I integrate it into my project, and how do I encapsulate and upload a package of my project to remote server for other users to use. However, conan only provides packages as libraries for other projects to use, it is not like pip in python where we can install packages and use it standalone. That is being said, we need to createa conan project to use the package. To make sure that my instruction is easy to read and covers all needed requirements, I asked Piotr to install it with the only instruction from my README.md, and he later found out he has no difficulty installing my package.
How did I set up conan?
To set up conan, there are few steps need to be followed:
- Install python first because conan relies on python to run its script.
- Use
pip install conan
to install conan. - In the SSGifier project folder, create a folder named
package
and create a foldersrc
insidepackage
and put all source files of SSGifier to thepackage/src
folder. - In
package
folder, use$ conan new mypackage/1.0 -t
to generate a package template for us to use. - Edit the generated
conanfile.py
and add the source files that to be packed into the package into the functiondef package(self)
. For example,self.copy("*.h", dst="src", src="src")
. - After finished setting up the
conanfile.py
, we need to register an account here to host our packages. - Follow the instruction to add the remote package source to conan.
- In the
package
folder, useconan upload . -r put-your-remote-name-here --all
to upload the package to remote. Now the package is uploaded to the remote server.
How to use the package?
You can also use SSGifier in your projectas as a library. To use it you need to do following:
- Downlaod & install
Conan
from here andclang
from here. - Create a
conanfile.txt
inside your project and addSSGifier/1.0.0
in the category of[requires]
toconanfile.txt
. Click to see official documents. You can use this template:
[requires]
SSGifier/1.0.0
[generators]
cmake
- Edit
conan.conf
file in the locationC:\Users\<your user name>\.conan
and addrevisions_enabled = 1
to[general]
. - Add this remote repository to conan by using this command
conan remote add tommy-conan-local https://tommyliu.jfrog.io/artifactory/api/conan/tommy-conan-local
- Add credential information to this repository by using this command
conan user -p AKCp8nHPJwRCr2my24TiMaikQgQUW4e3xRbqsiGw45j9nPfPdLWEREYigcMLLW4pQtqg18n8b -r tommy-conan-local lt19930320@gmail.com
. - Go to the directory of you project which you created in step 2(make sure conaninfo.txt), install SSGifier by using
conan install . -r tommy-conan-local
- Go to
C:\Users\<your user name>\.conan\data\SSGifier\1.0.0\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\src
to find the source file. - Compile these code. For gcc, use
g++ -std=c++17 main.cpp Utils.cpp ArgumentQueue.cpp FileProcessor.cpp MessagePrinter.cpp
, for clang, useclang++ -std=c++17 main.cpp Utils.cpp ArgumentQueue.cpp FileProcessor.cpp MessagePrinter.cpp
. - After compilation, a binrary executatable of SSGifier will be generated with the name of
a.exe
.
Top comments (0)