You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-180Lines changed: 0 additions & 180 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,186 +88,6 @@ Although building from source is not recommended, if you really want to do so, s
88
88
* clang-format (for `poac fmt`)
89
89
* clang-tidy (for `poac tidy`)
90
90
91
-
## Usage
92
-
93
-
### Start a new project with Poac
94
-
95
-
The `poac new` command lets you start a new Poac project:
96
-
97
-
```console
98
-
you:~$ poac new hello_world
99
-
Created binary (application) `hello_world` package
100
-
```
101
-
102
-
> [!TIP]
103
-
> If you want to integrate your existing project with Poac, use the `init` command:
104
-
>
105
-
> ```console
106
-
> you:~/your-pj$ poac init
107
-
> Created binary (application) `your-pj` package
108
-
> ```
109
-
>
110
-
> This command just creates a `poac.toml` file not to break your project.
111
-
112
-
### Build the project
113
-
114
-
In most cases, you want to execute the generated binary as well as build the project.
115
-
116
-
```console
117
-
you:~/hello_world$ poac run
118
-
Compiling src/main.cc
119
-
Linking hello_world
120
-
Finished debug target(s) in 0.45386s
121
-
Running poac-out/debug/hello_world
122
-
Hello, world!
123
-
```
124
-
125
-
If you just want to build it, run the `build` command:
126
-
127
-
```console
128
-
you:~/hello_world$ poac build
129
-
Finished debug target(s) in 0.00866317s
130
-
```
131
-
132
-
Poac uses a cache since we executed the command with no changes.
133
-
134
-
> [!TIP]
135
-
> To use a different compiler, you can export a `CXX` environmental variable:
136
-
>
137
-
> ```shell
138
-
>export CXX=g++-13
139
-
>```
140
-
141
-
### Install dependencies
142
-
143
-
Like Cargo does, Poac installs dependencies at build time. Poac currently supports Git and system dependencies. You can use the `poac add`command to add dependencies to your project.
144
-
145
-
The `poac add`command accepts the following arguments:
146
-
147
-
`poac add <package names ....> --<options>`
148
-
149
-
Options:
150
-
- `--sys`: Marks the packages as system dependency (requires the `--version` argument)
151
-
- `--version`: Specify dependency version. Only used with system dependencies
If `tag`, `branch`, or `rev` is unspecified for git dependencies, Poac will use the latest revision of the default branch. System dependency names must be acceptable by `pkg-config`. The version requirement syntax is specified in [src/VersionReq.hpp](https://github.com/poac-dev/poac/blob/main/src/VersionReq.hpp).
163
-
164
-
After adding dependencies, executing the `build` command will install the package and its dependencies.
> Poac currently supports building a project with header-only dependencies.
176
-
> Building with build-required dependencies will be soon supported.
177
-
178
-
### Unit tests
179
-
180
-
You can write unit tests in any source files within the `src` directory. Create a new file like:
181
-
182
-
`src/Lib.cc`
183
-
184
-
```cpp
185
-
intadd(int a, int b) {
186
-
return a + b;
187
-
}
188
-
189
-
#ifdef POAC_TEST
190
-
191
-
# include <cassert>
192
-
193
-
int main() {
194
-
assert(add(1, 2) == 3); // ok
195
-
assert(add(1, 2) == 4); // fail
196
-
}
197
-
198
-
#endif
199
-
```
200
-
201
-
Now, with the `test` command, you can run tests defined within `POAC_TEST`:
202
-
203
-
```console
204
-
you:~/hello_world$ poac test
205
-
Compiling src/Lib.cc
206
-
Linking tests/test_Lib
207
-
Testing Lib
208
-
Assertion failed: (add(1, 2) == 4), function main, file Lib.cc, line 13.
209
-
make: *** [test] Abort trap: 6
210
-
```
211
-
212
-
Unit tests with the `POAC_TEST` macro are useful when testing private functions. Integration testing with the `tests` directory has not yet been implemented.
213
-
214
-
### Run linter
215
-
216
-
Linting source code is essential to protect its quality. Poac supports linting your project by the `lint` command:
217
-
218
-
```console
219
-
you:~/hello_world$ poac lint
220
-
Linting hello_world
221
-
src/main.cc:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
222
-
Done processing src/main.cc
223
-
Total errors found: 1
224
-
Error: `cpplint` exited with status 1
225
-
```
226
-
227
-
> [!TIP]
228
-
> If you do not have `cpplint`, install it with the following command:
229
-
>
230
-
> ```bash
231
-
> pip install cpplint
232
-
>```
233
-
234
-
The `lint`command works without configurations, and Poac would automatically opt out of unwanted lints by adjusting to each project.
235
-
To customize the lint settings, try adding the `[lint.cpplint]` key in your `poac.toml` like [this](https://github.com/poac-dev/poac/blob/cc30b706fb49860903384df56d650a0955aca16c/poac.toml#L67-L83)
236
-
or creating a [`CPPLINT.cfg`](https://github.com/poac-dev/poac/blob/5e7e3792e8818d165149214e94f30958fb0fef66/CPPLINT.cfg) file in the repository root.
237
-
238
-
### Run formatter
239
-
240
-
Poac also supports formatting your source code with `clang-format`. Ensure having installed `clang-format` before running this command.
241
-
242
-
```console
243
-
you:~/hello_world$ poac fmt
244
-
Formatting hello_world
245
-
```
246
-
247
-
> [!NOTE]
248
-
> This command automatically detects what files we need to format to avoid getting bothered by commands like:
249
-
>
250
-
> ```console
251
-
> $ # We need to avoid the `build` dir and such dirs ...
252
-
> $ clang-format ./src/*.cpp -i
253
-
> $ clang-format ./include/**/*.hpp -i
254
-
> $ clang-format ./tests/**/*.cpp -i
255
-
> $ ...
256
-
> ```
257
-
258
-
To customize the format settings, try creating a [`.clang-format`](/.clang-format) file to the repository root.
259
-
260
-
### Run `clang-tidy`
261
-
262
-
Poac also supports running `clang-tidy` on your source code. Ensure having installed `clang-tidy` before running this command.
263
-
264
-
```console
265
-
you:~/hello_world$ poac tidy
266
-
Running clang-tidy
267
-
```
268
-
269
-
You can customize the tidy settings by creating a [`.clang-tidy`](/.clang-tidy) file to the repository root.
270
-
271
91
## Community
272
92
273
93
We use [GitHub Discussions](https://github.com/orgs/poac-dev/discussions).
0 commit comments