|
10 | 10 |
|
11 | 11 | from idf_build_apps import build_apps, find_apps, setup_logging |
12 | 12 | from idf_build_apps.constants import SUPPORTED_TARGETS |
| 13 | +from packaging import version |
| 14 | +from pkg_resources import get_distribution |
13 | 15 |
|
14 | 16 | if __name__ == '__main__': |
15 | 17 | parser = argparse.ArgumentParser( |
16 | 18 | description='Build all projects', |
17 | 19 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
18 | 20 | ) |
19 | 21 | parser.add_argument('paths', nargs='+', help='Paths to the apps to build.') |
| 22 | + parser.add_argument( |
| 23 | + '-v', |
| 24 | + '--verbose', |
| 25 | + action='count', |
| 26 | + help='Increase the LOGGER level of the script. Can be specified multiple times.', |
| 27 | + ) |
20 | 28 | parser.add_argument( |
21 | 29 | '-t', |
22 | 30 | '--target', |
|
28 | 36 | parser.add_argument('-d', '--delete', action='store_true', help='Delete build artifacts') |
29 | 37 | parser.add_argument('-c', '--recursive', action='store_true', help='Build recursively') |
30 | 38 | parser.add_argument('-l', '--linux', action='store_true', help='Include linux build (dont check warnings)') |
| 39 | + parser.add_argument('--preserve-all', action='store_true', help='Preserve the binaries for all apps when specified.') |
| 40 | + parser.add_argument('--pytest-apps', action='store_true', help='Only build apps required by pytest scripts.') |
31 | 41 | args = parser.parse_args() |
32 | 42 |
|
33 | 43 | IDF_PATH = os.environ['IDF_PATH'] |
|
41 | 51 | SUPPORTED_TARGETS.append('linux') |
42 | 52 | ignore_warning = 'warning: ' # Ignore all common warnings on linux builds |
43 | 53 | setup_logging(2) |
44 | | - apps = find_apps( |
45 | | - args.paths, |
46 | | - recursive=args.recursive, |
47 | | - target=args.target, |
48 | | - build_dir='build_@t_@w', |
49 | | - config_rules_str=args.rules, |
50 | | - build_log_path='build_log.txt', |
51 | | - size_json_path='size.json' if not args.linux else None, |
52 | | - check_warnings=True, |
53 | | - preserve=not args.delete, |
54 | | - manifest_files=args.manifests, |
55 | | - default_build_targets=SUPPORTED_TARGETS, |
56 | | - manifest_rootpath='.', |
57 | | - ) |
| 54 | + if version.parse(get_distribution('idf_build_apps').version) >= version.parse('2.0.0'): |
| 55 | + apps = find_apps( |
| 56 | + args.paths, |
| 57 | + recursive=args.recursive, |
| 58 | + target=args.target, |
| 59 | + build_dir='build_@t_@w', |
| 60 | + config_rules_str=args.rules, |
| 61 | + build_log_filename='build_log.txt', |
| 62 | + size_json_filename='size.json' if not args.linux else None, |
| 63 | + check_warnings=True, |
| 64 | + preserve=not args.delete, |
| 65 | + manifest_files=args.manifests, |
| 66 | + default_build_targets=SUPPORTED_TARGETS, |
| 67 | + manifest_rootpath='.', |
| 68 | + ) |
| 69 | + else: |
| 70 | + apps = find_apps( |
| 71 | + args.paths, |
| 72 | + recursive=args.recursive, |
| 73 | + target=args.target, |
| 74 | + build_dir='build_@t_@w', |
| 75 | + config_rules_str=args.rules, |
| 76 | + build_log_path='build_log.txt', |
| 77 | + size_json_path='size.json' if not args.linux else None, |
| 78 | + check_warnings=True, |
| 79 | + preserve=not args.delete, |
| 80 | + manifest_files=args.manifests, |
| 81 | + default_build_targets=SUPPORTED_TARGETS, |
| 82 | + manifest_rootpath='.', |
| 83 | + ) |
58 | 84 |
|
59 | 85 | for app in apps: |
60 | 86 | print(app) |
|
0 commit comments