Exemple #1
0
def parse_args():
    """Command line argument parsing."""
    global ssdroot_list, flag_report_nonvol, flag_sort_modtime
    global flag_only_repos, flag_terse_output, flag_showsize

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dnmrstz")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-r":
            flag_only_repos = True
        elif opt == "-m":
            flag_terse_output = True
        elif opt == "-z":
            flag_showsize = True
        elif opt == "-t":
            flag_sort_modtime = True
        elif opt == "-n":
            flag_report_nonvol = False

    if not args:
        ssdroot_list = find_ssdroots()
    else:
        ssdroot_list = find_ssdroot_from_args(args)
    if flag_showsize and flag_terse_output:
        usage("-m and -z options are incompatible")
def parse_args():
  """Command line argument parsing."""
  global flag_dryrun, flag_mode, flag_noclean

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "hdDSF:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-h":
      usage()
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-S":
      flag_noclean = True
    elif opt == "-F":
      if os.path.exists(arg):
        u.verbose(0, "adding %s to cmakefiles dict" % arg)
        cmakefiles[arg] = 1
      else:
        u.error("-F arg %s doesn't seem to exist" % arg)

  # Check for mode
  if len(args) != 1:
    usage("supply a single mode argument (either 'pre' or 'post')")
  if args[0] == "pre":
    flag_mode = "pre"
  elif args[0] == "post":
    flag_mode = "post"
  else:
    usage("unknown mode argument %s" % args[0])
Exemple #3
0
def parse_env_options():
  """Option parsing from env var."""
  global flag_echo, flag_dryrun, flag_nollvm, flag_trace_llinvoc

  optstr = os.getenv("GOLLVM_WRAP_OPTIONS")
  if not optstr:
    return
  args = optstr.split()

  try:
    optlist, _ = getopt.getopt(args, "detDG")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-e":
      flag_echo = True
    elif opt == "-t":
      flag_trace_llinvoc = True
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-G":
      flag_nollvm = True
  u.verbose(1, "env var options parsing complete")
Exemple #4
0
def parse_args():
    """Command line argument parsing."""
    global flag_echo, flag_dryrun, flag_tag, flag_script_to_run, flag_pkgtests

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dmneDp:t:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    if args:
        usage("unknown extra args: %s" % " ".join(args))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-m":
            flag_script_to_run = "make.bash"
        elif opt == "-n":
            flag_script_to_run = None
        elif opt == "-D":
            u.verbose(0, "+++ dry run mode")
            flag_dryrun = True
            flag_echo = True
        elif opt == "-e":
            flag_echo = True
        elif opt == "-t":
            flag_tag = arg
        elif opt == "-p":
            if not os.path.exists(arg):
                u.warning("can't access package %s, ignored for -p" % arg)
            flag_pkgtests.append(arg)
Exemple #5
0
def parse_args():
    """Command line argument parsing."""
    global flag_dryrun, flag_mode, flag_noclean

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "hdDSF:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-h":
            usage()
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-S":
            flag_noclean = True
        elif opt == "-F":
            if os.path.exists(arg):
                u.verbose(0, "adding %s to cmakefiles dict" % arg)
                cmakefiles[arg] = 1
            else:
                u.error("-F arg %s doesn't seem to exist" % arg)

    # Check for mode
    if len(args) != 1:
        usage("supply a single mode argument (either 'pre' or 'post')")
    if args[0] == "pre":
        flag_mode = "pre"
    elif args[0] == "post":
        flag_mode = "post"
    else:
        usage("unknown mode argument %s" % args[0])
Exemple #6
0
def parse_args():
  """Command line argument parsing."""
  global flag_subvol, flag_echo, flag_dryrun, flag_llvm_build
  global flag_echo

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "deDs:b:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if args:
    usage("unknown extra arguments")

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      flag_dryrun = True
      flag_echo = True
    elif opt == "-e":
      flag_echo = True
    elif opt == "-s":
      flag_subvol = arg
    elif opt == "-b":
      flag_llvm_build = arg

  if not flag_subvol:
    usage("specify subvol name with -s")
  if not flag_llvm_build:
    usage("specify default LLVM compiler build dir with -b")
  clang = "%s/%s" % (flag_llvm_build, "bin/clang")
  if not os.path.exists(clang):
    usage("unable to locate clang in %s/bin" % flag_llvm_build)
Exemple #7
0
def parse_args():
    """Command line argument parsing."""

    global flag_subcommand, flag_subcommand_args

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "d")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()

    if not args:
        usage("specify subcommand")

    flag_subcommand = args[0]
    if flag_subcommand not in possible_subcommands:
        usage("unknown subcommand %s" % flag_subcommand)
    nargs = len(args) - 1
    if nargs < 1:
        usage("no subcommand arguments specified")
    flag_subcommand_args = args[1:]
    req_args = possible_subcommands[flag_subcommand]
    if nargs != req_args:
        usage("subcommand %s requires %d args, %d supplied" %
              (flag_subcommand, req_args, nargs))

    if not flag_homedir:
        usage("environment variable HOME not set")
def parse_args():
    """Command line argument parsing."""
    global flag_echo, flag_dryrun, flag_allbranches

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dDea")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))
    for b in args:
        flag_branches[b] = 1

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-D":
            flag_dryrun = True
            flag_echo = True
        elif opt == "-e":
            flag_echo = True
        elif opt == "-a":
            flag_allbranches = True
            if args:
                usage("if -a is used, don't supply branch names")
    if not flag_branches and not flag_allbranches:
        usage("supply a branch name as arg, or use -a option")
