mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
utils: codegen: gen-controls.py: Convert to jinja2 templates
Jinja2 templates help separate the logic related to the template from the generation of the data. The python code becomes much clearer as a result. As an added bonus, we can use a single template file for both controls and properties. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
48f9660acd
commit
dc067c4bce
7 changed files with 175 additions and 340 deletions
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* Copyright (C) 2019, Google Inc.
|
||||
*
|
||||
* Control ID list
|
||||
* {{mode|capitalize}} ID list
|
||||
*
|
||||
* This file is auto-generated. Do not edit.
|
||||
*/
|
||||
|
@ -18,18 +18,42 @@
|
|||
|
||||
namespace libcamera {
|
||||
|
||||
namespace controls {
|
||||
namespace {{mode}} {
|
||||
|
||||
extern const ControlIdMap {{mode}};
|
||||
|
||||
{%- for vendor, ctrls in controls -%}
|
||||
|
||||
{% if vendor != 'libcamera' %}
|
||||
namespace {{vendor}} {
|
||||
|
||||
#define LIBCAMERA_HAS_{{vendor|upper}}_VENDOR_{{mode|upper}}
|
||||
{%- endif %}
|
||||
|
||||
enum {
|
||||
${ids}
|
||||
{%- for ctrl in ctrls %}
|
||||
{{ctrl.name|snake_case|upper}} = {{ctrl.id}},
|
||||
{%- endfor %}
|
||||
};
|
||||
|
||||
${controls}
|
||||
{% for ctrl in ctrls -%}
|
||||
{% if ctrl.is_enum -%}
|
||||
enum {{ctrl.name}}Enum {
|
||||
{%- for enum in ctrl.enum_values %}
|
||||
{{enum.name}} = {{enum.value}},
|
||||
{%- endfor %}
|
||||
};
|
||||
extern const std::array<const ControlValue, {{ctrl.enum_values_count}}> {{ctrl.name}}Values;
|
||||
extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap;
|
||||
{% endif -%}
|
||||
extern const Control<{{ctrl.type}}> {{ctrl.name}};
|
||||
{% endfor -%}
|
||||
|
||||
extern const ControlIdMap controls;
|
||||
{% if vendor != 'libcamera' %}
|
||||
} /* namespace {{vendor}} */
|
||||
{% endif -%}
|
||||
|
||||
${vendor_controls}
|
||||
|
||||
} /* namespace controls */
|
||||
{% endfor %}
|
||||
} /* namespace {{mode}} */
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -80,7 +80,7 @@ foreach mode, entry : controls_map
|
|||
properties_files_names += files_list
|
||||
endif
|
||||
|
||||
template_file = files(outfile + '.in')
|
||||
template_file = files('control_ids.h.in')
|
||||
ranges_file = files('../../src/libcamera/control_ranges.yaml')
|
||||
control_headers += custom_target(header + '_h',
|
||||
input : input_files,
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
/*
|
||||
* Copyright (C) 2019, Google Inc.
|
||||
*
|
||||
* Property ID list
|
||||
*
|
||||
* This file is auto-generated. Do not edit.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
namespace properties {
|
||||
|
||||
enum {
|
||||
${ids}
|
||||
};
|
||||
|
||||
${controls}
|
||||
|
||||
extern const ControlIdMap properties;
|
||||
|
||||
${vendor_controls}
|
||||
|
||||
} /* namespace properties */
|
||||
|
||||
} /* namespace libcamera */
|
Loading…
Add table
Add a link
Reference in a new issue