Skip to content

Commit

Permalink
cmds: add new sandbox modes to remaining commands
Browse files Browse the repository at this point in the history
This does not actually add any new behaviour. But it makes the remaining
commands consistent with the build/dev/jenkins commands by accepting the
same options.
  • Loading branch information
jkloetzke committed Oct 13, 2024
1 parent 5f340e8 commit 8082a75
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
27 changes: 21 additions & 6 deletions pym/bob/cmds/build/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ...generators import generators as defaultGenerators
from ...input import RecipeSet
from ...tty import colorize
from ...utils import processDefines
from ...utils import processDefines, SandboxMode
import argparse
import os

Expand Down Expand Up @@ -48,9 +48,15 @@ def _downloadArg(arg):
parser.add_argument('-j', '--jobs', default=None, type=int, nargs='?', const=...,
help="Specifies the number of jobs to run simultaneously.")
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
group.add_argument('--sandbox', action='store_const', const="yes", default=None,
help="Enable partial sandboxing")
group.add_argument('--slim-sandbox', action='store_const', const="slim", dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_const', const="dev", dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_const', const="strict", dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_const', const="no", dest='sandbox',
help="Disable sandboxing")
args = parser.parse_args(argv)

Expand All @@ -68,7 +74,9 @@ def _downloadArg(arg):
nameFormatter = recipes.getHook('developNameFormatter')
developPersister = DevelopDirOracle(nameFormatter, recipes.getHook('developNamePersister'))
nameFormatter = LocalBuilder.makeRunnable(developPersister.getFormatter())
packages = recipes.generatePackages(nameFormatter, args.sandbox)
sandboxMode = SandboxMode(args.sandbox)
packages = recipes.generatePackages(nameFormatter, sandboxMode.sandboxEnabled,
sandboxMode.stablePaths)
developPersister.prime(packages)

generators = defaultGenerators.copy()
Expand Down Expand Up @@ -98,7 +106,14 @@ def _downloadArg(arg):
extra.append('-e')
extra.append(e)
if args.preserve_env: extra.append('-E')
if args.sandbox: extra.append('--sandbox')
if args.sandbox == "yes":
extra.append('--sandbox')
elif args.sandbox == "slim":
extra.append('--slim-sandbox')
elif args.sandbox == "dev":
extra.append('--dev-sandbox')
elif args.sandbox == "strict":
extra.append('--strict-sandbox')
if args.jobs is ...:
# expand because we cannot control the argument order in the generator
args.jobs = os.cpu_count()
Expand Down
12 changes: 10 additions & 2 deletions pym/bob/cmds/build/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ def doQueryPath(argv, bobRoot):
help="Return a non-zero error code in case of errors")

group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', help="Enable sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing")
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")
parser.set_defaults(sandbox=None)

group = parser.add_mutually_exclusive_group()
Expand Down
6 changes: 6 additions & 0 deletions pym/bob/cmds/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ def doGraph(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")
parser.add_argument('--destination', metavar="DEST",
Expand Down
24 changes: 24 additions & 0 deletions pym/bob/cmds/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def doLS(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")
args = parser.parse_args(argv)
Expand Down Expand Up @@ -138,6 +144,12 @@ def doQueryMeta(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")
args = parser.parse_args(argv)
Expand Down Expand Up @@ -196,6 +208,12 @@ def doQuerySCM(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")

Expand Down Expand Up @@ -258,6 +276,12 @@ def doQueryRecipe(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")

Expand Down
6 changes: 6 additions & 0 deletions pym/bob/cmds/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ def doShow(argv, bobRoot):
group = parser.add_mutually_exclusive_group()
group.add_argument('--sandbox', action='store_true', default=False,
help="Enable sandboxing")
group.add_argument('--slim-sandbox', action='store_false', dest='sandbox',
help="Enable slim sandboxing")
group.add_argument('--dev-sandbox', action='store_true', dest='sandbox',
help="Enable development sandboxing")
group.add_argument('--strict-sandbox', action='store_true', dest='sandbox',
help="Enable strict sandboxing")
group.add_argument('--no-sandbox', action='store_false', dest='sandbox',
help="Disable sandboxing")

Expand Down

0 comments on commit 8082a75

Please sign in to comment.