Skip to content

Commit e7d31b9

Browse files
committed
document fpm clean altogether
1 parent df54054 commit e7d31b9

File tree

1 file changed

+92
-20
lines changed

1 file changed

+92
-20
lines changed

pages/how-to/selective-cleaning.md

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,99 @@
1-
# Selective cleaning with fpm
1+
# Cleaning build artifacts with fpm
2+
3+
The `fpm clean` command allows you to remove build artifacts to free up disk space or ensure a fresh build. This guide covers both general cleaning and selective cleaning options.
4+
5+
## Overview
6+
7+
By default, `fpm clean` prompts for confirmation before deleting directories in the `build/` folder while preserving dependencies. The command supports several modes of operation:
8+
9+
- **Interactive cleaning** (default): Prompts for confirmation
10+
- **Automatic cleaning**: Skip prompts with `--skip` or `--all`
11+
- **Selective cleaning** *(fpm v0.14.0+)*: Target specific executable types
12+
- **Registry cache cleaning**: Remove cached registry data
13+
14+
## General cleaning options
15+
16+
### Default behavior
17+
18+
```bash
19+
fpm clean
20+
```
21+
22+
Prompts for confirmation before deleting build artifacts, excluding dependencies. This is the safest option for regular use.
23+
24+
### Skip confirmation, preserve dependencies
25+
26+
```bash
27+
fpm clean --skip
28+
```
29+
30+
Deletes build directories without prompting but preserves dependency builds. Useful in automated scripts where you want to clean your project but keep external dependencies intact.
31+
32+
### Clean everything including dependencies
33+
34+
```bash
35+
fpm clean --all
36+
```
37+
38+
Deletes all build directories without prompting, including dependencies. Use this when you need a completely fresh build environment or when dependency issues require rebuilding everything from scratch.
39+
40+
### Clean registry cache
41+
42+
```bash
43+
fpm clean --registry-cache
44+
```
45+
46+
Removes cached registry data. Useful when registry metadata becomes stale or when troubleshooting package resolution issues.
47+
48+
### Custom configuration file
49+
50+
```bash
51+
fpm clean --config-file /path/to/config.toml
52+
```
53+
54+
Use a custom global configuration file location for the clean operation.
55+
56+
## Selective cleaning options
257

358
:::{note}
459
Available since fpm v0.14.0
560
:::
661

7-
The `fpm clean` command allows you to remove build artifacts to free up disk space or ensure a fresh build. By default, `fpm clean` removes all build artifacts, but you can use selective cleaning to remove only specific types of executables, which speeds up recompilation by preserving other build outputs.
8-
9-
## Command overview
62+
Selective cleaning allows you to remove only specific types of executables, which speeds up recompilation by preserving other build outputs.
1063

11-
The selective cleaning feature provides three flags to target specific executable types:
64+
### Available selective cleaning flags
1265

1366
- `--test`: Clean only test executables
1467
- `--apps`: Clean only application executables
1568
- `--examples`: Clean only example executables
1669

17-
## Basic usage
70+
### Selective cleaning examples
1871

19-
### Clean test executables only
72+
#### Clean test executables only
2073

2174
```bash
2275
fpm clean --test
2376
```
2477

2578
This removes only the compiled test executables while preserving application executables, example executables, and all object files. Useful when you've modified test code and want to ensure tests are rebuilt from scratch.
2679

27-
### Clean application executables only
80+
#### Clean application executables only
2881

2982
```bash
3083
fpm clean --apps
3184
```
3285

3386
This removes only the compiled application executables while preserving test executables, example executables, and object files. Useful when you've made changes that affect only your main applications.
3487

35-
### Clean example executables only
88+
#### Clean example executables only
3689

3790
```bash
3891
fpm clean --examples
3992
```
4093

4194
This removes only the compiled example executables while preserving application and test executables, and object files. Useful when working on documentation examples.
4295

43-
## Combining flags
96+
### Combining selective flags
4497

4598
You can combine multiple flags to clean several types of executables simultaneously:
4699

@@ -52,9 +105,11 @@ fpm clean --test --apps
52105
fpm clean --test --apps --examples
53106
```
54107

55-
## Practical use cases
108+
## Use cases and workflows
109+
110+
### Common scenarios
56111

57-
### Debugging failing tests
112+
#### Debugging failing tests
58113

59114
When tests are failing and you suspect cached executables might be the issue:
60115

@@ -65,7 +120,7 @@ fpm test
65120

66121
This ensures test executables are rebuilt from scratch while preserving your application builds.
67122

68-
### Preparing for release
123+
#### Preparing for release
69124

70125
Before building release versions of your applications:
71126

@@ -98,14 +153,31 @@ fpm clean --apps # If working on applications
98153
fpm clean --examples # If working on examples
99154
```
100155

101-
## Comparison with full cleaning
156+
## Command reference
157+
158+
### Complete option summary
159+
160+
| Command | What gets removed | Dependencies | Prompts | Use when |
161+
|---------|------------------|--------------|---------|----------|
162+
| `fpm clean` | All build artifacts | Preserved | Yes | Safe interactive cleaning |
163+
| `fpm clean --skip` | All build artifacts | Preserved | No | Automated scripts, preserve deps |
164+
| `fpm clean --all` | All build artifacts | Removed | No | Fresh start, dependency issues |
165+
| `fpm clean --registry-cache` | Registry cache only | N/A | No | Registry troubleshooting |
166+
| `fpm clean --test` | Test executables only | Preserved | Variable | Test-specific issues |
167+
| `fpm clean --apps` | Application executables only | Preserved | Variable | Application changes |
168+
| `fpm clean --examples` | Example executables only | Preserved | Variable | Documentation updates |
102169

103-
| Command | What gets removed | Use when |
104-
|---------|------------------|----------|
105-
| `fpm clean` | All build artifacts | Starting completely fresh, major build system changes |
106-
| `fpm clean --test` | Test executables only | Test-specific issues, modified test code |
107-
| `fpm clean --apps` | Application executables only | Application-specific changes |
108-
| `fpm clean --examples` | Example executables only | Documentation updates, example modifications |
170+
### Combining options
171+
172+
You can combine general and selective cleaning options:
173+
174+
```bash
175+
# Clean test and apps without prompting, preserve dependencies
176+
fpm clean --skip --test --apps
177+
178+
# Clean everything including dependencies and registry cache
179+
fpm clean --all --registry-cache
180+
```
109181

110182
## Performance benefits
111183

0 commit comments

Comments
 (0)