Exemple #9
0
def parse_args():
    """Command line argument parsing."""
    global flag_ndk_repo, flag_toolchain_repo, flag_create_platform_links
    global flag_echo, flag_dryrun, flag_workdir, flag_gcc_version

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dn:t:w:g:qDP")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-q":
            flag_echo = False
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-P":
            flag_create_platform_links = True
        elif opt == "-n":
            flag_ndk_repo = arg
        elif opt == "-t":
            flag_toolchain_repo = arg
        elif opt == "-w":
            flag_workdir = arg
        elif opt == "-g":
            flag_gcc_version = arg

    if args:
        usage("unknown extra args")
    if not flag_ndk_repo:
        usage("specify ndk repo path -n")
Exemple #10
0
def parse_args():
    """Command line argument parsing."""
    global flag_dryrun, flag_echo, flag_outdir, flag_infile

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "deo:i:D")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))
    if args:
        usage("unknown extra args")

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-e":
            flag_echo = True
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-o":
            flag_outdir = arg
            if not os.path.exists(flag_outdir):
                usage("argument to -o flag '%s' not accessible" % arg)
            if not os.path.isdir(flag_outdir):
                usage("argument to -o flag '%s' not a directory" % arg)
        elif opt == "-i":
            flag_infile = arg
            if not os.path.exists(flag_infile):
                usage("argument to -i flag '%s' not accessible" % arg)
    if not flag_outdir:
        usage("supply out dir path with -o")
    if not flag_infile:
        usage("supply input file path with -i")
def parse_args():
    """Command line argument parsing."""
    global flag_dryrun, flag_echo, flag_reverse

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dDR")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))
    if args:
        usage("unknown extra args")

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-D":
            flag_dryrun = True
            flag_echo = True
        elif opt == "-R":
            flag_reverse = True

    if not os.path.exists("gcc"):
        usage("expected to find gcc subdir")
    if not os.path.exists("libgo"):
        usage("expected to find libgo subdir")
    if not os.path.exists("../gofrontend"):
        usage("expected to find ../gofrontend subdir")
def parse_args():
  """Command line argument parsing."""
  global flag_infile, flag_outfile, flag_strip_offsets, flag_strip_pcinfo
  global flag_annotate_abstract, flag_normalize

  try:
    optlist, _ = getopt.getopt(sys.argv[1:], "di:o:u:SPAN")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-i":
      flag_infile = arg
    elif opt == "-o":
      flag_outfile = arg
    elif opt == "-S":
      flag_strip_offsets = True
    elif opt == "-P":
      flag_strip_pcinfo = True
    elif opt == "-A":
      flag_annotate_abstract = False
    elif opt == "-N":
      flag_normalize = False
    elif opt == "-u":
      flag_compunits[arg] = 1
Exemple #13
0
def parse_args():
    """Command line argument parsing."""
    global flag_infiles

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "d")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))
    if not args:
        usage("supply one or more link paths as arguments")

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
    for a in args:
        if not os.path.exists(a):
            u.warning("failed to open/access '%s' -- skipping" % a)
        else:
            try:
                p = os.readlink(a)
            except OSError as ose:
                u.warning("unable to process '%s' -- %s" % (a, ose))
                continue
            flag_infiles.append(a)
Exemple #14
0
def parse_args():
  """Command line argument parsing."""

  global flag_subcommand, flag_subcommand_args

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()

  if not args:
    usage("specify subcommand")

  flag_subcommand = args[0]
  if flag_subcommand not in possible_subcommands:
    usage("unknown subcommand %s" % flag_subcommand)
  nargs = len(args) - 1
  if nargs < 1:
    usage("no subcommand arguments specified")
  flag_subcommand_args = args[1:]
  req_args = possible_subcommands[flag_subcommand]
  if nargs != req_args:
    usage("subcommand %s requires %d args, %d supplied" %
          (flag_subcommand, req_args, nargs))

  if not flag_homedir:
    usage("environment variable HOME not set")
def parse_args():
    """Command line argument parsing."""
    global flag_dryrun, flag_reverse
    global flag_source_dir, flag_dest_dir

    try:
        optlist, _ = getopt.getopt(sys.argv[1:], "dD:S:CR")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-D":
            flag_dest_dir = arg
        elif opt == "-S":
            flag_source_dir = arg
        elif opt == "-C":
            flag_dryrun = False
        elif opt == "-R":
            flag_reverse = True

    if not os.path.exists(flag_source_dir):
        usage("source dir %s does not exist" % flag_source_dir)
    if not os.path.isdir(flag_source_dir):
        usage("source dir %s is not a directory" % flag_source_dir)
    if not os.path.exists(flag_dest_dir):
        usage("dest dir %s does not exist" % flag_dest_dir)
    if not os.path.isdir(flag_dest_dir):
        usage("dest dir %s is not a directory" % flag_dest_dir)
    if flag_reverse:
        flag_source_dir, flag_dest_dir = flag_dest_dir, flag_source_dir
    u.verbose(1, "src dir: %s" % flag_source_dir)
    u.verbose(1, "dst dir: %s" % flag_dest_dir)
def parse_args():
  """Command line argument parsing."""
  global flag_dryrun, flag_echo, flag_outdir, flag_infile

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "deo:i:D")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if args:
    usage("unknown extra args")

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-e":
      flag_echo = True
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-o":
      flag_outdir = arg
      if not os.path.exists(flag_outdir):
        usage("argument to -o flag '%s' not accessible" % arg)
      if not os.path.isdir(flag_outdir):
        usage("argument to -o flag '%s' not a directory" % arg)
    elif opt == "-i":
      flag_infile = arg
      if not os.path.exists(flag_infile):
        usage("argument to -i flag '%s' not accessible" % arg)
  if not flag_outdir:
    usage("supply out dir path with -o")
  if not flag_infile:
    usage("supply input file path with -i")
