]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: build python modules with meson
authorAleš Mrázek <ales.mrazek@nic.cz>
Mon, 10 Oct 2022 13:26:08 +0000 (15:26 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Sun, 30 Oct 2022 00:49:32 +0000 (02:49 +0200)
16 files changed:
manager/knot_resolver_manager/cli/cmd/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/cli/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/compat/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/datamodel/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/datamodel/templates/macros/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/datamodel/templates/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/datamodel/types/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/kresd_controller/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/kresd_controller/supervisord/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/kresd_controller/supervisord/plugin/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/utils/meson.build [new file with mode: 0644]
manager/knot_resolver_manager/utils/modeling/meson.build [new file with mode: 0644]
manager/meson.build
meson.build
meson_options.txt

diff --git a/manager/knot_resolver_manager/cli/cmd/meson.build b/manager/knot_resolver_manager/cli/cmd/meson.build
new file mode 100644 (file)
index 0000000..b113c38
--- /dev/null
@@ -0,0 +1,8 @@
+py3.install_sources(
+    files(
+        'completion.py',
+        'config.py',
+        'stop.py',
+    ),
+    subdir: manager_module_dir / cli_dir / cmd_dir
+)
diff --git a/manager/knot_resolver_manager/cli/meson.build b/manager/knot_resolver_manager/cli/meson.build
new file mode 100644 (file)
index 0000000..d81b26a
--- /dev/null
@@ -0,0 +1,23 @@
+if get_option('manager_client') != 'disabled'
+    build_manager_client = true
+endif
+
+if build_manager_client
+
+    cmd_dir = 'cmd'
+    subdir(cmd_dir)
+
+    py3.install_sources(
+        files(
+            '__init__.py',
+            '__main__.py',
+        ),
+        subdir: manager_module_dir / cli_dir
+    )
+
+    # install_data(
+    #     sources : 'kresctl',
+    #     install_dir: get_option('sbindir'),
+    # )
+
+endif
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/compat/meson.build b/manager/knot_resolver_manager/compat/meson.build
new file mode 100644 (file)
index 0000000..372dd45
--- /dev/null
@@ -0,0 +1,8 @@
+py3.install_sources(
+    files(
+        '__init__.py',
+        'asyncio.py',
+        'dataclasses.py',
+    ),
+    subdir: manager_module_dir / compat_dir
+)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/datamodel/meson.build b/manager/knot_resolver_manager/datamodel/meson.build
new file mode 100644 (file)
index 0000000..c5f3706
--- /dev/null
@@ -0,0 +1,29 @@
+py3.install_sources(
+    files(
+        '__init__.py',
+        'cache_schema.py',
+        'config_schema.py',
+        'dns64_schema.py',
+        'dnssec_schema.py',
+        'forward_zone_schema.py',
+        'logging_schema.py',
+        'lua_schema.py',
+        'monitoring_schema.py',
+        'network_schema.py',
+        'options_schema.py',
+        'policy_schema.py',
+        'rpz_schema.py',
+        'slice_schema.py',
+        'static_hints_schema.py',
+        'stub_zone_schema.py',
+        'view_schema.py',
+        'webmgmt_schema.py',
+    ),
+    subdir: manager_module_dir / datamodel_dir
+)
+
+templates_dir = 'templates'
+subdir(templates_dir)
+
+types_dir = 'types'
+subdir(types_dir)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/datamodel/templates/macros/meson.build b/manager/knot_resolver_manager/datamodel/templates/macros/meson.build
new file mode 100644 (file)
index 0000000..940b6e2
--- /dev/null
@@ -0,0 +1,9 @@
+py3.install_sources(
+    files(
+        'common_macros.lua.j2',
+        'network_macros.lua.j2',
+        'policy_macros.lua.j2',
+        'view_macros.lua.j2',
+    ),
+    subdir: manager_module_dir / datamodel_dir / templates_dir / macros_dir
+)
diff --git a/manager/knot_resolver_manager/datamodel/templates/meson.build b/manager/knot_resolver_manager/datamodel/templates/meson.build
new file mode 100644 (file)
index 0000000..a7de2b5
--- /dev/null
@@ -0,0 +1,24 @@
+macros_dir = 'macros'
+subdir(macros_dir)
+
+py3.install_sources(
+    files(
+        'cache.lua.j2',
+        'config.lua.j2',
+        'dns64.lua.j2',
+        'dnssec.lua.j2',
+        'forward_zones.lua.j2',
+        'logging.lua.j2',
+        'monitoring.lua.j2',
+        'network.lua.j2',
+        'options.lua.j2',
+        'policy.lua.j2',
+        'rpz.lua.j2',
+        'slices.lua.j2',
+        'static_hints.lua.j2',
+        'stub_zones.lua.j2',
+        'views.lua.j2',
+        'webmgmt.lua.j2',
+    ),
+    subdir: manager_module_dir / datamodel_dir / templates_dir
+)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/datamodel/types/meson.build b/manager/knot_resolver_manager/datamodel/types/meson.build
new file mode 100644 (file)
index 0000000..ca55d77
--- /dev/null
@@ -0,0 +1,9 @@
+py3.install_sources(
+    files(
+        '__init__.py',
+        'base_types.py',
+        'enums.py',
+        'types.py',
+    ),
+    subdir: manager_module_dir / datamodel_dir / types_dir
+)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/kresd_controller/meson.build b/manager/knot_resolver_manager/kresd_controller/meson.build
new file mode 100644 (file)
index 0000000..0407ab7
--- /dev/null
@@ -0,0 +1,10 @@
+supervisord_dir = 'supervisord'
+subdir(supervisord_dir)
+
+py3.install_sources(
+    files(
+        '__init__.py',
+        'interface.py',
+    ),
+    subdir: manager_module_dir / kresd_controller_dir
+)
diff --git a/manager/knot_resolver_manager/kresd_controller/supervisord/meson.build b/manager/knot_resolver_manager/kresd_controller/supervisord/meson.build
new file mode 100644 (file)
index 0000000..b63f7c1
--- /dev/null
@@ -0,0 +1,11 @@
+plugin_dir = 'plugin'
+subdir(plugin_dir)
+
+py3.install_sources(
+    files(
+        '__init__.py',
+        'config_file.py',
+        'supervisord.conf.j2'
+    ),
+    subdir: manager_module_dir / kresd_controller_dir / supervisord_dir
+)
diff --git a/manager/knot_resolver_manager/kresd_controller/supervisord/plugin/meson.build b/manager/knot_resolver_manager/kresd_controller/supervisord/plugin/meson.build
new file mode 100644 (file)
index 0000000..e5a9e96
--- /dev/null
@@ -0,0 +1,15 @@
+py3.extension_module(
+    'notify',
+    'notifymodule.c',
+    subdir: manager_module_dir / kresd_controller_dir / supervisord_dir / plugin_dir
+)
+
+py3.install_sources(
+    files(
+        '__init__.py',
+        'fast_rpcinterface.py',
+        'manager_lifecycle_monitor.py',
+        'stdout_pipe_log.py',
+    ),
+    subdir: manager_module_dir / kresd_controller_dir / supervisord_dir / plugin_dir
+)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/meson.build b/manager/knot_resolver_manager/meson.build
new file mode 100644 (file)
index 0000000..703cc45
--- /dev/null
@@ -0,0 +1,30 @@
+cli_dir = 'cli'
+subdir(cli_dir)
+
+compat_dir = 'compat'
+subdir(compat_dir)
+
+datamodel_dir = 'datamodel'
+subdir(datamodel_dir)
+
+kresd_controller_dir = 'kresd_controller'
+subdir(kresd_controller_dir)
+
+utils_dir = 'utils'
+subdir(utils_dir)
+
+py3.install_sources(
+    files(
+        '__init__.py',
+        '__main__.py',
+        'config_store.py',
+        'constants.py',
+        'exceptions.py',
+        'kres_manager.py',
+        'log.py',
+        'main.py',
+        'server.py',
+        'statistics.py',
+    ),
+    subdir: manager_module_dir
+)
diff --git a/manager/knot_resolver_manager/utils/meson.build b/manager/knot_resolver_manager/utils/meson.build
new file mode 100644 (file)
index 0000000..f05e191
--- /dev/null
@@ -0,0 +1,15 @@
+modeling_dir = 'modeling'
+subdir('modeling')
+
+py3.install_sources(
+    files(
+        '__init__.py',
+        'async_utils.py',
+        'custom_atexit.py',
+        'functional.py',
+        'requests.py',
+        'systemd_notify.py',
+        'which.py',
+    ),
+    subdir: manager_module_dir / utils_dir
+)
\ No newline at end of file
diff --git a/manager/knot_resolver_manager/utils/modeling/meson.build b/manager/knot_resolver_manager/utils/modeling/meson.build
new file mode 100644 (file)
index 0000000..e663115
--- /dev/null
@@ -0,0 +1,12 @@
+py3.install_sources(
+    files(
+        '__init__.py',
+        'base_schema.py',
+        'base_value_type.py',
+        'exceptions.py',
+        'parsing.py',
+        'query.py',
+        'types.py',
+    ),
+    subdir: manager_module_dir / utils_dir / modeling_dir
+)
\ No newline at end of file
index b88445e25a81f244a2fdd32f0255aaa5f6ccf6d7..c58514241ac84a35ca6c6004b30dd362fb935055 100644 (file)
@@ -2,16 +2,40 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 build_manager = false
+build_manager_client = false
+
 if get_option('manager') != 'disabled'
     message('--- manager dependencies ---')
 
-    python3 = find_program('python3', version: '>=3.6')
+    python_deps = [
+        # 'jinja2',
+        # 'yaml',
+        # 'aiohttp',
+        # 'prometheus_client',
+        # 'supervisor',
+        # 'typing_extensions',
+    ]
+
+    pymod = import('python')
+    py3 = pymod.find_installation('python3', modules: python_deps)
+    py3_deps = py3.dependency()
+
+    if py3.language_version().version_compare('<3.6')
+        error('At least Python 3.6 is required.')
+    else
+        build_manager = true
+    endif
 
-    build_manager = true
     message('----------------------------')
+elif get_option('manager') == 'disabled' and get_option('manager_client') == 'enabled'
+    error('manager client cannot be build without manager')
 endif
 
 if build_manager
+
+    manager_module_dir = 'knot_resolver_manager'
+    subdir(manager_module_dir)
+
     # YAML config: etc/knot-resolver/config.yml
     install_data(
         sources: 'etc/knot-resolver/config.yml',
index 4f677818999ff59a7fe4255a6770cee1bbfed678..928384756ae9437b41ce04fc2a4bd4d1ed66b882 100644 (file)
@@ -288,6 +288,7 @@ run_target(
 s_managed_ta = managed_ta ? 'enabled' : 'disabled'
 s_install_root_keys = install_root_keys ? 'enabled' : 'disabled'
 s_build_manager = build_manager ? 'enabled' : 'disabled'
+s_build_manager_client = build_manager_client ? 'enabled' : 'disabled'
 s_build_client = build_client ? 'enabled' : 'disabled'
 s_build_utils = build_utils ? 'enabled' : 'disabled'
 s_build_dnstap = build_dnstap ? 'enabled' : 'disabled'
@@ -323,6 +324,7 @@ message('''
 
   optional components
     manager:            @0@'''.format(s_build_manager) + '''
+    manager_client:     @0@'''.format(s_build_manager_client) + '''
     client:             @0@'''.format(s_build_client) + '''
     utils:              @0@'''.format(s_build_utils) + '''
     dnstap:             @0@'''.format(s_build_dnstap) + '''
index 62679d12042f0b43fe42abab8f8e30ea2ce769e9..568d964533bec4c78d98e75fc4f7137487e79241 100644 (file)
@@ -127,6 +127,18 @@ option(
   description: 'build manager and its features',
 )
 
+option(
+  'manager_client',
+  type: 'combo',
+  choices: [
+    'auto',
+    'enabled',
+    'disabled',
+  ],
+  value: 'auto',
+  description: 'build kresctl manager client',
+)
+
 option(
   'client',
   type: 'combo',