Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for scons_util.py #479

Merged
merged 9 commits into from
Nov 29, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ hardware.svg
abc.history
temp-*
.run.sh
,coverage.*
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
"module": "pytest",
"args": [
"-s",
"test/commands/test_build.py"
"test/test_scons_util.py::test_make_verilator_config_builder"
],
"console": "integratedTerminal",
"justMyCode": false,
Expand Down
4 changes: 2 additions & 2 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ make check
For complete tests with several python versions run the command below.

```shell
make check_all
make check-all
```

For quick tests that that don't load lengthy packagtes from the internet
Expand All @@ -38,7 +38,7 @@ When running any of the commands below, a test coverage is generated in the
```
make test // Partial coverage by offline tests
make check // Full coverage
make check_all // Full coverage by the last python env run.
make check-all // Full coverage by the last python env run.
```


Expand Down
51 changes: 44 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,94 @@
.PHONY: deps cenv env lint test presubmit publish_test publish install

# NOTE: Some targets have a shortcuts or alias names that are listed on the same line.
# The are provided for convinience or for backward competibility. For example
# 'check-all' has the aliases 'check_all' and 'ca'.

# Install dependencies for apio development
#
# Usage:
# make deps
deps:
python -m pip install --upgrade pip
pip install flit black flake8 pylint tox pytest semantic-version pyserial importlib-metadata


# Create the virtual-environment and update dependencies
#
# Usage:
# make cenv
cenv:
python3 -m venv venv
python3 -m venv venv --upgrade


# Usage
# make env
env:
@echo "For entering the virtual-environment just type:"
@echo ". venv/bin/activate"


# Lint only, no tests.
lint:
#
# Usage:
# make lint
# make l
lint l:
python -m tox -e lint


# Offline tests only, no lint, single python version, skipping online tests.
# This is a partial but fast test.
test:
#
# Usage:
# make test
# make t
test t:
python -m tox --skip-missing-interpreters false -e py312 -- --offline


# Tests and lint, single python version, all tests including online..
# This is a thorough but slow test and sufficient for testign before
# commiting changes run this before submitting code.
check:
#
# Usage:
# make check
# make c
check c:
python -m tox --skip-missing-interpreters false -e lint,py312


# Tests and lint, multiple python versions.
# Should be be run automatically on github.
check_all:
#
# Usage:
# make check-all
# make check_all // deprecated, to be deleted.
# make ca
check-all check_all ca:
python -m tox --skip-missing-interpreters false


# Publish to testPypi
publish_test:
#
# Usage:
# make publish-test
# make publish_test // deprecated, to be deleted.
publish-test publish_test:
flit publish --repository testpypi


# Publish to PyPi
#
# Usage:
# make publish
publish:
python -m flit publish

## Install the tool locally
#
# Usage:
# make instll
install:
flit build
flit install

