OSD600 Lab 10
Tags: beginners, opensource, cpp
Published: 2022-11-26 05:50:19

## The first try
I originally planned to use [build2](https://build2.org/), but I found it to be much more complex than I expected. There was plenty of documentation to read for build2. [The main documentation](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml) was all about the setup process, but there were also documentation pages for [building](https://build2.org/build2/doc/build2-build-system-manual.xhtml), [testing](https://build2.org/build2/doc/build2-testscript-manual.xhtml), and [package management](https://build2.org/bpkg/doc/build2-package-manager-manual.xhtml).

## The second try
As a result, I decided to use [Conan](https://conan.io/) instead. I installed Conan through pip, which requires Python. After installing Python, I ran 
```
pip install conan
```
This installed Conan for use in the command-line terminal. After installing Conan, I had to add a `conanfile.py` file.

```
conan new SauSaGe/1.0.0
```
The file has a bunch of fields with dummy info that need to be filled in. The next step requires a `CMakeLists.txt` file as well as [CMake](https://cmake.org/), of which how to create is [a process of its own](https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html#exercise-1-building-a-basic-project).

The next step is building the package.

```
conan create . SauSaGe/beta
```
This will build the package in `~/.conan/data` directory, which will contain the source code as well as the executable file. 

## Releasing
I used [GitLab](https://about.gitlab.com/) for this step, which requires a GitLab account. I set up an account and created a project. After that, go to the project's page to obtain the project id. Now you can add your remote to your list of remotes in Conan run

```
conan remote add <remote-name> https://gitlab.com/api/v4/projects/<project-id>/packages/conan
```
You also need to log in to to upload your package, this requires an access token, which can be found on GitLab in **Edit Profile -> Access Tokens**. After you create your access token, you can run this

```
conan user <gitlab-user> -r gitlab -p <access-token>
```
With the remote in your list, and your GitLab account logged into, you can finally upload your package. 

```
conan upload SauSaGe/1.0.0@SauSaGe/beta --all
```

## Released
My package is [here](https://gitlab.com/rudychung/SauSaGe/-/packages/11004579), after a few hours of research. 
To install using this package registry, create a `SauSaGe` directory containing a `conanfile.txt` file, the contents of which are
```
[requires]
SauSaGe/1.0.0@SauSaGe/beta

[generators]
make
```
Then, install the package
```
 conan install SauSaGe --remote=<remote-name>
```
I did not have to change much about my code to set it up for the package registry. Although I did need to install a variety of tools to go through the process. The whole process only added 2 files to my project.

## Testing
I had a classmate test test the code through the package registry. There were some struggles due to having to install Python, Conan and CMake. There were also some issues with adding the applications to PATH environment variable in order to run all these tools through the command-line terminal. But overall, it went smoothly.