def parse_args():
  """Command line argument parsing."""
  global flag_dryrun, flag_echo, flag_reverse

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dDR")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if args:
    usage("unknown extra args")

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      flag_dryrun = True
      flag_echo = True
    elif opt == "-R":
      flag_reverse = True

  if not os.path.exists("gcc"):
    usage("expected to find gcc subdir")
  if not os.path.exists("libgo"):
    usage("expected to find libgo subdir")
  if not os.path.exists("../gofrontend"):
    usage("expected to find ../gofrontend subdir")
Exemple #18
0
def parse_args():
  """Command line argument parsing."""

  global whichdev

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()

  if args:
    usage("unrecognized arg")

  # Check to make sure we can run adb
  u.doscmd("which adb")

  # Collect device flavor
  lines = u.docmdlines("whichdevice.sh")
  if len(lines) != 1:
    u.error("unexpected output from whichdevice.sh")
  whichdev = lines[0].strip()
  u.verbose(1, "device: %s" % whichdev)
def parse_args():
  """Command line argument parsing."""
  global flag_infile, flag_outfile, flag_single, flag_parfactor
  global flag_exclude_host, flag_exclude_target, flag_target
  global flag_unique

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "HTdaui:o:t:j:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("extra unknown arguments")
  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-a":
      flag_single = False
    elif opt == "-u":
      flag_unique = True
    elif opt == "-i":
      flag_infile = arg
    elif opt == "-o":
      flag_outfile = arg
    elif opt == "-t":
      flag_target = arg
    elif opt == "-j":
      flag_parfactor = int(arg)
    elif opt == "-H":
      flag_exclude_host = True
    elif opt == "-T":
      flag_exclude_target = True
  if flag_single:
    flag_parfactor = 0
Exemple #20
0
def parse_args():
  """Command line argument parsing."""
  global ssdroot_list, flag_report_nonvol, flag_sort_modtime
  global flag_only_repos, flag_terse_output, flag_showsize

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dnmrstz")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-r":
      flag_only_repos = True
    elif opt == "-m":
      flag_terse_output = True
    elif opt == "-z":
      flag_showsize = True
    elif opt == "-t":
      flag_sort_modtime = True
    elif opt == "-n":
      flag_report_nonvol = False

  if not args:
    ssdroot_list = find_ssdroots()
  else:
    ssdroot_list = find_ssdroot_from_args(args)
  if flag_showsize and flag_terse_output:
    usage("-m and -z options are incompatible")
def parse_args():
  """Command line argument parsing."""
  global flag_repo, flag_pflags, flag_addmx

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "xdr:f:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("unknown extra args: %s" % " ".join(args))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-x":
      flag_addmx = True
    elif opt == "-r":
      if not os.path.exists(arg):
        usage("can't access -A argument %s" % arg)
      flag_repo = arg
    elif opt == "-f":
      flag_pflags = arg.split(",")

  if not flag_pflags:
    usage("no -f option specified")
  if not flag_repo:
    usage("no -r option specified")
def parse_args():
  """Command line argument parsing."""
  global flag_echo, flag_dryrun, flag_allbranches

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dDea")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  for b in args:
    flag_branches[b] = 1

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      flag_dryrun = True
      flag_echo = True
    elif opt == "-e":
      flag_echo = True
    elif opt == "-a":
      flag_allbranches = True
      if args:
        usage("if -a is used, don't supply branch names")
  if not flag_branches and not flag_allbranches:
    usage("supply a branch name as arg, or use -a option")
Exemple #23
0
def parse_args():
  """Command line argument parsing."""
  global flag_infiles

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if not args:
    usage("supply one or more link paths as arguments")

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
  for a in args:
    if not os.path.exists(a):
      u.warning("failed to open/access '%s' -- skipping" % a)
    else:
      try:
        p = os.readlink(a)
      except OSError as ose:
        u.warning("unable to process '%s' -- %s" % (a, ose))
        continue
      flag_infiles.append(a)
def parse_args():
    """Command line argument parsing."""
    global flag_repo, flag_pflags, flag_addmx

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "xdr:f:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    if args:
        usage("unknown extra args: %s" % " ".join(args))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-x":
            flag_addmx = True
        elif opt == "-r":
            if not os.path.exists(arg):
                usage("can't access -A argument %s" % arg)
            flag_repo = arg
        elif opt == "-f":
            flag_pflags = arg.split(",")

    if not flag_pflags:
        usage("no -f option specified")
    if not flag_repo:
        usage("no -r option specified")
Exemple #25
0
def parse_env_options():
    """Option parsing from env var."""
    global flag_echo, flag_dryrun, flag_nollvm, flag_trace_llinvoc

    optstr = os.getenv("GOLLVM_WRAP_OPTIONS")
    if not optstr:
        return
    args = optstr.split()

    try:
        optlist, _ = getopt.getopt(args, "detDG")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-e":
            flag_echo = True
        elif opt == "-t":
            flag_trace_llinvoc = True
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-G":
            flag_nollvm = True
    u.verbose(1, "env var options parsing complete")
def parse_args():
  """Command line argument parsing."""
  global flag_outfile, flag_echo, flag_dryrun
  global flag_ninjatracing, flag_catapult

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "edDo:N:C:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("extra unknown arguments")
  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-e":
      flag_echo = True
    elif opt == "-N":
      flag_ninjatracing = arg
    elif opt == "-C":
      flag_catapult = arg
    elif opt == "-o":
      flag_outfile = arg
def parse_args():
  """Command line argument parsing."""
  global flag_dryrun, flag_reverse
  global flag_source_dir, flag_dest_dir

  try:
    optlist, _ = getopt.getopt(sys.argv[1:], "dD:S:CR")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      flag_dest_dir = arg
    elif opt == "-S":
      flag_source_dir = arg
    elif opt == "-C":
      flag_dryrun = False
    elif opt == "-R":
      flag_reverse = True

  if not os.path.exists(flag_source_dir):
    usage("source dir %s does not exist" % flag_source_dir)
  if not os.path.isdir(flag_source_dir):
    usage("source dir %s is not a directory" % flag_source_dir)
  if not os.path.exists(flag_dest_dir):
    usage("dest dir %s does not exist" % flag_dest_dir)
  if not os.path.isdir(flag_dest_dir):
    usage("dest dir %s is not a directory" % flag_dest_dir)
  if flag_reverse:
    flag_source_dir, flag_dest_dir = flag_dest_dir, flag_source_dir
  u.verbose(1, "src dir: %s" % flag_source_dir)
  u.verbose(1, "dst dir: %s" % flag_dest_dir)