4 changes: 2 additions & 2 deletions apio/resources/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"examples": {
"repository": {
"name": "apio-examples",
"organization": "zapta"
"organization": "FPGAwars"
},
"release": {
"tag_name": "%V",
"compressed_name": "apio-examples-%V",
"uncompressed_name": "apio-examples-%V",
"folder_name": "examples",
"extension": "zip",
"url_version": "https://github.com/zapta/apio-examples/raw/master/VERSION"
"url_version": "https://github.com/FPGAwars/apio-examples/raw/master/VERSION"
},
"description": "Verilog examples",
"env": {}
Expand Down
Empty file added apio/scons/__init__.py
Empty file.
37 changes: 18 additions & 19 deletions apio/scons/ecp5/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import os
from SCons.Script import (
Builder,
AlwaysBuild,
GetOption,
COMMAND_LINE_TARGETS,
ARGUMENTS,
Expand All @@ -50,7 +49,7 @@ from apio.scons.scons_util import (
TARGET,
BUILD_DIR,
SConstructId,
is_testbench,
has_testbench_name,
basename,
is_windows,
get_constraint_file,
Expand All @@ -72,13 +71,13 @@ from apio.scons.scons_util import (
set_up_cleanup,
)

# # -- Uncomment for debugging of the scons subprocess using a remote debugger.
# from apio.scons import scons_util
# scons_util.wait_for_remote_debugger()

# -- Create the environment
env = create_construction_env(ARGUMENTS)

# -- Uncomment for debugging of the scons subprocess using a remote debugger.
# from apio.scons import scons_util
# scons_util.wait_for_remote_debugger(env)

# -- Get arguments.
FPGA_SIZE = arg_str(env, "fpga_size", "")
Expand Down Expand Up @@ -189,11 +188,11 @@ bin_target = env.Bin(TARGET, pnr_target)
build_target = env.Alias("build", bin_target)

if VERBOSE_YOSYS:
AlwaysBuild(synth_target)
env.AlwaysBuild(synth_target)
if VERBOSE_PNR:
AlwaysBuild(pnr_target)
env.AlwaysBuild(pnr_target)
if VERBOSE_ALL:
AlwaysBuild(synth_target, pnr_target, build_target)
env.AlwaysBuild(synth_target, pnr_target, build_target)

# -- Apio report.
# -- Targets.
Expand All @@ -202,15 +201,15 @@ report_action = get_report_action(
env, SConstructId.SCONSTRUCT_ECP5, VERBOSE_PNR
)
report_target = env.Alias("report", PNR_REPORT_FILE, report_action)
AlwaysBuild(report_target)
env.AlwaysBuild(report_target)


# -- Apio upload.
# -- Targets.
# -- hardware.bit -> FPGA.
programmer_cmd = get_programmer_cmd(env)
upload_target = env.Alias("upload", bin_target, programmer_cmd)
AlwaysBuild(upload_target)
env.AlwaysBuild(upload_target)


# -- Apio verify.
Expand Down Expand Up @@ -240,7 +239,7 @@ def iverilog_tb_generator(source, target, env, for_signature):
for a given testbench target."""
# Extract testbench name from target file name.
testbench_file = str(target[0])
assert is_testbench(env, testbench_file), testbench_file
assert has_testbench_name(env, testbench_file), testbench_file
testbench_name = basename(env, testbench_file)

# Construct the command line.
Expand Down Expand Up @@ -300,17 +299,17 @@ env.Append(BUILDERS={"VCD": vcd_builder})
# -- Targets
# -- (modules).v -> (modules).out
verify_out_target = env.IVerilogVerify(TARGET, synth_srcs + test_srcs)
AlwaysBuild(verify_out_target)
env.AlwaysBuild(verify_out_target)
verify_target = env.Alias("verify", verify_out_target)


# -- Apio graph.
# -- Targets.
# -- (modules).v -> hardware.dot -> hardware.svg.
dot_target = env.DOT(TARGET, synth_srcs)
AlwaysBuild(dot_target)
env.AlwaysBuild(dot_target)
graphviz_target = env.GRAPHVIZ(TARGET, dot_target)
AlwaysBuild(graphviz_target)
env.AlwaysBuild(graphviz_target)
graph_target = env.Alias("graph", graphviz_target)


Expand All @@ -324,7 +323,7 @@ if "sim" in COMMAND_LINE_TARGETS:
)
vcd_file_target = env.VCD(sim_out_target)
waves_target = make_waves_target(env, vcd_file_target, sim_config)
AlwaysBuild(waves_target)
env.AlwaysBuild(waves_target)


# -- Apio test.
Expand All @@ -337,9 +336,9 @@ if "test" in COMMAND_LINE_TARGETS:
test_out_target = env.IVerilogTestbench(
sim_config.build_testbench_name, sim_config.srcs
)
AlwaysBuild(test_out_target)
env.AlwaysBuild(test_out_target)
test_vcd_target = env.VCD(test_out_target)
AlwaysBuild(test_vcd_target)
env.AlwaysBuild(test_vcd_target)
test_target = env.Alias(
sim_config.build_testbench_name, [test_out_target, test_vcd_target]
)
Expand All @@ -348,7 +347,7 @@ if "test" in COMMAND_LINE_TARGETS:
# Create a target for the test command that depends on all the test
# targets.
tests_target = env.Alias("test", tests_targets)
AlwaysBuild(tests_target)
env.AlwaysBuild(tests_target)


# -- Apio lint.
Expand Down Expand Up @@ -395,7 +394,7 @@ lint_config_target = env.VerilatorConfig(TARGET, [])
lint_out_target = env.Verilator(TARGET, synth_srcs + test_srcs)
env.Depends(lint_out_target, lint_config_target)
lint_target = env.Alias("lint", lint_out_target)
AlwaysBuild(lint_target)
env.AlwaysBuild(lint_target)


# -- Handle the cleanu of the artifact files.
Expand Down
Loading