Skip to content
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

Add link.dart hook #827

Merged
merged 202 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
5424b7e
Initial commit
mosuem Nov 6, 2023
4993919
Merge branch 'main' into addLinkingScript
mosuem Nov 20, 2023
86108c4
Fixes
mosuem Nov 24, 2023
a739eb8
Merge branch 'main' into addLinkingScript
mosuem Nov 24, 2023
3025ce5
Works now
mosuem Nov 27, 2023
4f77986
Start writing tests
mosuem Nov 27, 2023
f5aef83
Fixing test
mosuem Nov 27, 2023
f8d7498
Merge branch 'main' into addLinkingScript
mosuem Nov 29, 2023
ed23630
Fix merge errors
mosuem Nov 29, 2023
470e356
Fix issues
mosuem Nov 29, 2023
ded78ff
Fix path
mosuem Nov 29, 2023
5ff082f
Fix paths
mosuem Nov 29, 2023
4755b64
Fix paths
mosuem Nov 29, 2023
b376ae1
Rename asset
mosuem Nov 29, 2023
5c205b7
Format
mosuem Nov 29, 2023
30e639f
Add buildType
mosuem Nov 29, 2023
cd92f28
Rename
mosuem Nov 29, 2023
217a340
Remove asset type
mosuem Nov 30, 2023
d7bae1a
Add step serialization
mosuem Nov 30, 2023
e4c5793
Merge branch 'main' into addLinkingScript
mosuem Dec 6, 2023
f916a26
Fix overrides
mosuem Dec 6, 2023
c2f8ecb
Don't check web coverage
mosuem Dec 6, 2023
f0668f1
Merge fixes
mosuem Dec 6, 2023
83c6cdc
Switch to const constructors
mosuem Dec 6, 2023
6bfa254
Don't fail fast
mosuem Dec 6, 2023
e710239
Add override to link
mosuem Dec 6, 2023
a8651cc
Small fixes
mosuem Dec 7, 2023
9d6c1fb
Working on it
mosuem Dec 12, 2023
3edfc66
Merge branch 'main' into addLinkingScript
mosuem Jan 16, 2024
a9967d1
Fixes
mosuem Jan 16, 2024
ffd28a4
More fixes
mosuem Jan 16, 2024
3e68ba5
sort deps
mosuem Jan 16, 2024
137aaed
refactor test
mosuem Jan 17, 2024
3ba833f
Fix bugs
mosuem Jan 17, 2024
771d547
Works now, but ugly
mosuem Jan 18, 2024
5837168
Remove noise
mosuem Jan 18, 2024
13384f8
Fix build.dart
mosuem Jan 18, 2024
43de992
Remove list of assets
mosuem Jan 18, 2024
275ce4c
Add error message
mosuem Jan 19, 2024
fa50a91
Refactorings
mosuem Jan 19, 2024
a5b98cf
Remove step from assets
mosuem Jan 19, 2024
fec0e77
Refactorings
mosuem Jan 19, 2024
aa547cb
Adapt build.dart to existing link.dart
mosuem Jan 19, 2024
7b9dfd9
Merge branch 'main' into addLinkingScript
mosuem Jan 19, 2024
8ed8aa5
Add dep
mosuem Jan 19, 2024
b985808
Adapt docs
mosuem Jan 19, 2024
b3d1d36
Run pub get
mosuem Jan 19, 2024
ee29a5f
Move simple link data
mosuem Jan 19, 2024
5f890f5
Rev versions
mosuem Jan 19, 2024
94a5d42
Add breaking flag to CI
mosuem Jan 19, 2024
6392e45
ignore example
mosuem Jan 19, 2024
e6fed1f
Revert ignore example
mosuem Jan 19, 2024
9aea59c
Add copy flag
mosuem Jan 22, 2024
ab2005e
Fix CLI tests
mosuem Jan 22, 2024
e6091e8
Fix resources
mosuem Jan 22, 2024
e29da52
Fix resources file read
mosuem Jan 22, 2024
84c5335
Add docs
mosuem Jan 22, 2024
f3d82cc
Adapt build.dart and link.dart in the example
mosuem Jan 22, 2024
5da55a0
Don't fail fast
mosuem Jan 22, 2024
dadb61b
Merge branch 'main' into addLinkingScript
mosuem Feb 8, 2024
74e8670
Refactor
mosuem Feb 8, 2024
9cc7330
Merge branch 'main' into addLinkingScript
mosuem Mar 6, 2024
8d1728e
Rename
mosuem Mar 7, 2024
f8f33d6
More rename
mosuem Mar 7, 2024
0b119f3
Cleaning up
mosuem Mar 7, 2024
bf970a9
Simplify
mosuem Mar 7, 2024
b379d40
Give only correct assets
mosuem Mar 7, 2024
2e7c1b4
Simplify even more
mosuem Mar 7, 2024
026f99f
Simplify even more!
mosuem Mar 7, 2024
e7ee258
Simplify even more!!
mosuem Mar 7, 2024
91ec917
Fix
mosuem Mar 7, 2024
9efb650
Works now!
mosuem Mar 7, 2024
e3e71df
Change as per review
mosuem Mar 8, 2024
0016825
Fixes
mosuem Mar 8, 2024
91be8d0
Switch to wip version
mosuem Mar 8, 2024
77aad91
Skip link test for now
mosuem Mar 8, 2024
d46741a
Fix warnings
mosuem Mar 8, 2024
6611f5e
Add publish_to: none
mosuem Mar 8, 2024
bbf64b6
Fix example
mosuem Mar 8, 2024
f5a3feb
Fix issues
mosuem Mar 8, 2024
a280e4d
Fix tests
mosuem Mar 8, 2024
6abb07a
Fix build.dart
mosuem Mar 8, 2024
09beb27
Merge branch 'main' into addLinkingScript
mosuem Mar 21, 2024
86c4ee3
Fix cli_config version
mosuem Mar 21, 2024
50f77fc
Fix issues
mosuem Mar 21, 2024
5ca2b56
Fixes
mosuem Mar 22, 2024
0459384
Fix analyze issues
mosuem Mar 22, 2024
193161c
use build version for link config
mosuem Mar 22, 2024
bea90bb
Fixes
mosuem Mar 22, 2024
c61a18b
Test runs now!
mosuem Mar 22, 2024
136a1a0
Fix tests
mosuem Mar 22, 2024
1dd66ed
Merge branch 'main' into addLinkingScript
mosuem Mar 22, 2024
46afccb
Fix versions
mosuem Mar 22, 2024
5126a60
Fix tests again
mosuem Mar 22, 2024
627d6da
Fix file null test
mosuem Mar 22, 2024
b7e2dd9
Merge branch 'main' into addLinkingScript
mosuem Mar 25, 2024
facf256
Fix tests for windows
mosuem Mar 25, 2024
3e31906
Fix example deps
mosuem Mar 25, 2024
e465564
Remove skip
mosuem Mar 25, 2024
9e22a2d
Fix tests for windows 2
mosuem Mar 25, 2024
d978f11
Fix paths
mosuem Mar 25, 2024
8ab3152
Read uri as files
mosuem Mar 25, 2024
dddab2a
Fix file
mosuem Mar 25, 2024
c27dc43
Fix example
mosuem Mar 25, 2024
858f62e
First changes as per review
mosuem Mar 26, 2024
4530a1a
Merge branch 'main' into addLinkingScript
mosuem Mar 26, 2024
be3965a
Second changes as per review
mosuem Mar 26, 2024
7e6f2cf
Third changes as per review
mosuem Mar 26, 2024
4515729
Fix test
mosuem Mar 26, 2024
9faa86e
Merge branch 'main' into addLinkingScript
mosuem Mar 26, 2024
4df6f2d
Fix link script
mosuem Mar 26, 2024
5c6937d
Works
mosuem Mar 26, 2024
561fcaf
Different classes for different results
mosuem Mar 26, 2024
b193ce0
Add new test
mosuem Mar 27, 2024
8e7de31
Fix analysis issues
mosuem Mar 27, 2024
6670db5
More changes as per review
mosuem Mar 27, 2024
06bb6ca
Remove example
mosuem Mar 27, 2024
dcc81c5
Fix tests
mosuem Mar 27, 2024
762c2d3
Fix workflow
mosuem Mar 27, 2024
ff7696b
Refactor `BuildResult`
mosuem Mar 27, 2024
3e1d50b
Rewire linkoutput
mosuem Mar 27, 2024
da9fda7
Fix pubspecs of examples
mosuem Mar 27, 2024
b868be6
Move examples
mosuem Mar 28, 2024
f1514e5
Fix workflow
mosuem Mar 28, 2024
723b76b
Rename in workflow
mosuem Mar 28, 2024
1481bb0
Fix id
mosuem Mar 28, 2024
364f477
Fix example
mosuem Mar 28, 2024
3ff9396
Do not serialize empty fields
mosuem Mar 28, 2024
e21d1fa
pathseparator helper
mosuem Mar 28, 2024
a4486c5
Add helper to toolchain c
mosuem Mar 28, 2024
3c6ddf9
Resolve nits
mosuem Apr 4, 2024
9bff0b7
Show output when throwing
mosuem Apr 4, 2024
0302ac1
Add example
mosuem Apr 4, 2024
e1979e5
Add dependencies to linkoutput
mosuem Apr 4, 2024
c9f9e30
Adapt cbuilder to linking static libraries
mosuem Apr 4, 2024
1d61a35
Add to workflow
mosuem Apr 4, 2024
348adba
Remove example SDK constraint
mosuem Apr 4, 2024
628b76a
Small changes
mosuem Apr 8, 2024
9d380ec
Fix error
mosuem Apr 8, 2024
90bdc30
Fix error
mosuem Apr 8, 2024
35ce8c8
Fix paths for windows
mosuem Apr 8, 2024
e4c7274
Comment out CI for linking
mosuem Apr 8, 2024
d59ac14
Add docs
mosuem Apr 9, 2024
63bf1fa
Restrict linking assets
mosuem Apr 9, 2024
9ba15f2
Sort into separate file
mosuem Apr 9, 2024
d223fb0
Changes as per review
mosuem Apr 9, 2024
6133521
Address comments
mosuem Apr 9, 2024
103945d
Fix issue
mosuem Apr 9, 2024
f84fa17
Changes as per review
mosuem Apr 10, 2024
c882ee9
Fix tests
mosuem Apr 10, 2024
e3dfa21
Add test
mosuem Apr 10, 2024
b248d3c
Do not delete asset file
mosuem Apr 10, 2024
6800853
Merge branch 'main' into addLinkingScript
mosuem Apr 10, 2024
0f8eb1f
Add licenses
mosuem Apr 10, 2024
0f3e9c3
Add common config
mosuem Apr 11, 2024
58ba0c0
Export HookConfig
mosuem Apr 11, 2024
218bfa6
Fix issues
mosuem Apr 12, 2024
21402dc
Fix API
mosuem Apr 12, 2024
4b0df6a
Make arguments optional
mosuem Apr 12, 2024
c19dc83
Revert linkable assets
mosuem Apr 12, 2024
3955ea9
Export ResourceIdentifiers
mosuem Apr 12, 2024
3d8ed4a
Fix import
mosuem Apr 12, 2024
b88c152
Fix dep
mosuem Apr 12, 2024
c33d5dd
Fix linking id check
mosuem Apr 15, 2024
95a6479
Copy over more files
mosuem Apr 15, 2024
53ab489
Changes as per review
mosuem Apr 16, 2024
c24e422
Unify `configFile`
mosuem Apr 16, 2024
725bdd7
Make resources nullable
mosuem Apr 16, 2024
4903e37
Only expose iterable
mosuem Apr 17, 2024
b9e6c40
Make HookConfig implement the API
mosuem Apr 17, 2024
54d4d4c
Fix testdata
mosuem Apr 17, 2024
451fcd8
Inline linkconfigargs
mosuem Apr 17, 2024
986b9c7
Revert "Inline linkconfigargs"
mosuem Apr 17, 2024
6d1a7ac
Rename resources
mosuem Apr 17, 2024
8515785
Format docs
mosuem Apr 17, 2024
c07cf26
Reduce config usage
mosuem Apr 17, 2024
e569edb
Fixing up buildconfig
mosuem Apr 17, 2024
4a5ad33
Fix args
mosuem Apr 17, 2024
74c7471
Add tests
mosuem Apr 19, 2024
61e70dc
Fix analyze issues
mosuem Apr 19, 2024
2b12373
Fix imports
mosuem Apr 19, 2024
542466a
Add some debugging info to exceptions
mosuem Apr 25, 2024
334a6ce
Add linkModePreference to link config as well
mosuem May 2, 2024
e21c5f0
More changes as per review
mosuem May 2, 2024
9b4855f
Add version to linkoutput
mosuem May 2, 2024
ed4628b
Squashed commit of the following:
mosuem May 2, 2024
2b0272c
Merge branch 'main' into addLinkingScript
mosuem May 2, 2024
987296c
Fix analyzer issues
mosuem May 2, 2024
49914d7
Fix tests
mosuem May 2, 2024
3f5bd87
Remove resources from protocol
mosuem May 2, 2024
bf76046
Add another example
mosuem May 3, 2024
0950ec6
Remove wrong example from CI
mosuem May 3, 2024
49ec442
Add to manifest
mosuem May 3, 2024
884c505
Fix test
mosuem May 3, 2024
14a856c
Move resource test
mosuem May 6, 2024
9e55614
Add argument to drop dylib testcase
mosuem May 6, 2024
50ecb95
Add test project adding assets in link
mosuem May 7, 2024
4e7ba0e
Add to manifest
mosuem May 7, 2024
2532c8b
Rename
mosuem May 7, 2024
12076be
Add todo
mosuem May 7, 2024
60604a2
Refactor add link asset test
mosuem May 8, 2024
e3d9b0e
Adapt casing
mosuem May 8, 2024
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
46 changes: 25 additions & 21 deletions pkgs/native_assets_builder/lib/src/build_runner/build_planner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import 'package:graphs/graphs.dart' as graphs;
import 'package:logging/logging.dart';
import 'package:package_config/package_config.dart';