def parse_args():
  """Command line argument parsing."""
  global flag_aosp_link, flag_toolchain_link
  global flag_echo, flag_dryrun, flag_ndk_builddir
  global flag_gcc_version, flag_isl_version, flag_arches
  global aosp_ndk_link, aosp_toolchain_link, flag_hostopt
  global flag_build_debuggable, flag_parallel

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "da:b:n:t:g:i:qDwCW")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  flag_arches = legal_arches.keys()
  specific_arches = {}
  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-q":
      flag_echo = False
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-C":
      flag_build_debuggable = True
    elif opt == "-n":
      flag_aosp_link = arg
    elif opt == "-p":
      flag_parallel = True
    elif opt == "-t":
      flag_toolchain_link = arg
    elif opt == "-b":
      flag_ndk_builddir = arg
    elif opt == "-g":
      flag_gcc_version = arg
    elif opt == "-i":
      flag_isl_version = arg
    elif opt == "-w":
      flag_hostopt = "windows"
    elif opt == "-W":
      flag_hostopt = "windows64"
    elif opt == "-a":
      if arg not in legal_arches:
        usage("specified arch %s not part of legal list" % arg)
      specific_arches[arg] = 1
  if specific_arches:
    flag_arches = sorted(specific_arches.keys())

  if args:
    usage("unknown extra args")
  aosp_ndk_link = "%s/ndk" % flag_aosp_link
  if flag_toolchain_link:
    aosp_toolchain_link = flag_toolchain_link
  else:
    aosp_toolchain_link = "%s/toolchain" % flag_aosp_link
  if not os.path.exists(aosp_ndk_link):
    usage("unable to access %s" % aosp_ndk_link)
  if not os.path.exists(aosp_toolchain_link):
    usage("unable to access %s" % aosp_toolchain_link)
Exemple #29
0
def parse_args():
    """Command line argument parsing."""
    global flag_aosp_link, flag_toolchain_link
    global flag_echo, flag_dryrun, flag_ndk_builddir
    global flag_gcc_version, flag_isl_version, flag_arches
    global aosp_ndk_link, aosp_toolchain_link, flag_hostopt
    global flag_build_debuggable, flag_parallel

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "da:b:n:t:g:i:qDwCW")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    flag_arches = legal_arches.keys()
    specific_arches = {}
    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-q":
            flag_echo = False
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-C":
            flag_build_debuggable = True
        elif opt == "-n":
            flag_aosp_link = arg
        elif opt == "-p":
            flag_parallel = True
        elif opt == "-t":
            flag_toolchain_link = arg
        elif opt == "-b":
            flag_ndk_builddir = arg
        elif opt == "-g":
            flag_gcc_version = arg
        elif opt == "-i":
            flag_isl_version = arg
        elif opt == "-w":
            flag_hostopt = "windows"
        elif opt == "-W":
            flag_hostopt = "windows64"
        elif opt == "-a":
            if arg not in legal_arches:
                usage("specified arch %s not part of legal list" % arg)
            specific_arches[arg] = 1
    if specific_arches:
        flag_arches = sorted(specific_arches.keys())

    if args:
        usage("unknown extra args")
    aosp_ndk_link = "%s/ndk" % flag_aosp_link
    if flag_toolchain_link:
        aosp_toolchain_link = flag_toolchain_link
    else:
        aosp_toolchain_link = "%s/toolchain" % flag_aosp_link
    if not os.path.exists(aosp_ndk_link):
        usage("unable to access %s" % aosp_ndk_link)
    if not os.path.exists(aosp_toolchain_link):
        usage("unable to access %s" % aosp_toolchain_link)
Exemple #30
0
def parse_args():
    """Command line argument parsing."""
    global flag_echo, flag_dryrun, flag_infiles, flag_outdir, flag_tag
    global flag_binary, flag_pprof_path, flag_memvariants

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dmeDi:o:t:p:b:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    if args:
        usage("unknown extra args: %s" % " ".join(args))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-D":
            u.verbose(0, "+++ dry run mode")
            flag_dryrun = True
            flag_echo = True
        elif opt == "-e":
            flag_echo = True
        elif opt == "-m":
            flag_memvariants = True
        elif opt == "-i":
            infiles = arg.split(":")
            u.verbose(1, "%d input files" % len(infiles))
            for inf in infiles:
                if not os.path.exists(inf):
                    usage("unable to access -i input file %s" % inf)
                flag_infiles.append(inf)
        elif opt == "-o":
            if not os.path.exists(arg):
                usage("unable to access -o argument %s" % arg)
            if not os.path.isdir(arg):
                usage("-o argument %s not a directory" % arg)
            flag_outdir = arg
        elif opt == "-p":
            if not os.path.exists(arg):
                usage("unable to access -p argument %s" % arg)
            flag_pprof_path = arg
        elif opt == "-t":
            flag_tag = arg
        elif opt == "-b":
            if not os.path.exists(arg):
                usage("unable to access -b argument %s" % arg)
            flag_binary = arg

    if not flag_infiles:
        usage("supply input files with -i")
    if not flag_outdir:
        usage("supply output dir with -o")
    if not flag_binary:
        usage("supply executable path with -b")
def parse_args():
  """Command line argument parsing."""

  global flag_check_in_symbols, flag_filemode
  global flag_input_files, apo, abt, aho
  global flag_restrict_elf, flag_outfile, flag_prune
  global flag_backward_slice

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dpHB:Xr:o:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-p":
      flag_prune = True
    elif opt == "-H":
      flag_filemode = "host"
    elif opt == "-B":
      backdepth = int(arg)
      if backdepth < 1:
        u.usage("use positive arg for -B")
      flag_backward_slice = backdepth
    elif opt == "-r":
      if arg == "32":
        flag_restrict_elf = 32
      elif arg == "64":
        flag_restrict_elf = 64
      else:
        usage("argument to -r option must be either 32 or 64")
    elif opt == "-X":
      flag_check_in_symbols = False
    elif opt == "-o":
      flag_outfile = arg

  if not args:
    usage("specify at least one input file")

  for a in args:
    if not os.path.exists(a):
      usage("unable to read/access input arg %s" % a)
  flag_input_files = args

  abt = os.getenv("ANDROID_BUILD_TOP")
  if abt is None:
    u.error("ANDROID_BUILD_TOP not set (did you run lunch?)")
  apo = os.getenv("ANDROID_PRODUCT_OUT")
  if apo is None:
    u.error("ANDROID_PRODUCT_OUT not set (did you run lunch?)")
  aho = os.getenv("ANDROID_HOST_OUT")
  if aho is None:
    u.error("ANDROID_HOST_OUT not set (did you run lunch?)")
def parse_args():
  """Command line argument parsing."""
  global flag_echo, flag_dryrun, flag_infiles, flag_outdir, flag_tag
  global flag_binary, flag_pprof_path

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "deDi:o:t:p:b:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("unknown extra args: %s" % " ".join(args))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      u.verbose(0, "+++ dry run mode")
      flag_dryrun = True
      flag_echo = True
    elif opt == "-e":
      flag_echo = True
    elif opt == "-i":
      infiles = arg.split(":")
      u.verbose(1, "%d input files" % len(infiles))
      for inf in infiles:
        if not os.path.exists(inf):
          usage("unable to access -i input file %s" % inf)
        flag_infiles.append(inf)
    elif opt == "-o":
      if not os.path.exists(arg):
        usage("unable to access -o argument %s" % arg)
      if not os.path.isdir(arg):
        usage("-o argument %s not a directory" % arg)
      flag_outdir = arg
    elif opt == "-p":
      if not os.path.exists(arg):
        usage("unable to access -p argument %s" % arg)
      flag_pprof_path = arg
    elif opt == "-t":
      flag_tag = arg
    elif opt == "-b":
      if not os.path.exists(arg):
        usage("unable to access -b argument %s" % arg)
      flag_binary = arg

  if not flag_infiles:
    usage("supply input files with -i")
  if not flag_outdir:
    usage("supply output dir with -o")
  if not flag_tag:
    usage("supply tag with -t")
  if not flag_binary:
    usage("supply executable path with -b")
Exemple #33
0
def parse_args():
  """Command line argument parsing."""
  global flag_echo, flag_dryrun, flag_dwarf_cu, flag_dumpdwarf

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "deDa:f:m:W:Z")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("unknown extra args")

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-D":
      u.verbose(0, "+++ dry run mode")
      flag_dryrun = True
      flag_echo = True
    elif opt == "-e":
      flag_echo = True
    elif opt == "-f":
      flag_functions[arg] = 1
    elif opt == "-a":
      are = re.compile(r"^0x(\S+)$")
      m = are.match(arg)
      if not m:
        u.warning("ignore -a arg '%s' -- not in form 0x<hexdigits>" % arg)
      else:
        hd = m.group(1)
        good = True
        v = "bad"
        try:
          v = int(hd, 16)
        except ValueError:
          good = False
          u.warning("ignore -a arg '%s' -- not in form 0x<hexdigits>" % arg)
        if good:
          u.verbose(1, "looking for addr %s dec %d" % (arg, v))
          flag_addresses[v] = 1
    elif opt == "-m":
      flag_loadmodules[arg] = 1
    elif opt == "-W":
      flag_dwarf_cu = arg
    elif opt == "-Z":
      flag_dumpdwarf = True

  # Make sure at least one function, loadmodule, or addr
  if not flag_functions and not flag_addresses:
    usage("specify function name with -f or address with -a")
  if not flag_loadmodules:
    usage("specify loadmodule with -m")
  if len(flag_loadmodules) > 1 and flag_dwarf_cu:
    usage("use only single loadmodule with -W option")
Exemple #34
0
def parse_args():
  """Command line argument parsing."""
  global flag_echo, flag_dryrun, flag_google, flag_flavor
  global flag_show_output, flag_49_branch, flag_5_branch
  global flag_dogo, flag_use_mirrors, flag_prereqs, flag_mkbuilds

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dbBeDPGMBXgsf:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-e":
      flag_echo = True
    elif opt == "-g":
      flag_google = True
    elif opt == "-G":
      flag_dogo = True
    elif opt == "-P":
      flag_prereqs = True
    elif opt == "-M":
      flag_use_mirrors = True
    elif opt == "-b":
      flag_49_branch = True
    elif opt == "-B":
      flag_5_branch = True
    elif opt == "-X":
      flag_mkbuilds = False
    elif opt == "-s":
      flag_show_output = True
    elif opt == "-f":
      if arg not in flavors:
        usage("flavor %s not in set of legal "
              "flavors: %s" % (arg, " ".join(flavors.keys())))
      flag_flavor = arg
    elif opt == "-D":
      flag_dryrun = True
      flag_echo = True

  if args:
    usage("unknown extra args")
  if not flag_flavor:
    usage("select a flavor")
  if flag_49_branch and flag_google:
    usage("pick either -b or -g (not both)")
  if flag_49_branch and flag_flavor != "svn":
    usage("-b option requires -f svn")
  if flag_5_branch and flag_flavor != "svn":
    usage("-B option requires -f svn")
  if flag_5_branch and flag_49_branch:
    usage("select one of -B / -b but not both")
def parse_args():
    """Command line argument parsing."""
    global flag_offset_to_find, flag_loadmodule, flag_objdump

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dm:x:T:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    if args:
        usage("unknown extra args")

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-T":
            flag_objdump = arg
        elif opt == "-x":
            r = re.compile(r"^0x(\S+)$")
            m = r.match(arg)
            if not m:
                usage(
                    "supply argument of the form 0x<hexliteral> to -x option")
            hexdigits = m.group(1)
            try:
                v = int(hexdigits, 16)
            except ValueError:
                usage(
                    "supply argument of the form 0x<hexliteral> to -x option")
            u.verbose(
                1, "restricting output to compunit "
                "containing DIE offset %x\n" % v)
            flag_offset_to_find = v
        elif opt == "-m":
            if not os.path.exists(arg):
                usage("argument '%s' to -m option does not exist" % arg)
            flag_loadmodule = arg

    # Make sure at least one function, loadmodule
    if not flag_loadmodule:
        usage("specify loadmodule -m")
    if not flag_offset_to_find:
        usage("specify offset to find with -x")

    # Pick objdump variant based on Os.
    if not flag_objdump:
        lines = u.docmdlines("uname")
        if not lines:
            u.error("unable to run/interpret 'uname'")
        if lines[0] == "Darwin":
            flag_objdump = "gobjdump"
        else:
            flag_objdump = "objdump"
Exemple #36
0
def parse_args():
    """Parse command line arguments for the script."""
    global flag_target_file, flag_prev_revision, target_is_url
    global flag_revision_pair, flag_diff_cmd, flag_save_temps

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dsr:R:c:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
            u.verbose(1, "debug level now %d" % u.verbosity_level())
        elif opt == "-r":
            flag_prev_revision = int(arg)
        elif opt == "-s":
            flag_save_temps = True
        elif opt == "-c":
            flag_diff_cmd = arg
        elif opt == "-R":
            plist = arg.split(":")
            if plist[1] == "PREV":
                lr = int(plist[0])
                p = (lr, lr - 1)
            else:
                p = (int(plist[0]), int(plist[1]))
            if p[0] <= 0:
                usage("specify positive left revision with -R")
            if p[1] <= 0:
                usage("specify positive right revision with -R")
            if p[0] == p[1]:
                usage("specify different revisions with -R")
            u.verbose(1, "revision pair: %d %d" % (p[0], p[1]))
            flag_revision_pair = p

    if not args or len(args) != 1:
        u.error("supply single file to diff")
    flag_target_file = args[0]
    um = re.compile(r"^.+://.+$")
    res = um.match(flag_target_file)
    if res:
        target_is_url = True
        if not flag_revision_pair:
            usage("URL target can only be used with -R option.")
    else:
        if not os.path.exists(flag_target_file):
            u.error("target file %s does not appear to exist" %
                    flag_target_file)
        if not os.path.isfile(flag_target_file):
            u.error("target file %s is not a file" % flag_target_file)
Exemple #37
0
def parse_args():
  """Command line argument parsing."""
  global flag_reverse

  try:
    optlist, _ = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
Exemple #38
0
def parse_args():
    """Command line argument parsing."""
    global flag_reverse

    try:
        optlist, _ = getopt.getopt(sys.argv[1:], "d")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
Exemple #39
0
def parse_args():
    """Command line argument parsing."""
    global flag_device, flag_archive_dir

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "da:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-a":
            flag_archive_dir = arg

    # Use $HOME/aosp_blobs if -a not specified
    if not flag_archive_dir:
        homedir = os.getenv("HOME")
        if not homedir:
            u.error(
                "no setting for $HOME environment variable -- cannot continue")
        flag_archive_dir = "%s/blobs" % homedir
        sys.stderr.write("... archive dir not specified, "
                         "using %s\n" % flag_archive_dir)

    # Error checking
    if not os.path.exists(flag_archive_dir):
        u.error("archive dir %s doesn't exist" % flag_archive_dir)
    if not os.path.isdir(flag_archive_dir):
        u.error("archive dir %s not a directory" % flag_archive_dir)

    if len(args) != 1:
        u.error("provide at most one device (N5, N7, etc) as cmd line arg")
    flag_device = args[0]

    dmatch = re.compile(r"^N\d$$")
    m = dmatch.match(flag_device)
    if m is None:
        u.error("device argument not in form 'N{0-9}'")

    abt = os.getenv("ANDROID_BUILD_TOP")
    if abt is None:
        u.error("ANDROID_BUILD_TOP not set (did you run lunch?)")
    apo = os.getenv("ANDROID_PRODUCT_OUT")
    if apo is None:
        u.error("ANDROID_PRODUCT_OUT not set (did you run lunch?)")

    # Switch to abt
    print "cd %s" % abt
    os.chdir(abt)
Exemple #40
0
def parse_args():
  """Parse command line arguments for the script."""
  global flag_target_file, flag_prev_revision, target_is_url
  global flag_revision_pair, flag_diff_cmd, flag_save_temps

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dsr:R:c:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
      u.verbose(1, "debug level now %d" % u.verbosity_level())
    elif opt == "-r":
      flag_prev_revision = int(arg)
    elif opt == "-s":
      flag_save_temps = True
    elif opt == "-c":
      flag_diff_cmd = arg
    elif opt == "-R":
      plist = arg.split(":")
      if plist[1] == "PREV":
        lr = int(plist[0])
        p = (lr, lr-1)
      else:
        p = (int(plist[0]), int(plist[1]))
      if p[0] <= 0:
        usage("specify positive left revision with -R")
      if p[1] <= 0:
        usage("specify positive right revision with -R")
      if p[0] == p[1]:
        usage("specify different revisions with -R")
      u.verbose(1, "revision pair: %d %d" % (p[0], p[1]))
      flag_revision_pair = p

  if not args or len(args) != 1:
    u.error("supply single file to diff")
  flag_target_file = args[0]
  um = re.compile(r"^.+://.+$")
  res = um.match(flag_target_file)
  if res:
    target_is_url = True
    if not flag_revision_pair:
      usage("URL target can only be used with -R option.")
  else:
    if not os.path.exists(flag_target_file):
      u.error("target file %s does not appear to exist" % flag_target_file)
    if not os.path.isfile(flag_target_file):
      u.error("target file %s is not a file" % flag_target_file)
def parse_args():
  """Command line argument parsing."""
  global flag_device, flag_archive_dir

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "da:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-a":
      flag_archive_dir = arg

  # Use $HOME/aosp_blobs if -a not specified
  if not flag_archive_dir:
    homedir = os.getenv("HOME")
    if not homedir:
      u.error("no setting for $HOME environment variable -- cannot continue")
    flag_archive_dir = "%s/blobs" % homedir
    sys.stderr.write("... archive dir not specified, "
                     "using %s\n" % flag_archive_dir)

  # Error checking
  if not os.path.exists(flag_archive_dir):
    u.error("archive dir %s doesn't exist" % flag_archive_dir)
  if not os.path.isdir(flag_archive_dir):
    u.error("archive dir %s not a directory" % flag_archive_dir)

  if len(args) != 1:
    u.error("provide at most one device (N5, N7, etc) as cmd line arg")
  flag_device = args[0]

  dmatch = re.compile(r"^N\d$$")
  m = dmatch.match(flag_device)
  if m is None:
    u.error("device argument not in form 'N{0-9}'")

  abt = os.getenv("ANDROID_BUILD_TOP")
  if abt is None:
    u.error("ANDROID_BUILD_TOP not set (did you run lunch?)")
  apo = os.getenv("ANDROID_PRODUCT_OUT")
  if apo is None:
    u.error("ANDROID_PRODUCT_OUT not set (did you run lunch?)")

  # Switch to abt
  print "cd %s" % abt
  os.chdir(abt)
Exemple #42
0
def parse_args():
    """Command line argument parsing."""
    global flag_dryrun, flag_destdir
    global flag_oldsha, flag_newsha, flag_branch_to_diff

    try:
        optlist, _ = getopt.getopt(sys.argv[1:], "hdo:DS:B:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-h":
            usage()
        elif opt == "-D":
            flag_dryrun = True
        elif opt == "-B":
            flag_branch_to_diff = arg
        elif opt == "-S":
            r1 = re.compile(r"^(\S+):(\S+)$")
            m1 = r1.match(arg)
            if m1:
                flag_oldsha = m1.group(1)
                flag_newsha = m1.group(2)
                u.verbose(1, "old sha: %s" % flag_oldsha)
                u.verbose(1, "new sha: %s" % flag_newsha)
            else:
                u.usage("malformed -S argument %s (should be of form X:Y)" %
                        arg)
        elif opt == "-o":
            if flag_destdir:
                usage("specify a single dest dir with -o")
            if not os.path.exists(arg):
                usage("dest dir %s does not exist" % arg)
            if not os.path.isdir(arg):
                usage("dest dir %s is not a directory" % arg)
            not_empty = False
            for _ in os.listdir(arg):
                not_empty = True
                break
            if not_empty:
                u.warning("warning: dest dir %s is not empty" % arg)
            flag_destdir = arg
    if not flag_destdir:
        usage("supply dest dir with -o option")
    if flag_branch_to_diff and flag_oldsha:
        usage("supply either -B or -S but not both")
    u.verbose(1, "dst dir: %s" % flag_destdir)
Exemple #43
0
def parse_args():
  """Command line argument parsing."""
  global flag_dryrun, flag_destdir
  global flag_oldsha, flag_newsha, flag_branch_to_diff

  try:
    optlist, _ = getopt.getopt(sys.argv[1:], "hdo:DS:B:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-h":
      usage()
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-B":
      flag_branch_to_diff = arg
    elif opt == "-S":
      r1 = re.compile(r"^(\S+):(\S+)$")
      m1 = r1.match(arg)
      if m1:
        flag_oldsha = m1.group(1)
        flag_newsha = m1.group(2)
        u.verbose(1, "old sha: %s" % flag_oldsha)
        u.verbose(1, "new sha: %s" % flag_newsha)
      else:
        u.usage("malformed -S argument %s (should be of form X:Y)" % arg)
    elif opt == "-o":
      if flag_destdir:
        usage("specify a single dest dir with -o")
      if not os.path.exists(arg):
        usage("dest dir %s does not exist" % arg)
      if not os.path.isdir(arg):
        usage("dest dir %s is not a directory" % arg)
      not_empty = False
      for _ in os.listdir(arg):
        not_empty = True
        break
      if not_empty:
        u.warning("warning: dest dir %s is not empty" % arg)
      flag_destdir = arg
  if not flag_destdir:
    usage("supply dest dir with -o option")
  if flag_branch_to_diff and flag_oldsha:
    usage("supply either -B or -S but not both")
  u.verbose(1, "dst dir: %s" % flag_destdir)
def parse_args():
  """Command line argument parsing."""
  global flag_serial

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if not args or len(args) != 1:
    usage("supply a single device serial number as argument")
  flag_serial = args[0]

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
Exemple #45
0
def parse_args():
  """Command line argument parsing."""
  global flag_subdir, flag_strace, flag_toplevel, flag_dryrun
  global flag_showcommands, flag_dependencies, flag_parfactor
  global flag_dashk, flag_checkbuild

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "adkstTDSx:j:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-s":
      flag_showcommands = " showcommands"
    elif opt == "-k":
      flag_dashk = "-k"
    elif opt == "-a":
      flag_dependencies = True
    elif opt == "-S":
      flag_strace = "strace -f -o trace.txt "
    elif opt == "-D":
      flag_dryrun = True
    elif opt == "-t":
      flag_toplevel = True
    elif opt == "-T":
      flag_toplevel = True
      flag_checkbuild = True
    elif opt == "-x":
      u.verbose(0, "adding extra make arg %s" % arg)
      flag_extra_make_args.append(arg)
    elif opt == "-j":
      flag_parfactor = int(arg)

  if not flag_toplevel:
    if not args:
      usage("supply dirname arg")
    if len(args) != 1:
      usage("supply single dirname arg")
    if flag_extra_make_args:
      usage("-x option can only be supplied with -t")
    flag_subdir = args[0]
  else:
    if flag_dependencies:
      usage("specify at most one of -t, -a")
Exemple #46
0
def parse_args():
  """Command line argument parsing."""

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()

  if not args:
    usage("supply one or more input files")
  for a in args:
    infiles[a] = 1
def parse_args():
    """Command line argument parsing."""
    global flag_copies

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "dc:")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    if args:
        usage("uknown extra args")
    for opt, arg in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-c":
            flag_copies = int(arg)
def parse_args():
  """Command line argument parsing."""
  global flag_infile, flag_outfile, flag_single
  global flag_gccgo_gdb, flag_relocate, flag_cpuprofile, flag_nopar
  global flag_autofdoprofile, flag_perfbin, flag_noaslr, flag_emitloop

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "di:o:R:G:CASZNP:L")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("extra unknown arguments")
  for opt, arg in optlist:
    u.verbose(1, "++ examining opt %s arg %s" %  (opt, arg))
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-S":
      flag_single = True
    elif opt == "-G":
      flag_gccgo_gdb = arg
    elif opt == "-Z":
      flag_noaslr = arg
    elif opt == "-C":
      flag_cpuprofile = True
    elif opt == "-A":
      flag_autofdoprofile = True
    elif opt == "-N":
      flag_nopar = True
    elif opt == "-P":
      flag_perfbin = arg
    elif opt == "-L":
      flag_emitloop = True
    elif opt == "-R":
      flag_relocate = arg
      if flag_relocate[0] != "/":
        flag_relocate = os.path.join(os.getcwd(), flag_relocate)
    elif opt == "-i":
      if flag_infile:
        usage("supply at most one -i option")
      flag_infile = arg
    elif opt == "-o":
      if flag_outfile:
        usage("supply at most one -o option")
      flag_outfile = arg
