Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp committed Aug 30, 2023
1 parent 78dc165 commit dfcea13
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build_tool/lib/src/artifacts_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ArtifactProvider {

Future<Map<Target, List<Artifact>>> _getPrecompiledArtifacts(
List<Target> targets) async {
if (userOptions.allowPrecompiledBinaries == false) {
if (userOptions.usePrecompiledBinaries == false) {
_log.info('Precompiled binaries are disabled');
return {};
}
Expand Down
20 changes: 10 additions & 10 deletions build_tool/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,34 +230,34 @@ class CargokitCrateOptions {
class CargokitUserOptions {
// When Rustup is installed always build locally unless user opts into
// using precompiled binaries.
static bool defaultAllowPrecompiledBinaries() {
static bool defaultUsePrecompiledBinaries() {
return Rustup.executablePath() == null;
}

CargokitUserOptions({
required this.allowPrecompiledBinaries,
required this.usePrecompiledBinaries,
required this.verboseLogging,
});

CargokitUserOptions._()
: allowPrecompiledBinaries = defaultAllowPrecompiledBinaries(),
: usePrecompiledBinaries = defaultUsePrecompiledBinaries(),
verboseLogging = false;

static CargokitUserOptions parse(YamlNode node) {
if (node is! YamlMap) {
throw SourceSpanException('Cargokit options must be a map', node.span);
}
bool allowPrecompiledBinaries = defaultAllowPrecompiledBinaries();
bool usePrecompiledBinaries = defaultUsePrecompiledBinaries();
bool verboseLogging = false;

for (final entry in node.nodes.entries) {
if (entry.key case YamlScalar(value: 'allow_precompiled_binaries')) {
if (entry.key case YamlScalar(value: 'use_precompiled_binaries')) {
if (entry.value case YamlScalar(value: bool value)) {
allowPrecompiledBinaries = value;
usePrecompiledBinaries = value;
continue;
}
throw SourceSpanException(
'Invalid value for "allow_precompiled_binaries". Must be a boolean.',
'Invalid value for "use_precompiled_binaries". Must be a boolean.',
entry.value.span);
} else if (entry.key case YamlScalar(value: 'verbose_logging')) {
if (entry.value case YamlScalar(value: bool value)) {
Expand All @@ -269,12 +269,12 @@ class CargokitUserOptions {
entry.value.span);
} else {
throw SourceSpanException(
'Unknown cargokit option type. Must be "allow_precompiled_binaries" or "verbose_logging".',
'Unknown cargokit option type. Must be "use_precompiled_binaries" or "verbose_logging".',
entry.key.span);
}
}
return CargokitUserOptions(
allowPrecompiledBinaries: allowPrecompiledBinaries,
usePrecompiledBinaries: usePrecompiledBinaries,
verboseLogging: verboseLogging,
);
}
Expand All @@ -301,6 +301,6 @@ class CargokitUserOptions {
return CargokitUserOptions._();
}

final bool allowPrecompiledBinaries;
final bool usePrecompiledBinaries;
final bool verboseLogging;
}
4 changes: 2 additions & 2 deletions build_tool/test/options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ precompiled_binaries:

test('parseCargokitUserOptions', () {
const yaml = '''
allow_precompiled_binaries: false
use_precompiled_binaries: false
verbose_logging: true
''';
final options = CargokitUserOptions.parse(loadYamlNode(yaml));
expect(options.allowPrecompiledBinaries, false);
expect(options.usePrecompiledBinaries, false);
expect(options.verboseLogging, true);
});
}
4 changes: 2 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ verbose_logging: true
# Opts out of using precompiled binaries. If crate has configured
# and deployed precompiled binaries, these will be by default used whenever Rustup
# is not installed. With `allow_precompiled_binaries` set to false, the build will
# is not installed. With `use_precompiled_binaries` set to false, the build will
# instead be aborted prompting user to install Rustup.
allow_precompiled_binaries: false
use_precompiled_binaries: false
```
## Detecting Rustup
Expand Down
2 changes: 1 addition & 1 deletion docs/precompiled_binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To streamline plugin usage, it is possible for Cargokit to use precompiled binar

This is how the process of using precompiled binaries looks during the build on developer machine:

1. Cargokit checks if there is `cargokit_options.yaml` file in the root folder of target application. If there is one, it will be checked for `allow_precompiled_binaries` options to see if user opted out of using precompiled binaries. In which case Cargokit will insist on building from source. Cargokit will also build from source if the configuration file is absent, but user has Rustup installed.
1. Cargokit checks if there is `cargokit_options.yaml` file in the root folder of target application. If there is one, it will be checked for `use_precompiled_binaries` options to see if user opted out of using precompiled binaries. In which case Cargokit will insist on building from source. Cargokit will also build from source if the configuration file is absent, but user has Rustup installed.

2. Cargokit checks if there is `cargokit_options.yaml` file placed in the Rust crate. If there is one, it will be checked for `precompiled_binaries` section to see if crate supports precompiled binaries. The configuration section must contain a public key and URL prefix.

Expand Down

0 comments on commit dfcea13

Please sign in to comment.