| #!/usr/bin/env python3 |
| # |
| # Copyright 2023 The Cobalt Authors. All Rights Reserved. |
| |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| """Creates a GN include file for building dav1d from source.""" |
| |
| __author__ = "dalecurtis@chromium.org (Dale Curtis)" |
| |
| import datetime |
| import glob |
| import os |
| |
| _COPYRIGHT = """# Copyright %d The Cobalt Authors. All Rights Reserved. |
| |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # NOTE: this file is autogenerated by libdav1d/generate_source.py - DO NOT EDIT. |
| |
| """ % ( |
| datetime.datetime.now().year) |
| |
| |
| def _Glob(pattern): |
| # Replace path separator. Needed when running on Windows. |
| return [i.replace(os.sep, '/') for i in glob.glob(pattern)] |
| |
| |
| def _WriteArray(fd, var_name, array, filter_list=[], last_entry=False): |
| if len(array) == 0: |
| fd.write("%s = []\n" % var_name) |
| return |
| |
| fd.write("%s = [\n" % var_name) |
| for item in sorted(array): |
| if item not in filter_list: |
| fd.write(" \"%s\",\n" % item) |
| fd.write("]\n") |
| if not last_entry: |
| fd.write("\n") |
| |
| |
| def _WriteGn(fd): |
| fd.write(_COPYRIGHT) |
| |
| # NOTE: $arch_template_sources are empty as of Dec 2022. If they remain |
| # empty over the next few rolls we should remove them. |
| _WriteArray(fd, "x86_asm_sources", _Glob("src/x86/*.asm"), |
| ["src/x86/filmgrain_common.asm"]) |
| _WriteArray(fd, "x86_template_sources", _Glob("src/x86/*_tmpl.c")) |
| |
| _WriteArray( |
| fd, "arm32_asm_sources", _Glob("src/arm/32/*.S"), |
| _Glob("src/arm/32/*_tmpl.S") + ["src/arm/32/util.S"]) |
| _WriteArray( |
| fd, "arm64_asm_sources", _Glob("src/arm/64/*.S"), |
| _Glob("src/arm/64/*_tmpl.S") + ["src/arm/64/util.S"]) |
| _WriteArray(fd, "arm_template_sources", _Glob("src/arm/*_tmpl.c")) |
| |
| template_sources = _Glob("src/*_tmpl.c") |
| _WriteArray(fd, "template_sources", template_sources) |
| |
| # Generate list of sources which need to be compiled multiple times with the |
| # correct -DBIT_DEPTH=8|10 option specified each time. |
| _WriteArray(fd, "c_headers", _Glob("src/*.h")) |
| _WriteArray(fd, "c_sources", _Glob("src/*.c"), template_sources, |
| last_entry=True) |
| |
| |
| def main(): |
| with open("dav1d_generated.gni", "w") as fd: |
| _WriteGn(fd) |
| |
| |
| if __name__ == "__main__": |
| main() |