Skip to content

Commit

Permalink
WIP: Add file-specific defines
Browse files Browse the repository at this point in the history
  • Loading branch information
olofk committed Nov 5, 2024
1 parent 8d3d6bc commit 836045c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions fusesoc/capi2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def get_files(self, flags):
if (type(v) == bool and v == True)
or (type(v) == str and len(v)) > 0
or (type(v) == list and len(v)) > 0
or (type(v) == dict and len(v)) > 0
}

_src_files.append(attributes)
Expand Down
19 changes: 19 additions & 0 deletions fusesoc/capi2/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@
"description": "Path to file",
"type": "object",
"properties": {
"define": {
"description": "Defines to be used for this file. These defines will be added to those specified in the target parameters section. If a define is specified both here and in the target parameter section, the value specified here will take precedence. The parameter default value can be set here with ``param=value``",
"type": "object",
"patternProperties": {
"^.+$": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
]
}
}
},
"is_include_file": {
"description": "Treats file as an include file when true",
"type": "boolean"
Expand Down
12 changes: 12 additions & 0 deletions tests/capi2_cores/misc/fileattrs.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CAPI=2:

name : ::fileattrs:0

filesets:
defines:
files:
- hasdefines : {define : {key1 : value1, key2 : value2}}
- nodefines

targets:
defines: {filesets : [defines]}
12 changes: 12 additions & 0 deletions tests/test_capi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ def test_capi2_get_files():

assert expected == result

core_file = os.path.join(tests_dir, "capi2_cores", "misc", "fileattrs.core")
core = Core(Core2Parser(), core_file)
flags = {"is_toplevel": True, "target": "defines"}
result = core.get_files(flags)
expected = [
{"name": "hasdefines", "define": {"key1": "value1", "key2": "value2"}},
{
"name": "nodefines",
},
]
assert expected == result


def test_capi2_type_check():
from fusesoc.capi2.coreparser import Core2Parser
Expand Down

0 comments on commit 836045c

Please sign in to comment.