Skip to content

Commit

Permalink
Allow partition build config to be embedded
Browse files Browse the repository at this point in the history
Avoids need for separate file with simple FWFS definitions
  • Loading branch information
mikee47 committed Oct 26, 2021
1 parent 420b592 commit c76a8f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sming/Components/IFS
5 changes: 4 additions & 1 deletion Sming/Components/Storage/Tools/hwconfig/hwconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def handle_partgen(args, config, part):

def handle_expr(args, config, part):
# Evaluate expression against configuration data
return str(eval(args.expr)).encode()
res = eval(args.expr)
if isinstance(res, dict):
return json.dumps(res).encode()
return str(res).encode()


def main():
Expand Down
4 changes: 4 additions & 0 deletions samples/Basic_Templates/app/CsvTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ class CsvTemplate : public SectionTemplate
{
}

// Return true if we have a new valid record, false if not
bool nextRecord() override
{
// Content section we fetch the next data record, if there is one
if(sectionIndex() == 1) {
return csv.next();
}

// This code emits the header and footer sections exactly once
// `recordIndex` starts at -1 (before first record)
return recordIndex() < 0;
}

Expand Down
7 changes: 6 additions & 1 deletion samples/Basic_Templates/basic_templates.hw
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"filename": "out/fwfs1.bin",
"build": {
"target": "fwfs-build",
"config": "fsimage.fwfs"
"config": {
"name": "Basic Templates demo volume",
"source": {
"/": "files"
}
}
},
"readonly": true,
"encrypted": false
Expand Down
6 changes: 0 additions & 6 deletions samples/Basic_Templates/fsimage.fwfs

This file was deleted.

0 comments on commit c76a8f2

Please sign in to comment.