Skip to content

Commit

Permalink
utils: Use example targets
Browse files Browse the repository at this point in the history
Signed-off-by: Razvan Deaconescu <[email protected]>
  • Loading branch information
razvand committed Dec 8, 2024
1 parent 10e4919 commit 4ee7d7e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions utils/new-design/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,20 @@ def has_networking(self):
def has_rootfs(self):
return self.config['rootfs']

def _get_targets_from_runtime(self):
kraft_proc = subprocess.Popen(["kraft", "pkg", "info", "--log-level", "panic", self.config["runtime"], "-o", "json"], stdout=subprocess.PIPE)
jq_proc = subprocess.Popen(["jq", "-r", ".[] | .plat"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
kraft_output,_ = kraft_proc.communicate()
jq_out,_ = jq_proc.communicate(kraft_output)

targets = []
for full_plat in jq_out.decode().split("\n"):
if full_plat:
plat = full_plat.split("/")[0]
arch = full_plat.split("/")[1]
targets.append((plat, arch))
self.config['targets'] = targets

def _parse_user_config(self, user_config_file):
with open(user_config_file, "r", encoding="utf-8") as stream:
data = yaml.safe_load(stream)
Expand Down Expand Up @@ -567,6 +581,8 @@ def _parse_app_config(self, app_config_file):

if not 'targets' in data.keys():
self.config['targets'] = None
if self.is_example():
self._get_targets_from_runtime()
else:
targets = []
for t in data['targets']:
Expand Down Expand Up @@ -657,6 +673,8 @@ def __init__(self, base_dir, config, target_config, app_config):
self.app_config = app_config
self.kernel_name = f"{self.app_config.config['name']}_{self.config['platform']}-{self.config['arch']}"
self.kernel_path = os.path.join(os.path.join(os.path.join(self.dir, ".unikraft"), "build"), self.kernel_name)
if app_config.is_example():
self.kernel_path = os.path.join(os.path.join(os.path.join(self.dir, ".unikraft"), "bin"), "kernel")

def get_build_tools(plat, arch):
return ["make", "kraft"]
Expand Down Expand Up @@ -898,6 +916,10 @@ def _generate_fs(self):
with open(os.path.join(SCRIPT_DIR, "tpl_build_fs.sh"), "r", encoding="utf-8") as stream:
raw_content = stream.read()

if self.app_config.has_template():
app_dir = os.path.join(os.path.join(self.target_config["base"], "apps"), self.app_config.config['template'])
else:
app_dir = os.getcwd()
base = self.target_config["base"]
target_dir = self.dir
rootfs = os.path.join(os.getcwd(), self.app_config.config["rootfs"])
Expand Down

0 comments on commit 4ee7d7e

Please sign in to comment.