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 2b82a60
Show file tree
Hide file tree
Showing 4 changed files with 30 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
6 changes: 6 additions & 0 deletions tests/capi2_cores/misc/files.core
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ CAPI=2:

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

logical_name:
files:
- vlogfile : {logical_name : overridden_logical_name}
Expand Down Expand Up @@ -47,6 +52,7 @@ scripts:
targets:
default:
filesets: [
defines,
logical_name,
copyfiles,
miscfiles,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_capi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ def test_capi2_get_files():
core = Core(Core2Parser(), core_file)

expected = [
{"name": "hasdefines", "define": {"key1": "value1", "key2": "value2"}},
{
"name": "nodefines",
},
{
"file_type": "vhdlSource",
"logical_name": "overridden_logical_name",
Expand Down

0 comments on commit 2b82a60

Please sign in to comment.