4 This file is part of Cleanflight.
6 Cleanflight is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Cleanflight is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
24 if __name__
== '__main__':
25 path
= os
.path
.join(os
.path
.dirname(__file__
), '..',
26 'main', 'target', '*', 'target.h')
27 files
= glob
.glob(path
)
31 target
= os
.path
.basename(os
.path
.dirname(file))
32 with
open(file, 'r') as handle
:
35 if line
.startswith('#define'):
37 line
= line
.replace('\t', ' ')
38 define
= line
.split(' ')[1].strip()
39 if define
not in defines
:
41 defines
[define
].append(target
)
45 counts
= {k
: len(v
) for k
, v
in defines
.items()}
47 for define
, count
in sorted(counts
.items(), key
=operator
.itemgetter(1)):
48 print("{}\t{}\t{}".format(define
, count
, ', '.join(sorted(defines
[define
]))))