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

Add flag to change compiler warnings #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions build_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,33 @@ def run_or_die(cmd, error):
success = 0

# expand groups:
use_warnings_all = False
for arg in sys.argv[1:]:
platform = ALL_PLATFORMS.get(arg, None)
if isinstance(platform, str):
platforms.append(arg)
elif isinstance(platform, collections.Iterable):
for p in platform:
platforms.append(p)
if arg == '--compiler-warnings-all':
# This configures arduino-cli to use `compiler.warning_level=all`
# That setting determins which value of `compiler.warning_flags` to use.
# Some platforms (notably ESP32) include `-Werror` which can cause compiler
# errors that we want to test against.
# This is opt-in for now, so libraries can migrate at their own pace.
# Ideally this changes to an opt-out flag eventually.
use_warnings_all = True
else:
print("Unknown platform: ", arg)
exit(-1)
platform = ALL_PLATFORMS.get(arg, None)
if isinstance(platform, str):
platforms.append(arg)
elif isinstance(platform, collections.Iterable):
for p in platform:
platforms.append(p)
else:
print("Unknown platform: ", arg)
exit(-1)

def test_examples_in_folder(folderpath):
def test_examples_in_folder(folderpath, use_warnings_all=False):
global success
for example in sorted(os.listdir(folderpath)):
examplepath = folderpath+"/"+example
if os.path.isdir(examplepath):
test_examples_in_folder(examplepath)
test_examples_in_folder(examplepath, use_warnings_all)
continue
if not examplepath.endswith(".ino"):
continue
Expand All @@ -210,7 +220,10 @@ def test_examples_in_folder(folderpath):
ColorPrint.print_warn("skipping")
continue

cmd = ['arduino-cli', 'compile', '--fqbn', fqbn, examplepath]
if use_warnings_all:
cmd = ['arduino-cli', 'compile', '--warnings', 'all', '--fqbn', fqbn, examplepath]
else:
cmd = ['arduino-cli', 'compile', '--fqbn', fqbn, examplepath]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
r = proc.wait()
Expand Down Expand Up @@ -267,7 +280,7 @@ def test_examples_in_learningrepo(folderpath):
install_platform(":".join(fqbn.split(':', 2)[0:2])) # take only first two elements
print('#'*80)
if not IS_LEARNING_SYS:
test_examples_in_folder(BUILD_DIR+"/examples")
test_examples_in_folder(BUILD_DIR+"/examples", use_warnings_all)
else:
test_examples_in_folder(BUILD_DIR)
test_examples_in_folder(BUILD_DIR, use_warnings_all)
exit(success)