Skip to content

Commit 7f15da7

Browse files
easbarbaCOM8
authored andcommitted
add meson example and run docs in a container
1 parent 17daa08 commit 7f15da7

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM docker.io/library/ruby:2.7
2+
ENV BUNDLER_VERSION=2.4.22
3+
RUN gem install bundler:$BUNDLER_VERSION
4+
WORKDIR /app
5+
COPY Gemfile Gemfile.lock .
6+
RUN bundle install
7+
COPY . .
8+
EXPOSE 4000
9+
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]

index.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The only explicit requirements are:
109109
* a `C++17` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let me know
110110
* If you would like to perform https requests `OpenSSL` and its development libraries are required.
111111

112-
## Building cpr - Using vcpkg
112+
### Building cpr - Using vcpkg
113113

114114
You can download and install cpr using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
115115
```Bash
@@ -121,13 +121,64 @@ cd vcpkg
121121
```
122122
The `cpr` port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
123123

124-
## Building cpr - Using Conan
124+
### Building cpr - Using Conan
125125

126126
You can download and install `cpr` using the [Conan](https://conan.io/) package manager. Setup your CMakeLists.txt (see [Conan documentation](https://docs.conan.io/en/latest/integrations/build_system.html) on how to use MSBuild, Meson and others).
127127
An example can be found [**here**](https://github.com/libcpr/example-cmake-conan).
128128

129129
The `cpr` package in Conan is kept up to date by Conan contributors. If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the `conan-center-index` repository.
130130

131+
### Building cpr with Meson
132+
133+
Meson is available in all Linux/BSD and on Marcos in their main repository. Once installed just make a directory `cpr_test` and enter it and run:
134+
135+
``` bash
136+
meson init -l cpp -n cpr-test
137+
```
138+
139+
It creates a .cpp file in the directory root and a meson.build just like this.
140+
141+
Now to make `cpr` available to the project, make a `subprojects` directory and install it with:
142+
143+
``` bash
144+
meson wrap install cpr
145+
```
146+
147+
It creates a meson wrap file in `subprojects/cpr.wrap`, with that we need to it as dependecy in the `meson.build` file:
148+
149+
```conf
150+
project('cpr-test', 'cpp',
151+
version : '0.1',
152+
default_options : ['warning_level=3', 'cpp_std=c++17'])
153+
154+
cpr_dep = dependency('cpr')
155+
156+
exe = executable('cpr-test', 'cpr_test.cpp', dependencies: [ cpr_dep ], install: true)
157+
158+
test('basic', exe)
159+
```
160+
161+
and now just paste the example usage in the top of page in the new .cpp file, do some modification and build/compile the project:
162+
163+
``` bash
164+
meson setup builddir --wipe
165+
meson compile -C builddir
166+
./builddir/cpr-test
167+
```
168+
169+
That's it. For more information check out on the Meson website: https://mesonbuild.com
170+
171+
## Testing `docs` in a container image
172+
173+
With your image builder ready, either [Docker](docker.com) or [Podman](podman.io), build it like:
174+
175+
```
176+
podman build . --tag cpr-image
177+
podman run --rm -it -p 4000:4000 -v ${PWD}:/app -w /app cpr-image
178+
```
179+
180+
Then go to `localhost:4000` with your web browser or [curl](curl.se). That's it!
181+
131182
## Contributing
132183

133184
Please fork this repository and contribute back using [pull requests](https://github.com/libcpr/cpr/pulls). Features can be requested using [issues](https://github.com/libcpr/cpr/issues). All code, comments, and critiques are greatly appreciated.

0 commit comments

Comments
 (0)