-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native_assets_*] Error on conflict dylib names (#1512)
- Loading branch information
Showing
12 changed files
with
213 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:logging/logging.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../helpers.dart'; | ||
import 'helpers.dart'; | ||
|
||
const Timeout longTimeout = Timeout(Duration(minutes: 5)); | ||
|
||
void main() async { | ||
test('conflicting dylib name', timeout: longTimeout, () async { | ||
await inTempDir((tempUri) async { | ||
await copyTestProjects(targetUri: tempUri); | ||
final packageUri = tempUri.resolve('native_add_duplicate/'); | ||
|
||
await runPubGet( | ||
workingDirectory: packageUri, | ||
logger: logger, | ||
); | ||
|
||
{ | ||
final logMessages = <String>[]; | ||
final result = await build( | ||
packageUri, | ||
createCapturingLogger(logMessages, level: Level.SEVERE), | ||
dartExecutable, | ||
); | ||
final fullLog = logMessages.join('\n'); | ||
expect(result.success, false); | ||
expect( | ||
fullLog, | ||
contains('Duplicate dynamic library file name'), | ||
); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
pkgs/native_assets_builder/test_data/native_add_duplicate/hook/build.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:logging/logging.dart'; | ||
import 'package:native_assets_cli/native_assets_cli.dart'; | ||
import 'package:native_toolchain_c/native_toolchain_c.dart'; | ||
|
||
void main(List<String> arguments) async { | ||
await build(arguments, (config, output) async { | ||
final packageName = config.packageName; | ||
const duplicatedPackageName = 'native_add'; | ||
final cbuilder = CBuilder.library( | ||
name: duplicatedPackageName, | ||
assetName: 'src/${packageName}_bindings_generated.dart', | ||
sources: [ | ||
'src/$duplicatedPackageName.c', | ||
], | ||
); | ||
await cbuilder.run( | ||
config: config, | ||
output: output, | ||
logger: Logger('') | ||
..level = Level.ALL | ||
..onRecord.listen((record) { | ||
print('${record.level.name}: ${record.time}: ${record.message}'); | ||
}), | ||
); | ||
}); | ||
} |
26 changes: 26 additions & 0 deletions
26
pkgs/native_assets_builder/test_data/native_add_duplicate/pubspec.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: native_add_duplicate | ||
description: Introduces the same dylib as native_add, to introduce a conflict. | ||
version: 0.1.0 | ||
|
||
publish_to: none | ||
|
||
environment: | ||
sdk: '>=3.3.0 <4.0.0' | ||
|
||
dependencies: | ||
logging: ^1.1.1 | ||
native_add: | ||
path: ../native_add/ | ||
# native_assets_cli: ^0.7.3 | ||
native_assets_cli: | ||
path: ../../../native_assets_cli/ | ||
# native_toolchain_c: ^0.5.3 | ||
native_toolchain_c: | ||
path: ../../../native_toolchain_c/ | ||
|
||
dev_dependencies: | ||
ffigen: ^8.0.2 | ||
lints: ^3.0.0 | ||
some_dev_dep: | ||
path: ../some_dev_dep/ | ||
test: ^1.23.1 |
9 changes: 9 additions & 0 deletions
9
pkgs/native_assets_builder/test_data/native_add_duplicate/src/native_add.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#include "native_add.h" | ||
|
||
int32_t add(int32_t a, int32_t b) { | ||
return a + b; | ||
} |
13 changes: 13 additions & 0 deletions
13
pkgs/native_assets_builder/test_data/native_add_duplicate/src/native_add.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#include <stdint.h> | ||
|
||
#if _WIN32 | ||
#define MYLIB_EXPORT __declspec(dllexport) | ||
#else | ||
#define MYLIB_EXPORT | ||
#endif | ||
|
||
MYLIB_EXPORT int32_t add(int32_t a, int32_t b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters