JSON-for-VHDL
JSON-for-VHDL copied to clipboard
Bazel currently can't handle spaces in paths (Xilinx ISE, Xilinx Vivado)
Hi!
I'm writing some bazel build/test rules for vunit which in turn depends on JSON-for-vhdl. My rules only concern GHDL at the moment, but any file/repo vunit depends on will be part of the set of files that bazel analyzes. (e.g. Xilinx\ ISE and Xilinx\ Viviado)
Would it be possible to update the paths under tests to not contiain spaces? There is an ongoing issue with the bazel: https://github.com/bazelbuild/bazel/issues/4327 where spaces in paths aren't supported, it isn't for this repository to solve and bazel should support it. But this feels like a faster work around... (unless there are other implications, perhaps the path must contain spaces?)
Sample output from failing test:
link or target filename contains space on line 487: 'py_deps/pypi__vunit_hdl/vunit/vhdl/JSON-for-VHDL/tests/Xilinx ISE/JSON.xise /home/solsjo/.cache/bazel/_bazel_solsjo/b5525a1b2d1def765c8de26cfc81b7d5/external/py_deps/pypi__vunit_hdl/vunit/vhdl/JSON-for-VHDL/tests/Xilinx ISE/JSON.xise'
How does a path in JSON-for-VHDL have an influence on Bazel? Tests are not part of the libraries source code.
How does a path in JSON-for-VHDL have an influence on Bazel? Tests are not part of the libraries source code.
My two cents, The way I employ vunit is that I specify a Bazel py_binary rule that depends on the python package vunit_hdl. The main of the binary is the python vunit test bench configuration (run.py)
vunit_hdl have JSON-for-VHDL as a subrepository.
Since Bazel can't know what files are of importance to my binary; I suspect that Bazel adds all files in vunit_hdl as a runtime dependency of the python binary. And in adding all files to the runfiles directory and the runfiles manifest (files specified to be available to the python binary at runtime) notices that a path among the files contains spaces).
Now, there are other ways of resolving this. (I've made it work previously by explicitly describing in Bazel, what dependencies exist and how to use the vunit python code and vhdl/verilog code)
I can do that instead. I just liked the minimal setup,
py_binary(
name="tb_something",
main="run.py",
deps=[requirement("vunit_hdl")],
data=[":tb_something"],
)
where requirement uses a requirements.txt file that specifies vunit_hdl.
compared to, e.g.
py_binary(
name="tb_something",
main="run.py",
deps=["@rules_vunit//vunit_lib:vunit_main"],
data=[":tb_something"],
)
Where I, as described earlier, need to specify how rules_vunit depends on things internally. (Totally do-able though)
Thanks for the quick reply! :)
I can change the paths, but the main problem is in Bazel taking all files as source files and dependencies. It needs to allow excludes.
Do you install VUnit via PIP or via Git clone? In case of a PIP installation, test cases shouldn't be installed.
/cc @umarcor
I can change the paths, but the main problem is in Bazel taking all files as source files and dependencies. It needs to allow excludes.
- I agree, its on Bazel to handle spaces in paths.
Do you install VUnit via PIP or via Git clone? In case of a PIP installation, test cases shouldn't be installed.
The requirement
construct installs vunit via pip under bazel.
- Yeah, I see, but I think Bazel picks up any file in the package, python file or not.
The JSON-for-VHDL only contains vhdl code / data relevant for the vhdl not python.
From the Bazel perspective the tests in the vunit subrepo JSON-for-VHDL is only data. To ensure hermetic builds it only brings in things that we say we depend on into the Bazel sandbox. Using the
requirment
construct Bazel knows that we depend on files in that package, python and runtime data (vhdl) for compilation. But it can't differentiate between files stored in a test folder (not vhdl) and vhdl code.
I can install it / call via Bazel repository rules, as a http_archive, and reference it as a py_library, similar to the second code example.
But then I need to tell Bazel explicitly how vunit is setup internally.
E.g:
filegroup(
name="only_vhdl",
srcs=glob("**/**/*.vhd)
)
py_binary(
name="vunit_main.py",
deps=[":only_vhdl"],
...
Overall, I think that testing spaces in paths is important, because that's relatively common on Windows. I would propose creating a feature branch where tests are modified, and use that for Bazel testing, while the issue is fixed upstream.
Ack! Thank you! @Paebbels @umarcor