class NativeAssetsBuildPlanner {
final PackageGraph packageGraph;
class NativeAssetsPlanner {
mosuem marked this conversation as resolved.
Show resolved Hide resolved
final DependencyGraph dependencyGraph;
final List<Package> packagesWithNativeAssets;
final Uri dartExecutable;
final Logger logger;

NativeAssetsBuildPlanner({
required this.packageGraph,
NativeAssetsPlanner({
required this.dependencyGraph,
required this.packagesWithNativeAssets,
required this.dartExecutable,
required this.logger,
});

static Future<NativeAssetsBuildPlanner> fromRootPackageRoot({
static Future<NativeAssetsPlanner> fromRootPackageRoot({
required Uri rootPackageRoot,
required List<Package> packagesWithNativeAssets,
required Uri dartExecutable,
Expand All @@ -37,10 +37,10 @@ class NativeAssetsBuildPlanner {
],
workingDirectory: rootPackageRoot.toFilePath(),
);
final packageGraph =
PackageGraph.fromPubDepsJsonString(result.stdout as String);
return NativeAssetsBuildPlanner(
packageGraph: packageGraph,
final dependencyGraph =
DependencyGraph.fromPubDepsJsonString(result.stdout as String);
return NativeAssetsPlanner(
dependencyGraph: dependencyGraph,
packagesWithNativeAssets: packagesWithNativeAssets,
dartExecutable: dartExecutable,
logger: logger,
Expand All @@ -50,17 +50,18 @@ class NativeAssetsBuildPlanner {
(List<Package> packages, bool success) plan({
String? runPackageName,
}) {
final PackageGraph packageGraph;
final DependencyGraph dependencyGraph;
if (runPackageName != null) {
packageGraph = this.packageGraph.subGraph(runPackageName);
dependencyGraph = this.dependencyGraph.subGraph(runPackageName);
} else {
packageGraph = this.packageGraph;
dependencyGraph = this.dependencyGraph;
}
final packageMap = {
for (final package in packagesWithNativeAssets) package.name: package
};
final packagesToBuild = packageMap.keys.toSet();
final stronglyConnectedComponents = packageGraph.computeStrongComponents();
final stronglyConnectedComponents =
dependencyGraph.computeStrongComponents();
final result = <Package>[];
var success = true;
for (final stronglyConnectedComponent in stronglyConnectedComponents) {
Expand All @@ -83,17 +84,20 @@ class NativeAssetsBuildPlanner {
}
}

class PackageGraph {
/// A graph of package dependencies, encoded as package name -> list of package
mosuem marked this conversation as resolved.
Show resolved Hide resolved
/// dependencies.
class DependencyGraph {
final Map<String, List<String>> map;

PackageGraph(this.map);
DependencyGraph(this.map);

/// Construct a graph from the JSON produced by `dart pub deps --json`.
factory PackageGraph.fromPubDepsJsonString(String json) =>
PackageGraph.fromPubDepsJson(jsonDecode(json) as Map<dynamic, dynamic>);
factory DependencyGraph.fromPubDepsJsonString(String json) =>
DependencyGraph.fromPubDepsJson(
jsonDecode(json) as Map<dynamic, dynamic>);

/// Construct a graph from the JSON produced by `dart pub deps --json`.
factory PackageGraph.fromPubDepsJson(Map<dynamic, dynamic> map) {
factory DependencyGraph.fromPubDepsJson(Map<dynamic, dynamic> map) {
final result = <String, List<String>>{};
final packages = map['packages'] as List<dynamic>;
for (final package in packages) {
Expand All @@ -104,7 +108,7 @@ class PackageGraph {
.toList();
result[name] = dependencies;
}
return PackageGraph(result);
return DependencyGraph(result);
}

Iterable<String> neighborsOf(String vertex) => map[vertex] ?? [];
Expand All @@ -114,12 +118,12 @@ class PackageGraph {
List<List<String>> computeStrongComponents() =>
graphs.stronglyConnectedComponents(vertices, neighborsOf);

PackageGraph subGraph(String rootPackageName) {
DependencyGraph subGraph(String rootPackageName) {
final subgraphVertices = [
...graphs.transitiveClosure(vertices, neighborsOf)[rootPackageName]!,
rootPackageName,
];
return PackageGraph({
return DependencyGraph({
for (final vertex in map.keys)
if (subgraphVertices.contains(vertex))
vertex: [
Expand Down
Loading
Loading