| 1 |
# SPDX-License-Identifier: MIT |
| 2 |
# |
| 3 |
# Copyright The SCons Foundation |
| 4 |
|
| 5 |
import sys |
| 6 |
from SCons.Script.SConsOptions import SConsOptionParser, SConsBadOptionError |
| 7 |
|
| 8 |
DefaultEnvironment(tools=[]) |
| 9 |
|
| 10 |
AddOption( |
| 11 |
'--testing', |
| 12 |
help='Test arg', |
| 13 |
) |
| 14 |
|
| 15 |
if ARGUMENTS.get('raise', 0) == '1': |
| 16 |
ValidateOptions(throw_exception=True) |
| 17 |
elif ARGUMENTS.get('raise', 0) == '2': |
| 18 |
try: |
| 19 |
ValidateOptions(throw_exception=True) |
| 20 |
except SConsBadOptionError as e: |
| 21 |
print( |
| 22 |
f"Parser is SConsOptionParser: {isinstance(e.parser, SConsOptionParser)}" |
| 23 |
) |
| 24 |
print(f"Message is: {e.opt_str}") |
| 25 |
Exit(3) |
| 26 |
else: |
| 27 |
ValidateOptions() |
| 28 |
|
| 29 |
print("This is in SConstruct") |