[analyzer] Stable analysis tool has more options

The CL adds options to disable comments, disable warnings and disable
lints. It also makes the cfe "compile_files_in_folders" tool ignore
these settings.

Disabling comments, for instance, looks to give a change of:
 * instructions:u between -6.79% and -7.99%.
 * msec task-clock:u between -6.72% and -11.21%.
 * seconds time elapsed between -6.71 and -11.21%.

depending on what other options are given (disabling lints and/or
warnings too) and whether GC is "disabled" or not. See below for
details.

Similarly disabling lints (the 14 lints I've otherwise enabled)
(although less combinations tested) seems to change the cost between
-2.11% and -3.33%, and disabling warnings seems to change the cost
between -7.60% and -13.28%.

In total either enabling both lints, warnings and comments vs neither
(disabling all three) change the cost -16.29% and -21.86%.

Comparing a CFE compile with an analyzer "compile" with all three
disabled shows that analyzer is still about twice as slow.

Details:

```
$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot) with snapshot #2 (stable_analysis.aot --no-comments)
msec task-clock:u: -7.0360% +/- 2.2215% (-716.15 +/- 226.12) (10178.40 -> 9462.25)
page-faults:u: -9.3094% +/- 0.0553% (-16061.70 +/- 95.37) (172531.70 -> 156470.00)
cycles:u: -6.9440% +/- 2.2933% (-2972501432.70 +/- 981663660.71) (42806647619.00 -> 39834146186.30)
instructions:u: -6.7931% +/- 0.0048% (-3440120947.40 +/- 2430899.72) (50641327831.60 -> 47201206884.20)
seconds time elapsed: -7.0392% +/- 2.2165% (-0.72 +/- 0.23) (10.18 -> 9.47)
seconds user: -6.9201% +/- 2.3274% (-0.68 +/- 0.23) (9.83 -> 9.15)
seconds sys: -10.2590% +/- 9.2097% (-0.04 +/- 0.03) (0.35 -> 0.31)

Comparing GC runtimes:
Combined GC time: -9.6583% +/- 1.7022% (-321.00 +/- 56.57) (3323.57 -> 3002.57)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot) with snapshot #2 (stable_analysis.aot --no-comments)
msec task-clock:u: -7.1224% +/- 0.3630% (-1605.67 +/- 81.82) (22543.93 -> 20938.26)
page-faults:u: -3.1600% +/- 0.0002% (-46716.10 +/- 2.42) (1478356.30 -> 1431640.20)
cycles:u: -7.7156% +/- 0.3679% (-6694485059.90 +/- 319209763.53) (86765022635.00 -> 80070537575.10)
instructions:u: -7.6201% +/- 0.0010% (-2695561907.00 +/- 362989.96) (35374252528.80 -> 32678690621.80)
branch-misses:u: -10.2389% +/- 3.5180% (-11334840.10 +/- 3894561.73) (110703356.00 -> 99368515.90)
seconds time elapsed: -7.1089% +/- 0.3612% (-1.60 +/- 0.08) (22.56 -> 20.95)
seconds user: -7.4913% +/- 0.4934% (-1.51 +/- 0.10) (20.13 -> 18.62)
seconds sys: -4.0502% +/- 3.7179% (-0.10 +/- 0.09) (2.42 -> 2.32)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-lints" --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot --no-lints) with snapshot #2 (stable_analysis.aot --no-comments --no-lints)
msec task-clock:u: -9.2019% +/- 0.6621% (-910.34 +/- 65.50) (9892.93 -> 8982.59)
page-faults:u: -6.2397% +/- 0.0494% (-10547.20 +/- 83.52) (169032.60 -> 158485.40)
cycles:u: -9.3403% +/- 0.6697% (-3887793187.50 +/- 278762348.75) (41623774318.80 -> 37735981131.30)
instructions:u: -7.0416% +/- 0.0016% (-3514960850.70 +/- 810910.06) (49917064106.10 -> 46402103255.40)
branch-misses:u: -8.4057% +/- 2.6353% (-13819038.80 +/- 4332417.14) (164399864.10 -> 150580825.30)
seconds time elapsed: -9.2035% +/- 0.6675% (-0.91 +/- 0.07) (9.90 -> 8.99)
seconds user: -9.4766% +/- 0.7713% (-0.91 +/- 0.07) (9.55 -> 8.65)

Comparing GC runtimes:
Combined GC time: -11.4370% +/- 1.6980% (-378.03 +/- 56.13) (3305.37 -> 2927.33)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot --no-lints) with snapshot #2 (stable_analysis.aot --no-comments --no-lints)
msec task-clock:u: -7.2817% +/- 0.4008% (-1593.44 +/- 87.70) (21882.89 -> 20289.45)
page-faults:u: -3.1244% +/- 0.0002% (-45240.50 +/- 2.27) (1447974.10 -> 1402733.60)
cycles:u: -7.9326% +/- 0.4361% (-6672136018.70 +/- 366778719.10) (84110098071.20 -> 77437962052.50)
instructions:u: -7.4881% +/- 0.0026% (-2595260910.30 +/- 917003.73) (34658689885.60 -> 32063428975.30)
branch-misses:u: -10.1639% +/- 3.2225% (-11069908.60 +/- 3509791.31) (108913984.10 -> 97844075.50)
seconds time elapsed: -7.2712% +/- 0.4031% (-1.59 +/- 0.09) (21.90 -> 20.31)
seconds user: -7.8503% +/- 0.5967% (-1.53 +/- 0.12) (19.53 -> 18.00)
seconds sys: -2.5633% +/- 2.0326% (-0.06 +/- 0.05) (2.35 -> 2.29)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-lints" --sarguments="--no-warnings" --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --sarguments="--no-warnings" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot --no-lints --no-warnings) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -11.2175% +/- 0.9595% (-1057.47 +/- 90.45) (9427.00 -> 8369.53)
page-faults:u: -2.9365% +/- 0.0303% (-4905.10 +/- 50.64) (167041.70 -> 162136.60)
cycles:u: -11.5567% +/- 0.9943% (-4574393094.20 +/- 393550033.60) (39582014249.70 -> 35007621155.50)
instructions:u: -7.9922% +/- 0.0016% (-3682331457.40 +/- 758149.87) (46074246049.70 -> 42391914592.30)
branch-misses:u: -12.5973% +/- 3.8892% (-20502429.90 +/- 6329690.96) (162752151.40 -> 142249721.50)
seconds time elapsed: -11.2137% +/- 0.9574% (-1.06 +/- 0.09) (9.43 -> 8.37)
seconds user: -11.8730% +/- 1.0637% (-1.08 +/- 0.10) (9.10 -> 8.02)

Comparing GC runtimes:
Combined GC time: -11.6525% +/- 0.5882% (-393.43 +/- 19.86) (3376.40 -> 2982.97)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot --no-lints --no-warnings) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -6.7208% +/- 0.3612% (-1266.45 +/- 68.07) (18843.65 -> 17577.20)
page-faults:u: -3.1649% +/- 0.0001% (-42088.20 +/- 1.96) (1329861.40 -> 1287773.20)
cycles:u: -7.3160% +/- 0.4054% (-5241354807.90 +/- 290412282.62) (71642843105.80 -> 66401488297.90)
instructions:u: -7.5935% +/- 0.0044% (-2296152115.10 +/- 1343905.59) (30238373990.20 -> 27942221875.10)
branch-misses:u: -9.1132% +/- 3.9645% (-8608099.00 +/- 3744717.48) (94457321.20 -> 85849222.20)
seconds time elapsed: -6.7108% +/- 0.3627% (-1.27 +/- 0.07) (18.86 -> 17.59)
seconds user: -7.0670% +/- 0.5908% (-1.18 +/- 0.10) (16.67 -> 15.49)
seconds sys: -4.0702% +/- 2.9649% (-0.09 +/- 0.06) (2.18 -> 2.09)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-warnings" --sarguments="--no-comments" --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --sarguments="--no-warnings" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot --no-warnings --no-comments) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -3.3341% +/- 0.7377% (-289.51 +/- 64.06) (8683.35 -> 8393.84)
page-faults:u: -0.7417% +/- 0.0323% (-1211.60 +/- 52.80) (163349.30 -> 162137.70)
cycles:u: -3.4347% +/- 0.7601% (-1248867985.60 +/- 276375749.53) (36360602643.40 -> 35111734657.80)
instructions:u: -2.6297% +/- 0.0028% (-1144935784.80 +/- 1231115.23) (43538078747.80 -> 42393142963.00)
branch-misses:u: -5.2678% +/- 3.3805% (-7994928.30 +/- 5130484.66) (151768514.80 -> 143773586.50)
seconds time elapsed: -3.3345% +/- 0.7360% (-0.29 +/- 0.06) (8.69 -> 8.40)
seconds user: -3.2817% +/- 0.7542% (-0.27 +/- 0.06) (8.35 -> 8.07)

Comparing GC runtimes:
No change in combined time.

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot --no-warnings --no-comments) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -2.9476% +/- 0.7598% (-533.40 +/- 137.48) (18095.98 -> 17562.59)
page-faults:u: -2.1956% +/- 0.0002% (-28908.80 +/- 2.72) (1316679.70 -> 1287770.90)
cycles:u: -3.0434% +/- 0.8290% (-2084711292.10 +/- 567884399.15) (68499834949.50 -> 66415123657.40)
instructions:u: -2.1172% +/- 0.0036% (-604406330.20 +/- 1031078.80) (28547212878.80 -> 27942806548.60)
seconds time elapsed: -2.9501% +/- 0.7589% (-0.53 +/- 0.14) (18.11 -> 17.58)
seconds user: -2.7506% +/- 0.9446% (-0.44 +/- 0.15) (15.93 -> 15.49)
seconds sys: -4.3950% +/- 4.3370% (-0.10 +/- 0.09) (2.17 -> 2.07)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-lints" --sarguments="--no-comments" --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --sarguments="--no-warnings" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot --no-lints --no-comments) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -7.6122% +/- 0.8005% (-689.89 +/- 72.54) (9062.94 -> 8373.04)
page-faults:u: 2.3362% +/- 0.0384% (3701.00 +/- 60.83) (158421.00 -> 162122.00)
cycles:u: -7.9589% +/- 0.8252% (-3031048897.60 +/- 314287122.04) (38083925666.10 -> 35052876768.50)
instructions:u: -8.6432% +/- 0.0022% (-4010719175.80 +/- 1020253.35) (46402911564.20 -> 42392192388.40)
branch-misses:u: -8.5667% +/- 3.3681% (-13392276.60 +/- 5265305.94) (156329178.70 -> 142936902.10)
seconds time elapsed: -7.6092% +/- 0.7960% (-0.69 +/- 0.07) (9.07 -> 8.38)
seconds user: -8.1069% +/- 0.8987% (-0.71 +/- 0.08) (8.74 -> 8.03)

Comparing GC runtimes:
Combined GC time: 1.4218% +/- 0.6146% (41.57 +/- 17.97) (2923.60 -> 2965.17)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot --no-lints --no-comments) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -13.2776% +/- 0.5461% (-2683.53 +/- 110.37) (20211.00 -> 17527.47)
page-faults:u: -8.1957% +/- 0.0002% (-114963.50 +/- 2.25) (1402734.60 -> 1287771.10)
cycles:u: -14.0568% +/- 0.5875% (-10861686217.90 +/- 453928594.78) (77270029416.60 -> 66408343198.70)
instructions:u: -12.8518% +/- 0.0039% (-4120716309.30 +/- 1253748.99) (32063315038.40 -> 27942598729.10)
branch-misses:u: -12.3483% +/- 4.9528% (-11819842.80 +/- 4740787.92) (95720172.60 -> 83900329.80)
seconds time elapsed: -13.2848% +/- 0.5501% (-2.69 +/- 0.11) (20.23 -> 17.54)
seconds user: -14.2010% +/- 0.8556% (-2.56 +/- 0.15) (18.00 -> 15.45)
seconds sys: -5.7485% +/- 4.1202% (-0.13 +/- 0.09) (2.21 -> 2.08)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/analyzer/tool/stable_analysis.aot --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --sarguments="--no-warnings" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (stable_analysis.aot) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -17.0699% +/- 1.2566% (-1725.94 +/- 127.06) (10111.01 -> 8385.07)
page-faults:u: -6.0303% +/- 0.0647% (-10406.40 +/- 111.60) (172567.50 -> 162161.10)
cycles:u: -17.5229% +/- 1.3093% (-7452390822.40 +/- 556837791.41) (42529351599.20 -> 35076960776.80)
instructions:u: -16.2915% +/- 0.0045% (-8250492166.60 +/- 2298292.70) (50642836187.30 -> 42392344020.70)
branch-misses:u: -19.3893% +/- 5.0813% (-33703814.20 +/- 8832662.68) (173826494.90 -> 140122680.70)
seconds time elapsed: -17.0646% +/- 1.2597% (-1.73 +/- 0.13) (10.12 -> 8.39)
seconds user: -17.4043% +/- 1.3249% (-1.70 +/- 0.13) (9.77 -> 8.07)

Comparing GC runtimes:
Combined GC time: -9.6474% +/- 0.9303% (-317.80 +/- 30.65) (3294.17 -> 2976.37)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (stable_analysis.aot) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: -21.8650% +/- 0.3146% (-4909.91 +/- 70.64) (22455.59 -> 17545.68)
page-faults:u: -12.8916% +/- 0.0001% (-190583.50 +/- 2.05) (1478355.30 -> 1287771.80)
cycles:u: -23.1639% +/- 0.3324% (-20039621139.90 +/- 287545199.62) (86512110232.60 -> 66472489092.70)
instructions:u: -21.0110% +/- 0.0045% (-7432530108.60 +/- 1594640.89) (35374475273.60 -> 27941945165.00)
branch-misses:u: -20.4131% +/- 3.4484% (-21659250.80 +/- 3658856.19) (106104443.40 -> 84445192.60)
seconds time elapsed: -21.8550% +/- 0.3165% (-4.91 +/- 0.07) (22.47 -> 17.56)
seconds user: -22.9392% +/- 0.6813% (-4.61 +/- 0.14) (20.12 -> 15.50)
seconds sys: -12.6236% +/- 4.3772% (-0.30 +/- 0.10) (2.34 -> 2.04)

$ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --no-gc --silent --iterations=10 --gcs=3 --snapshot=pkg/front_end/tool/compile_files_in_folders.aot --snapshot=pkg/analyzer/tool/stable_analysis.aot --sarguments="--no-comments" --sarguments="--no-lints" --sarguments="--no-warnings" --arguments="/tmp/extracted_compile_dart_compile"
Will now run 10+3 iterations with 2 snapshots.
.........|.........|......
..........................

Comparing snapshot #1 (compile_files_in_folders.aot) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: 93.7631% +/- 1.7382% (4059.93 +/- 75.26) (4329.99 -> 8389.92)
page-faults:u: 74.1975% +/- 0.0433% (69060.90 +/- 40.33) (93077.10 -> 162138.00)
cycles:u: 95.0345% +/- 1.8170% (17109768118.30 +/- 327129529.20) (18003745305.70 -> 35113513424.00)
instructions:u: 100.4940% +/- 0.0028% (21248236334.70 +/- 598466.90) (21143775631.70 -> 42392011966.40)
branch-misses:u: 98.0546% +/- 7.7754% (70722114.60 +/- 5607995.68) (72125240.20 -> 142847354.80)
seconds time elapsed: 93.7448% +/- 1.7272% (4.06 +/- 0.07) (4.33 -> 8.39)
seconds user: 94.6406% +/- 1.9931% (3.93 +/- 0.08) (4.15 -> 8.08)
seconds sys: 74.2391% +/- 13.9753% (0.13 +/- 0.03) (0.18 -> 0.32)

Comparing GC runtimes:
Combined GC time: 100.8652% +/- 2.6849% (1496.13 +/- 39.82) (1483.30 -> 2979.43)

Will now run 10+0 iterations with 2 snapshots.
Running with extra vm arguments: --new_gen_semi_initial_size=10000 --new_gen_semi_max_size=20000
.........|.........|
....................

Comparing snapshot #1 (compile_files_in_folders.aot) with snapshot #2 (stable_analysis.aot --no-comments --no-lints --no-warnings)
msec task-clock:u: 304.8456% +/- 1.7471% (13210.70 +/- 75.71) (4333.57 -> 17544.27)
page-faults:u: 199.1590% +/- 0.0010% (857307.10 +/- 4.13) (430463.60 -> 1287770.70)
cycles:u: 339.8369% +/- 2.0802% (51368129498.20 +/- 314431857.77) (15115522915.20 -> 66483652413.40)
instructions:u: 121.8106% +/- 0.0124% (15344104830.80 +/- 1564723.39) (12596695878.50 -> 27940800709.30)
branch-misses:u: 72.0768% +/- 6.0455% (35926587.50 +/- 3013368.88) (49844848.90 -> 85771436.40)
seconds time elapsed: 304.7994% +/- 1.7436% (13.22 +/- 0.08) (4.34 -> 17.56)
seconds user: 336.2468% +/- 1.5576% (11.94 +/- 0.06) (3.55 -> 15.49)
seconds sys: 165.8816% +/- 7.6178% (1.28 +/- 0.06) (0.77 -> 2.05)
```

Change-Id: I048a6031e3d6bb56896fa28077b5e7ddf9add810
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452783
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>

https://dart.googlesource.com/sdk/+/273fe8e63a6edba1a019d4a5861756e489506e6e
2 files changed
tree: b7c07ae07d45728c7bc710e8453bf0fd35ce3003
  1. engine/
  2. tools/
  3. .gitignore
  4. commits.json
  5. DEPS
  6. OWNERS
  7. README.md
README.md

Monorepo

A gclient solution for checking out Dart and Flutter source trees

Monorepo is:

  • Optimized for Tip-of-Tree testing: The Monorepo DEPS used to check out Dart and Flutter dependencies comes from the Flutter engine DEPS with updated dependencies from Dart.

Checking out Monorepo

With depot_tools installed and on your path, create a directory for your monorepo checkout and run these commands to create a gclient solution in that directory:

mkdir monorepo
cd monorepo
gclient config --unmanaged https://dart.googlesource.com/monorepo
gclient sync -D

This gives you a checkout in the monorepo directory that contains:

monorepo/
  DEPS - the DEPS used for this gclient checkout
  commits.json - the pinned commits for Dart, flutter/engine,
                 and flutter/flutter
  tools/ - scripts used to create monorepo DEPS
engine/src/ - the flutter/buildroot repo
    flutter/ - the flutter/engine repo
    out/ - the build directory, where Flutter engine builds are created
    third_party/ - Flutter dependencies checked out by DEPS
      dart/ - the Dart SDK checkout.
        third_party - Dart dependencies, also used by Flutter
flutter/ - the flutter/flutter repo

Building Flutter engine

Flutter's instructions for building the engine are at Compiling the engine

They can be followed closely, with a few changes:

  • Googlers working on Dart do not need to switch to Fuchsia's Goma RBE, except for Windows. The GOMA_DIR enviroment variable can just point to the .cipd_bin directory in a depot_tools installation, and just goma_ctl ensure_start is sufficient.
  • The --no-prebuilt-dart-sdk option has to be added to every gn command, so that the build is set up to build and use a local Dart SDK.
  • The --full-dart-sdk option must be added to gn for the host build target if you will be building web or desktop apps.

Example build commands that work on linux:

MONOREPO_PATH=$PWD
if [[ ! $PATH =~ (^|:)$MONOREPO_PATH/flutter/bin(:|$) ]]; then
  PATH=$MONOREPO_PATH/flutter/bin:$PATH
fi

export GOMA_DIR=$(dirname $(command -v gclient))/.cipd_bin
goma_ctl ensure_start

pushd engine/src
flutter/tools/gn --goma --no-prebuilt-dart-sdk --unoptimized --full-dart-sdk
autoninja -C out/host_debug_unopt
popd

Building Flutter apps

The Flutter commands used to build and run apps will use the locally built Flutter engine and Dart SDK, instead of the one downloaded by the Flutter tool, if the --local-engine option is provided.

For example, to build and run the Flutter spinning square sample on the web platform,

MONOREPO_PATH=$PWD
cd flutter/examples/layers
flutter --local-engine=host_debug_unopt \
  -d chrome run widgets/spinning_square.dart
cd $MONOREPO_PATH

To build for desktop, specify the desktop platform device in flutter run as -d macos or -d linux or -d windows. You may also need to run the command

flutter create --platforms=windows,macos,linux

on existing apps, such as sample apps. New apps created with flutter create already include these support files. Details of desktop support are at Desktop Support for Flutter

Testing

Tests in the Flutter source tree can be run with the flutter test command, run in the directory of a package containing tests. For example:

MONOREPO_PATH=$PWD
cd flutter/packages/flutter
flutter test --local-engine=host_debug_unopt
cd $MONOREPO_PATH

Troubleshooting

Please file an issue or email the dart-engprod team with any problems with or questions about using monorepo.

We will update this documentation to address them.

  • flutter commands may download the engine and Dart SDK files for the configured channel, even though they will be using the local engine and its SDK.

Windows

  • On Windows, gclient sync needs to be run in an administrator session, because some installed dependencies create symlinks.