Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Add new design for generator script #44

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b9c82b6
utils: Add new design for generator script
razvand Jun 20, 2024
9037b2a
Document new class design
razvand Jul 19, 2024
77efe14
Improve tester config
razvand Aug 17, 2024
9ec6873
utils: Generate target configs for new design
razvand Aug 20, 2024
a27ce67
utils/new-design: Add initial generator logic
razvand Aug 20, 2024
cf917e7
new-design: Add Kraftfile generator
razvand Aug 21, 2024
3a60bc1
new-design: Add Makefile generator
razvand Aug 21, 2024
f758ebe
new-design: Add generators for build scripts
razvand Aug 21, 2024
bd5d767
new-design: Complete build scripts
razvand Aug 21, 2024
630ea66
new-design: Separate build variants from run variants
razvand Aug 31, 2024
4d9fc47
new-design: Add support for Clang
razvand Aug 31, 2024
39e186d
new-design: Add support for building Xen
razvand Aug 31, 2024
1b8f089
new-desing: Add run scripts
razvand Sep 11, 2024
2c9025a
new-design: Add support for ports for NAT networking
razvand Sep 14, 2024
b47d398
new-design: Consistent naming for networking types
razvand Sep 14, 2024
b8bd606
new-design: Add Firecracker run support
razvand Sep 14, 2024
69ec39b
new-design: Add common directory
razvand Sep 15, 2024
6ee2656
new-design: Use machine variable for non-arch runs
razvand Sep 15, 2024
4cd04b6
library/nginx/1.15: Add setup for new design scripts
razvand Sep 15, 2024
54dad81
library/nginx/1.15: Add test scripts
razvand Sep 15, 2024
3b4efbb
library/nginx/1.15: Ignore .tests/ directory
razvand Sep 15, 2024
0cf9a63
native/http-c: Add testing scripts
razvand Sep 19, 2024
4fa5aec
utils/new-design: Remove run configs when rootfs is not present
razvand Sep 19, 2024
1a785fa
utils/new-design: Pass configuration file as argument
razvand Sep 19, 2024
529944f
utils/new-design: Fixes for when rootfs is absent
razvand Sep 20, 2024
e3e56c7
utils/new-design: Fixes for base build
razvand Nov 11, 2024
10e4919
utils: Update tst scripts
razvand Dec 8, 2024
4ee7d7e
utils: Use example targets
razvand Dec 8, 2024
7c11bf7
new-design: Add fs build (init) script
razvand Jan 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 194 additions & 0 deletions utils/new-design/all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import os
import yaml
import itertools

class ConfigVariants:
arch = ['arm64', 'x86_64']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
arch = ['arm64', 'x86_64']
arch = ['arm64', 'x86_64']

I think it would be better to have a dictionary here to keep track a number of options (an option means arch, hypervisor, platform etc)

hypervisor = ['none', 'kvm', 'xen']
platform = ['qemu', 'firecracker', 'xen']
build_tool = ['make', 'kraft']
run_tool = ['vmm', 'kraft']
bootloader = ['multiboot', 'uefi']
pie = [False, True]
debug = ['none', 'strace', 'err', 'info', 'debug']
fs = ['none', 'initrd', '9pfs']
networking = ['none', 'bridge', 'nat', 'tap']

def _convert_to_dict(i):
return {
Copy link

@RaduNichita RaduNichita Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return {
return {

could you add an assert for the number of options, to make sure we get an error when we add a new option and we don't modify in all places

'arch': i[0],
'hypervisor': i[1],
'platform': i[2],
'build_tool': i[3],
'run_tool': i[4],
'bootloader': i[5],
'debug': i[6],
'fs': i[7],
'networking': i[8]
}

def _is_valid_config(d):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep an order about the if clauses?

For example - platform, then hypervisor, then netowrking and so on?

if d['networking'] == 'bridge' and d['platform'] == 'firecracker':
return False
if d['networking'] == 'tap' and d['platform'] != 'firecracker':
return False
if d['bootloader'] == 'uefi' and d['arch'] != 'x86_64':
return False
if d['platform'] == 'firecracker' and d['hypervisor'] != 'kvm':
return False
if d['platform'] == 'xen' and d['hypervisor'] != 'xen':
return False
if d['platform'] == 'qemu' and (d['hypervisor'] != 'kvm' and d['hypervisor'] != 'none'):
return False
if d['fs'] == '9pfs' and d['platform'] == 'firecracker':
return False
return True

def generate_config_variants(self):
variants = []
for i in itertools.product(self.arch, self.hypervisor, self.platform,
self.build_tool, self.run_tool,
self.bootloader, self.debug, self.fs,
self.networking):
d = ConfigVariants._convert_to_dict(i)
if ConfigVariants._is_valid_config(d):
variants.append(d)
return variants

class SystemConfig:
OS_TYPE_NONE = None
ARCH_NONE = None
HYPERVISOR_NONE = None
os = {
"type": OS_TYPE_NONE,
"kernel_version": None,
"distro": None
}
arch = ARCH_NONE
hypervisor = HYPERVISOR_NONE
vmms = {
'arm64': [],
'x86_64': []
}
compilers = {
'arm64': [],
'x86_64': []
}

def _get_os(self):
pass

def _get_arch(self):
pass

def _get_hypervisor(self):
pass

def _get_vmms(self):
pass

def _get_compilers(self):
pass

def __init__(self):
_get_os()
_get_arch()
_get_hypervisor()
_get_vmms()
_get_compilers()


class AppConfig:
ROOTFS_PATH_TYPE_NONE = None
SOURCES_TYPE_NONE = None
memory = 8
networking_enabled = False
# accel_enabled = False
specification = None
name = None
cmd = None
ROOTFS_PATH_TYPE_NONE = None
rootfs = {
'path': None,
'path_type': ROOTFS_PATH_TYPE_NONE
}
template = None
kernel = {
'version': None,
'source': None,
'config': {}
}
libs = []
targets = []
scripts_dir = os.path.join(os.getcwd(), "scripts")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scripts_dir = os.path.join(os.getcwd(), "scripts")
scripts_dir = os.path.join(os.getcwd(), SCRIPTS_PATH)

I think it may be better if we want to change the path in the future?

sources = {
'type': SOURCES_TYPE_NONE,
'path': None
}
target_configs = []

def _parse_user_config(self):
pass

def _parse_app_config(self):
pass

def __init__(self, user_config="config.yaml"):
_parse_user_config()
_parse_app_config()

def generate_target_configs(self):
for t in self.targets:
pass

class TargetConfig:
PLATFORM_NONE = None
ARCH_NONE = None
BOOTLOADER_TYPE_NONE = None
DEBUG_NONE = None
platform = PLATFORM_NONE
arch = ARCH_NONE
pie_enabled = False
paging_enabled = False
bootloader = BOOTLOADER_TYPE_NONE
debug = DEBUG_NONE
compiler = None
embedded_initrd = False

def __init__(self):
pass

class BuildConfig:
BUILD_TOOL_NONE = None
build_tool = {
'type': BUILD_TOOL_NONE,
'recipe': None
}
build_script = None
build_dir = None
artifacts_dir = None

def __init__(self):
pass

class RunConfig:
NET_TYPE_NONE = None
RUN_TOOL_NONE = None
FS_TYPE_NONE = None
net_type = NET_TYPE_NONE
run_tool = {
'type': RUN_TOOL_NONE,
'config': None
}
fs_type = FS_TYPE_NONE
run_script = None

def __init__(self):
pass

class TestRunner:
pass

c = ConfigVariants()
for i in c.generate_config_variants():
print(i)
Loading