def parse_args():
  """Command line argument parsing."""
  global flag_copies

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "dc:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  if args:
    usage("uknown extra args")
  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-c":
      flag_copies = int(arg)
def parse_args():
  """Command line argument parsing."""
  try:
    optlist, args = getopt.getopt(sys.argv[1:], "d")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if not args:
    usage("supply one or more object files or archives as arguments")

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
  for a in args:
    if not os.path.exists(a):
      u.warning("failed to open/access '%s' -- skipping" % a)
    else:
      flag_infiles.append(a)
Exemple #51
0
def parse_args():
    """Command line argument parsing."""
    global flag_infiles, flag_summarize

    try:
        optlist, args = getopt.getopt(sys.argv[1:], "ds")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
        elif opt == "-s":
            flag_summarize = True
    if not args:
        usage("supply one or more filenames as arguments")
    flag_infiles = args
Exemple #52
0
def parse_args():
  """Command line argument parsing."""
  global flag_infiles, flag_summarize

  try:
    optlist, args = getopt.getopt(sys.argv[1:], "ds")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))

  for opt, _ in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-s":
      flag_summarize = True
  if not args:
    usage("supply one or more filenames as arguments")
  flag_infiles = args
Exemple #53
0
def parse_args():
    """Command line argument parsing."""
    try:
        optlist, args = getopt.getopt(sys.argv[1:], "d")
    except getopt.GetoptError as err:
        # unrecognized option
        usage(str(err))
    if not args:
        usage("supply one or more object files or archives as arguments")

    for opt, _ in optlist:
        if opt == "-d":
            u.increment_verbosity()
    for a in args:
        if not os.path.exists(a):
            u.warning("failed to open/access '%s' -- skipping" % a)
        else:
            flag_infiles.append(a)
def parse_args():
  """Command line argument parsing."""
  global flag_archive_dir, flag_scrape_target
  try:
    optlist, args = getopt.getopt(sys.argv[1:], "da:s:")
  except getopt.GetoptError as err:
    # unrecognized option
    usage(str(err))
  if args:
    usage("unexpected extra args")

  for opt, arg in optlist:
    if opt == "-d":
      u.increment_verbosity()
    elif opt == "-a":
      flag_archive_dir = arg
    elif opt == "-s":
      flag_scrape_target = arg

  # Use $HOME/aosp_blobs if -a not specified
  if not flag_archive_dir:
    homedir = os.getenv("HOME")
    if not homedir:
      u.error("no setting for $HOME environment variable -- cannot continue")
    flag_archive_dir = "%s/blobs" % homedir
    sys.stderr.write("... archive dir not specified, "
                     "using %s\n" % flag_archive_dir)

  # Does archive dir exist?
  if os.path.exists(flag_archive_dir):
    # Error if not a directory
    if not os.path.isdir(flag_archive_dir):
      u.error("specified archive dir %s is "
              "not a directory" % flag_archive_dir)
  else:
    sys.stderr.write("... creating %s, since it "
                     "does not exist" % flag_archive_dir)
    try:
      os.mkdir(flag_archive_dir)
    except OSError as err:
      u.error("unable to create archive directory")

  u.verbose(0, "... archive dir: '%s'" % flag_archive_dir)
  u.verbose(0, "... scrape target: '%s'" % flag_scrape_target)