From af5d8338a90a7ba54a1bd4b9e34be2bc26d40072 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Mon, 21 Aug 2023 20:20:01 -0700 Subject: [PATCH] Disallow using ./tools/gn --enable-unittests --android (or --ios) (flutter/engine#44930) Closes https://github.com/flutter/flutter/issues/132611. As seen on https://github.com/flutter/flutter/issues/132611, this will never succeed compiling. I tried to update the Wiki as well: https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment#vscode-with-cc-intellisense-cc --- engine/src/flutter/tools/gn | 11 +++++++++++ engine/src/flutter/tools/gn_test.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 4ddaf65919..649a0da300 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -299,6 +299,17 @@ def to_gn_args(args): gn_args['full_dart_sdk'] = args.full_dart_sdk if args.enable_unittests: + # Ensure that Android and iOS are *not* used with --enable-unittests. + # https://github.com/flutter/flutter/issues/132611 + if args.target_os == 'android' or args.target_os == 'ios': + raise Exception( + 'Cannot use --enable-unittests with --target-os=android or ios. If ' + + 'you are trying to create an output directory to use for clangd ' + + '(i.e. for VSCode integration), use a host build instead.\n\n' + + 'See https://github.com/flutter/flutter/wiki/' + + 'Setting-up-the-Engine-development-environment' + + '#vscode-with-cc-intellisense-cc' + ) gn_args['enable_unittests'] = True if args.no_enable_unittests: gn_args['enable_unittests'] = False diff --git a/engine/src/flutter/tools/gn_test.py b/engine/src/flutter/tools/gn_test.py index a399d7e779..9e623e1e86 100644 --- a/engine/src/flutter/tools/gn_test.py +++ b/engine/src/flutter/tools/gn_test.py @@ -35,6 +35,14 @@ class GNTestCase(unittest.TestCase): ) self.assertEquals(self._gn_args(['--ios'])['target_cpu'], 'arm') + def test_cannot_use_android_and_enable_unittests(self): + with self.assertRaises(SystemExit): + self._gn_args(['--android', '--enable-unittests']) + + def test_cannot_use_ios_and_enable_unittests(self): + with self.assertRaises(SystemExit): + self._gn_args(['--ios', '--enable-unittests']) + if __name__ == '__main__': unittest.main()