Skip to content

How to make an aop package (aspectd) in a decent way? #36738

@kangwang1988

Description

@kangwang1988

This issue is related to #35803

Recently, I've developed a package aiming at implement the AOP(aspect oriented programming) feature for dart based on kernel-to-kernel transformation which is available at: https://github.com/alibaba-flutter/aspectd

A design diagram is given below:
Aspectd Diagram

Though it is expected to do aop without invasion, there is still one invasion point.

Given an app package(where original codes is given), aspectd requires a new aop package where aop codes are written, so that when compiling the aop package, both app and aop codes can be all compiled into the app.dill.
Henceforth, a hook is needed in the app building process(flutter_tools) so that aop package can be compiled when app package is compiled successfully, both in jit/aot mode.
After the aop package is compiled into dill successfully, a dill transformer is needed to extract the annotations and transform the component object so that aop feature can be implemented as expected.

More generally, different from gradle, design of flutter_tools make it hard for developers if they want to do inject some customized hooks before/after running flutter commands.

It would be better if a generalized way is provided.

Current patching logic to flutter_tools is given below:
a. build_aot.dart

Screen Shot 2019-07-23 at 4 34 49 PM

b.build_bundle.dart
Screen Shot 2019-07-23 at 4 34 57 PM

c.aspectd.dart
Not a problem as totally new.

cc @jonahwilliams

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: buildBuilding flutter applications with the toolc: new featureNothing broken; request for a new capabilitycustomer: alibabateam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions