blob: 7519b487a2d7367874d945562539ce9d2a71169f [file] [log] [blame]
Yecheng Zhaod1bc1c72021-03-12 00:15:04 -08001# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import os
16
17"""Generate sources.gni for the list of mbedtls source files"""
18
19LICENSE_HEADER = """# Copyright 2021 The Pigweed Authors
20#
21# Licensed under the Apache License, Version 2.0 (the "License"); you may not
22# use this file except in compliance with the License. You may obtain a copy of
23# the License at
24#
25# https://www.apache.org/licenses/LICENSE-2.0
26#
27# Unless required by applicable law or agreed to in writing, software
28# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30# License for the specific language governing permissions and limitations under
31# the License.
32
33"""
34
35if __name__ == "__main__":
36
37 cfiles = []
38 for (path, dirnames, filenames) in os.walk("src/library"):
39 for filename in filenames:
40 if not filename.endswith('.c'):
41 continue
42 cfiles.append(os.path.join(path, filename))
43 cfiles.sort()
44
45 with open("sources.gni", 'w') as f:
46 f.write(LICENSE_HEADER)
47 f.write("mbedtls_sources = [\n")
48 for source in cfiles:
49 f.write(f' \"{source}\",\n')
50 f.write("]\n")