Skip to content

[native_assets_cli] Cleanup JSON: env_script and env_script_arguments #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@
"cc": {
"$ref": "../../../../hooks/doc/schema/shared/shared_definitions.schema.json#/definitions/absolutePath"
},
"env_script": {
"$ref": "../../../../hooks/doc/schema/shared/shared_definitions.schema.json#/definitions/absolutePath"
},
"env_script_arguments": {
"type": "array",
"items": {
"type": "string"
}
},
"ld": {
"$ref": "../../../../hooks/doc/schema/shared/shared_definitions.schema.json#/definitions/absolutePath"
},
Expand Down
2 changes: 0 additions & 2 deletions pkgs/code_assets/test/data/build_input_windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"c_compiler": {
"ar": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\Hostx64\\x64\\lib.exe",
"cc": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\Hostx64\\x64\\cl.exe",
"env_script": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat",
"env_script_arguments": [],
"ld": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\Hostx64\\x64\\link.exe",
"windows": {
"developer_command_prompt": {
Expand Down
8 changes: 0 additions & 8 deletions pkgs/code_assets/test/schema/schema_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ _codeFieldsWindows({
required Party party,
}) => <(List<Object>, void Function(ValidationResults result))>[
if (inputOrOutput == InputOrOutput.input && hook == Hook.build) ...[
(
[..._codeConfigPath, 'c_compiler', 'env_script'],
expectOptionalFieldMissing,
),
(
[..._codeConfigPath, 'c_compiler', 'env_script_arguments'],
expectOptionalFieldMissing,
),
([..._codeConfigPath, 'c_compiler', 'windows'], expectRequiredFieldMissing),
(
[..._codeConfigPath, 'c_compiler', 'windows', 'developer_command_prompt'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ extension CCompilerConfigSyntax on CCompilerConfig {
ar: archiver,
cc: compiler,
ld: linker,
envScript: _windows?.developerCommandPrompt?.script,
envScriptArguments: _windows?.developerCommandPrompt?.arguments,
windows: _windows?.toSyntax(),
);

Expand Down
25 changes: 0 additions & 25 deletions pkgs/native_assets_cli/lib/src/code_assets/syntax.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,11 @@ class CCompilerConfig extends JsonObject {
CCompilerConfig({
required Uri ar,
required Uri cc,
required Uri? envScript,
required List<String>? envScriptArguments,
required Uri ld,
required Windows? windows,
}) : super() {
_ar = ar;
_cc = cc;
_envScript = envScript;
_envScriptArguments = envScriptArguments;
_ld = ld;
_windows = windows;
json.sortOnKey();
Expand All @@ -152,25 +148,6 @@ class CCompilerConfig extends JsonObject {

List<String> _validateCc() => _reader.validatePath('cc');

Uri? get envScript => _reader.optionalPath('env_script');

set _envScript(Uri? value) {
json.setOrRemove('env_script', value?.toFilePath());
}

List<String> _validateEnvScript() =>
_reader.validateOptionalPath('env_script');

List<String>? get envScriptArguments =>
_reader.optionalStringList('env_script_arguments');

set _envScriptArguments(List<String>? value) {
json.setOrRemove('env_script_arguments', value);
}

List<String> _validateEnvScriptArguments() =>
_reader.validateOptionalStringList('env_script_arguments');

Uri get ld => _reader.path$('ld');

set _ld(Uri value) {
Expand Down Expand Up @@ -202,8 +179,6 @@ class CCompilerConfig extends JsonObject {
...super.validate(),
..._validateAr(),
..._validateCc(),
..._validateEnvScript(),
..._validateEnvScriptArguments(),
..._validateLd(),
..._validateWindows(),
];
Expand Down
19 changes: 5 additions & 14 deletions pkgs/native_assets_cli/test/code_assets/config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void main() async {
// check the nested key.
Map<String, Object> inputJson({
String hookType = 'build',
bool includeDeprecated = false,
OS targetOS = OS.android,
}) {
final codeConfig = {
Expand All @@ -58,8 +57,6 @@ void main() async {
'ar': fakeAr.toFilePath(),
'ld': fakeLd.toFilePath(),
'cc': fakeClang.toFilePath(),
if (includeDeprecated) 'env_script': fakeVcVars.toFilePath(),
if (includeDeprecated) 'env_script_arguments': ['arg0', 'arg1'],
'windows': {
'developer_command_prompt': {
'arguments': ['arg0', 'arg1'],
Expand Down Expand Up @@ -146,11 +143,11 @@ void main() async {
),
);
final input = BuildInput(inputBuilder.json);
expect(input.json, inputJson(includeDeprecated: true));
expect(input.json, inputJson());
expectCorrectCodeConfig(input.config.code);
});

test('BuildInput from json without deprecated keys', () {
test('BuildInput from json ', () {
for (final targetOS in [OS.android, OS.iOS, OS.macOS]) {
final input = BuildInput(inputJson(targetOS: targetOS));
expect(input.packageName, packageName);
Expand Down Expand Up @@ -191,20 +188,14 @@ void main() async {
),
);
final input = LinkInput(inputBuilder.json);
expect(input.json, inputJson(hookType: 'link', includeDeprecated: true));
expect(input.json, inputJson(hookType: 'link'));
expectCorrectCodeConfig(input.config.code);
expect(input.assets.encodedAssets, assets);
});

test('LinkInput from json without deprecated keys', () {
test('LinkInput from json', () {
for (final targetOS in [OS.android, OS.iOS, OS.macOS]) {
final input = LinkInput(
inputJson(
includeDeprecated: false,
targetOS: targetOS,
hookType: 'link',
),
);
final input = LinkInput(inputJson(targetOS: targetOS, hookType: 'link'));
expect(input.packageName, packageName);
expect(input.packageRoot, packageRootUri);
expect(input.outputDirectoryShared, outputDirectoryShared);
Expand Down
Loading