repo_name
stringclasses
2 values
file_path
stringlengths
14
31
language
stringclasses
3 values
quality_score
int64
80
95
num_tokens
int64
179
2.36k
num_lines
int64
22
283
license
stringclasses
2 values
date_scraped
stringlengths
27
27
last_modified
stringclasses
9 values
code
stringlengths
415
7.35k
apple/cups
test/5.3-lpq.sh
Shell
80
179
22
Apache-2.0
2025-02-25T00:20:28.878501Z
2018-10-02T22:21:25+00:00Z
#!/bin/sh # # Test the lpq command. # # Copyright © 2007 by Apple Inc. # Copyright © 1997-2005 by Easy Software Products, all rights reserved. # # Licensed under Apache License v2.0. See the file "LICENSE" for more # information. # echo "LPQ Test" echo "" echo " lpq -P Test1" $runcups $VALGRIND ../berkeley/lpq -P Test1 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo ""
apple/cups
test/5.1-lpadmin.sh
Shell
80
630
63
Apache-2.0
2025-02-25T00:20:51.660213Z
2018-10-02T22:21:25+00:00Z
#!/bin/sh # # Test the lpadmin command. # # Copyright © 2007-2018 by Apple Inc. # Copyright © 1997-2005 by Easy Software Products, all rights reserved. # # Licensed under Apache License v2.0. See the file "LICENSE" for more # information. # echo "Add Printer Test" echo "" echo " lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd" $runcups $VALGRIND ../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1 if test $? != 0; then echo " FAILED" exit 1 else if test -f $CUPS_SERVERROOT/ppd/Test3.ppd; then echo " PASSED" else echo " FAILED (No PPD)" exit 1 fi fi echo "" echo "Modify Printer Test" echo "" echo " lpadmin -p Test3 -v file:/tmp/Test3 -o PageSize=A4" $runcups $VALGRIND ../systemv/lpadmin -p Test3 -v file:/tmp/Test3 -o PageSize=A4 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "Delete Printer Test" echo "" echo " lpadmin -x Test3" $runcups $VALGRIND ../systemv/lpadmin -x Test3 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "Add Shared Printer Test" echo "" echo " lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m everywhere" $runcups $VALGRIND ../systemv/lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m everywhere 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo ""
apple/cups
test/5.4-lpstat.sh
Shell
80
415
49
Apache-2.0
2025-02-25T00:20:52.642297Z
2019-04-26T21:40:54+00:00Z
#!/bin/sh # # Test the lpstat command. # # Copyright © 2007-2019 by Apple Inc. # Copyright © 1997-2005 by Easy Software Products, all rights reserved. # # Licensed under Apache License v2.0. See the file "LICENSE" for more # information. # echo "LPSTAT Basic Test" echo "" echo " lpstat -t" $runcups $VALGRIND ../systemv/lpstat -t 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "LPSTAT Enumeration Test" echo "" echo " lpstat -e" printers="`$runcups $VALGRIND ../systemv/lpstat -e 2>&1`" if test $? != 0 -o "x$printers" = x; then echo " FAILED" exit 1 else for printer in $printers; do echo $printer done echo " PASSED" fi echo "" echo "LPSTAT Get Host Test" echo "" echo " lpstat -H" server="`$runcups $VALGRIND ../systemv/lpstat -H 2>&1`" if test $? != 0 -o "x$server" != x$CUPS_SERVER; then echo " FAILED ($server)" exit 1 else echo " PASSED ($server)" fi echo ""
apple/cups
test/5.8-cancel.sh
Shell
80
408
48
Apache-2.0
2025-02-25T00:20:58.086178Z
2019-04-26T21:40:54+00:00Z
#!/bin/sh # # Test the cancel command. # # Copyright © 2007-2019 by Apple Inc. # Copyright © 1997-2006 by Easy Software Products, all rights reserved. # # Licensed under Apache License v2.0. See the file "LICENSE" for more # information. # echo "Cancel Destination Test" echo "" echo " lp -d Test1 -o job-hold-until=indefinite testfile.jpg" $runcups $VALGRIND ../systemv/lp -d Test1 -o job-hold-until=indefinite ../examples/testfile.jpg 2>&1 echo " cancel Test1" $runcups $VALGRIND ../systemv/cancel Test1 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "Cancel All Test" echo "" echo " cancel -a" $runcups $VALGRIND ../systemv/cancel -a 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "Purge All Test" echo "" echo " cancel -a -x" $runcups $VALGRIND ../systemv/cancel -a -x 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo ""
apple/cups
test/5.9-lpinfo.sh
Shell
80
370
46
Apache-2.0
2025-02-25T00:20:59.067376Z
2019-04-26T21:40:54+00:00Z
#!/bin/sh # # Test the lpinfo command. # # Copyright © 2007-2019 by Apple Inc. # Copyright © 1997-2005 by Easy Software Products, all rights reserved. # # Licensed under Apache License v2.0. See the file "LICENSE" for more # information. # echo "LPINFO Devices Test" echo "" echo " lpinfo -v" $runcups $VALGRIND ../systemv/lpinfo -v 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "LPINFO Drivers Test" echo "" echo " lpinfo -m" $runcups $VALGRIND ../systemv/lpinfo -m 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo "" echo "LPINFO Drivers Test" echo "" echo " lpinfo -m | grep -q sample.drv" $runcups $VALGRIND ../systemv/lpinfo -m | grep -q sample.drv 2>&1 if test $? != 0; then echo " FAILED" exit 1 else echo " PASSED" fi echo ""
apple/swift-lldb
scripts/analyze-project-deps.py
Python
80
2,361
208
NOASSERTION
2025-02-25T00:32:28.338543Z
2019-03-21T07:19:09+00:00Z
#! /usr/bin/env python import argparse import itertools import os import re import sys from collections import defaultdict from use_lldb_suite import lldb_root parser = argparse.ArgumentParser( description='Analyze LLDB project #include dependencies.') parser.add_argument('--show-counts', default=False, action='store_true', help='When true, show the number of dependencies from each subproject') parser.add_argument('--discover-cycles', default=False, action='store_true', help='When true, find and display all project dependency cycles. Note,' 'this option is very slow') args = parser.parse_args() src_dir = os.path.join(lldb_root, "source") inc_dir = os.path.join(lldb_root, "include") src_map = {} include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"') def is_sublist(small, big): it = iter(big) return all(c in it for c in small) def normalize_host(str): if str.startswith("lldb/Host"): return "lldb/Host" if str.startswith("Plugins"): return "lldb/" + str if str.startswith("lldb/../../source"): return str.replace("lldb/../../source", "lldb") return str def scan_deps(this_dir, file): global src_map deps = {} this_dir = normalize_host(this_dir) if this_dir in src_map: deps = src_map[this_dir] with open(file) as f: for line in list(f): m = include_regex.match(line) if m is None: continue relative = m.groups()[0].rstrip("/") if relative == this_dir: continue relative = normalize_host(relative) if relative in deps: deps[relative] += 1 elif relative != this_dir: deps[relative] = 1 if this_dir not in src_map and len(deps) > 0: src_map[this_dir] = deps for (base, dirs, files) in os.walk(inc_dir): dir = os.path.basename(base) relative = os.path.relpath(base, inc_dir) inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]] relative = relative.replace("\\", "/") for inc in inc_files: inc_path = os.path.join(base, inc) scan_deps(relative, inc_path) for (base, dirs, files) in os.walk(src_dir): dir = os.path.basename(base) relative = os.path.relpath(base, src_dir) src_files = [x for x in files if os.path.splitext(x)[1] in [".cpp", ".h", ".mm"]] norm_base_path = os.path.normpath(os.path.join("lldb", relative)) norm_base_path = norm_base_path.replace("\\", "/") for src in src_files: src_path = os.path.join(base, src) scan_deps(norm_base_path, src_path) pass def is_existing_cycle(path, cycles): # If we have a cycle like # A -> B -> C (with an implicit -> A at the end) # then we don't just want to check for an occurrence of A -> B -> C in the # list of known cycles, but every possible rotation of A -> B -> C. For # example, if we previously encountered B -> C -> A (with an implicit -> B # at the end), then A -> B -> C is also a cycle. This is an important # optimization which reduces the search space by multiple orders of # magnitude. for i in range(0,len(path)): if any(is_sublist(x, path) for x in cycles): return True path = [path[-1]] + path[0:-1] return False def expand(path_queue, path_lengths, cycles, src_map): # We do a breadth first search, to make sure we visit all paths in order # of ascending length. This is an important optimization to make sure that # short cycles are discovered first, which will allow us to discard longer # cycles which grow the search space exponentially the longer they get. while len(path_queue) > 0: cur_path = path_queue.pop(0) if is_existing_cycle(cur_path, cycles): continue next_len = path_lengths.pop(0) + 1 last_component = cur_path[-1] for item in src_map[last_component]: if item.startswith("clang"): continue if item in cur_path: # This is a cycle. Minimize it and then check if the result is # already in the list of cycles. Insert it (or not) and then # exit. new_index = cur_path.index(item) cycle = cur_path[new_index:] if not is_existing_cycle(cycle, cycles): cycles.append(cycle) continue path_lengths.append(next_len) path_queue.append(cur_path + [item]) pass cycles = [] path_queue = [[x] for x in iter(src_map)] path_lens = [1] * len(path_queue) items = list(src_map.items()) items.sort(key = lambda A : A[0]) for (path, deps) in items: print(path + ":") sorted_deps = list(deps.items()) if args.show_counts: sorted_deps.sort(key = lambda A: (A[1], A[0])) for dep in sorted_deps: print("\t{} [{}]".format(dep[0], dep[1])) else: sorted_deps.sort(key = lambda A: A[0]) for dep in sorted_deps: print("\t{}".format(dep[0])) def iter_cycles(cycles): global src_map for cycle in cycles: cycle.append(cycle[0]) zipper = list(zip(cycle[0:-1], cycle[1:])) result = [(x, src_map[x][y], y) for (x,y) in zipper] total = 0 smallest = result[0][1] for (first, value, last) in result: total += value smallest = min(smallest, value) yield (total, smallest, result) if args.discover_cycles: print("Analyzing cycles...") expand(path_queue, path_lens, cycles, src_map) average = sum([len(x)+1 for x in cycles]) / len(cycles) print("Found {} cycles. Average cycle length = {}.".format(len(cycles), average)) counted = list(iter_cycles(cycles)) if args.show_counts: counted.sort(key = lambda A: A[0]) for (total, smallest, cycle) in counted: sys.stdout.write("{} deps to break: ".format(total)) sys.stdout.write(cycle[0][0]) for (first, count, last) in cycle: sys.stdout.write(" [{}->] {}".format(count, last)) sys.stdout.write("\n") else: for cycle in cycles: cycle.append(cycle[0]) print(" -> ".join(cycle)) print("Analyzing islands...") islands = [] outgoing_counts = defaultdict(int) incoming_counts = defaultdict(int) for (total, smallest, cycle) in counted: for (first, count, last) in cycle: outgoing_counts[first] += count incoming_counts[last] += count for cycle in cycles: this_cycle = set(cycle) disjoints = [x for x in islands if this_cycle.isdisjoint(x)] overlaps = [x for x in islands if not this_cycle.isdisjoint(x)] islands = disjoints + [set.union(this_cycle, *overlaps)] print("Found {} disjoint cycle islands...".format(len(islands))) for island in islands: print("Island ({} elements)".format(len(island))) sorted = [] for node in island: sorted.append((node, incoming_counts[node], outgoing_counts[node])) sorted.sort(key = lambda x: x[1]+x[2]) for (node, inc, outg) in sorted: print(" {} [{} in, {} out]".format(node, inc, outg)) sys.stdout.flush() pass
apple/swift-lldb
lit/lit.cfg.py
Python
80
1,156
106
NOASSERTION
2025-02-25T00:32:30.631002Z
2019-09-18T19:20:58+00:00Z
# -*- Python -*- import os import platform import re import shutil import site import sys import lit.formats from lit.llvm import llvm_config from lit.llvm.subst import FindTool from lit.llvm.subst import ToolSubst site.addsitedir(os.path.dirname(__file__)) from helper import toolchain # name: The name of this test suite. config.name = 'LLDB' # testFormat: The test format to use to interpret tests. config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) # suffixes: A list of file extensions to treat as test files. This is overriden # by individual lit.local.cfg files in the test subdirectories. config.suffixes = ['.test', '.cpp', '.s'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent # directories. config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit') # Begin Swift mod. # Swift's libReflection builds without ASAN, which causes a known # false positive in std::vector. If sanitizers are off, this is just # a no-op config.environment['ASAN_OPTIONS'] = 'detect_container_overflow=0' # End Swift mod. llvm_config.use_default_substitutions() toolchain.use_lldb_substitutions(config) toolchain.use_support_substitutions(config) if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple): config.available_features.add("armhf-linux") def calculate_arch_features(arch_string): # This will add a feature such as x86, arm, mips, etc for each built # target features = [] for arch in arch_string.split(): features.append(arch.lower()) return features # Run llvm-config and add automatically add features for whether we have # assertions enabled, whether we are in debug mode, and what targets we # are built for. llvm_config.feature_config( [('--assertion-mode', {'ON': 'asserts'}), ('--build-mode', {'DEBUG': 'debug'}), ('--targets-built', calculate_arch_features) ]) # Clean the module caches in the test build directory. This is necessary in an # incremental build whenever clang changes underneath, so doing it once per # lit.py invocation is close enough. for cachedir in [config.clang_module_cache, config.lldb_module_cache]: if os.path.isdir(cachedir): print("Deleting module cache at %s."%cachedir) shutil.rmtree(cachedir) # Set a default per-test timeout of 10 minutes. Setting a timeout per test # requires that killProcessAndChildren() is supported on the platform and # lit complains if the value is set but it is not supported. supported, errormsg = lit_config.maxIndividualTestTimeIsSupported if supported: lit_config.maxIndividualTestTime = 900 else: lit_config.warning("Could not set a default per-test timeout. " + errormsg) # If running tests natively, check for CPU features needed for some tests. if 'native' in config.available_features: cpuid_exe = lit.util.which('lit-cpuid', config.lldb_tools_dir) if cpuid_exe is None: lit_config.warning("lit-cpuid not found, tests requiring CPU extensions will be skipped") else: out, err, exitcode = lit.util.executeCommand([cpuid_exe]) if exitcode == 0: for x in out.split(): config.available_features.add('native-cpu-%s' % x) else: lit_config.warning("lit-cpuid failed: %s" % err) if not config.lldb_disable_python: config.available_features.add('python')
apple/swift-lldb
scripts/install-lldb-swift.py
Python
95
2,280
283
NOASSERTION
2025-02-25T00:34:35.867688Z
2016-12-02T09:32:43+00:00Z
#!/usr/bin/env python # install-lldb-swift.py # # This source file is part of the Swift.org open source project # # Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See https://swift.org/LICENSE.txt for license information # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # # ------------------------------------------------------------------------------ # This script will install the files from an LLDB build into Xcode. import argparse import os import shutil import sys parser = argparse.ArgumentParser( description="Installs the files from an LLDB build into Xcode. Without options, tries to do the right thing.") parser.add_argument("-l", "--lldb", help="Path to build/Configuration.") parser.add_argument( "-s", "--swift", help="Path to llvm-build/LLVMConfig/arch/LLVMConfig.") parser.add_argument("-x", "--xcode", help="Path to Xcode.app.") parser.add_argument( "-d", "--dry", help="Dry run: log what would happen but don't do it.", action="store_true") args = parser.parse_args() def checkCandidates(candidates, checker): for candidate in candidates: if checker(candidate): return candidate return None # Checker helpers def checkDirOrLink(path): return (os.path.isdir(path) or os.path.islink(path)) def checkFileOrLink(path): return (os.path.isfile(path) or os.path.islink(path)) # Find an LLDB build def checkLLDB(path): if not checkFileOrLink(path + "/lldb"): return False if not checkDirOrLink(path + "/LLDB.framework"): return False return True def findLLDB(): lldb_candidates = [ "build/DebugClang", "build/Debug", "build/Release" ] return checkCandidates(lldb_candidates, checkLLDB) # Find a Swift build def checkSwift(path): if not checkFileOrLink(path + "/bin/swift"): return False if not checkDirOrLink(path + "/lib/swift"): return False return True def findSwift(): swift_candidates = [ "llvm-build/Debug+Asserts/x86_64", "llvm-build/Debug/x86_64", "llvm-build/Release+Debug/x86_64", "llvm-build/Release+Asserts/x86_64", "llvm-build/Release/x86_64" ] return checkCandidates(swift_candidates, checkSwift) # Find an Xcode installation def checkXcode(path): if not checkFileOrLink( path + "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift"): return False if not checkDirOrLink( path + "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift"): return False return True def findXcode(): xcode_candidates = [ "/Applications/Xcode.app" ] return checkCandidates(xcode_candidates, checkXcode) # Check input arguments def getPaths(): lldb = None if args.lldb: lldb = args.lldb else: lldb = findLLDB() swift = None if args.swift: swift = args.swift else: swift = findSwift() xcode = None if args.xcode: xcode = args.xcode else: xcode = findXcode() if not lldb: print "Couldn't find LLDB automatically. Please use --lldb." return None if not checkLLDB(lldb): print "The path passed to --lldb is not a valid LLDB build." return None if not swift: print "Couldn't find Swift automatically. Please use --swift." return None if not checkSwift(swift): print "The path passed to --swift is not a valid Swift build." return None if not xcode: print "Couldn't find Xcode automatically. Please use --xcode." return None if not checkXcode(xcode): print "The path passed to --xcode is not a valid Xcode installation." return None return (lldb, swift, xcode) # Work unit classes class WorkUnit: def __init__(self, from_path, to_path): self.from_path = from_path self.to_path = to_path self.backup_path = to_path + ".backup" # basic operations def remove(self, path): if os.path.islink(path): print "Remove alias " + self.to_path elif os.path.isdir(path): print "Remove (recursive) " + self.to_path else: print "Remove " + self.to_path if not args.dry: if os.path.islink(path): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) else: os.remove(path) def removeBackup(self): self.remove(self.backup_path) def backupUnchecked(self): print "Move " + self.to_path + " to " + self.backup_path if not args.dry: os.rename(self.to_path, self.backup_path) def removeTo(self): self.remove(self.to_path) def linkFromTo(self): abs_from_path = os.path.abspath(self.from_path) print "Link " + abs_from_path + " to " + self.to_path if not args.dry: os.symlink(abs_from_path, self.to_path) # high-level operations def checkAndBackup(self): if os.path.islink(self.to_path): self.removeTo() # no backup necessary else: if os.path.exists(self.backup_path): self.removeBackup() self.backupUnchecked() def install(self): self.linkFromTo() # Make path dictionary def makeWorkUnits(lldb, swift, xcode): toolchain = xcode + "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain" toolchain_usr_bin = toolchain + "/usr/bin" toolchain_usr_lib = toolchain + "/usr/lib" work_units = [ WorkUnit( swift + "/bin/swift", toolchain_usr_bin + "/swift"), WorkUnit( swift + "/lib/swift", toolchain_usr_lib + "/swift"), WorkUnit( lldb + "/LLDB.framework", xcode + "/Contents/SharedFrameworks/LLDB.framework")] # if we've built sourcekitd, install that too # ## commented out because a built sourcekit doesn't work # # if os.path.isdir(swift + "/lib/sourcekitd.framework"): # work_units.append(WorkUnit(swift + "/lib/sourcekitd.framework", toolchain_usr_lib + "/sourcekitd.framework")) return work_units # Prepare Xcode installation, backing up data as necessary def prepareAndBackup(work_units): for work_unit in work_units: work_unit.checkAndBackup() # Install def install(work_units): for work_unit in work_units: work_unit.install() # Main validated_paths = getPaths() if not validated_paths: sys.exit(0) (lldb, swift, xcode) = validated_paths print "Installing LLDB from " + lldb + " and Swift from " + swift + " into Xcode at " + xcode work_units = makeWorkUnits(lldb, swift, xcode) prepareAndBackup(work_units) install(work_units)
apple/swift-lldb
scripts/macos-setup-codesign.sh
Shell
80
666
57
NOASSERTION
2025-02-25T00:34:37.834753Z
2018-06-14T18:04:13+00:00Z
#!/bin/bash CERT="lldb_codesign" function error() { echo error: "$@" exit 1 } function cleanup { # Remove generated files rm -f "$TMPDIR/$CERT.tmpl" "$TMPDIR/$CERT.cer" "$TMPDIR/$CERT.key" > /dev/null 2>&1 } trap cleanup EXIT # Check if the certificate is already present in the system keychain security find-certificate -Z -p -c "$CERT" /Library/Keychains/System.keychain > /dev/null 2>&1 if [ $? -eq 0 ]; then echo Certificate has already been generated and installed exit 0 fi # Create the certificate template cat <<EOF >$TMPDIR/$CERT.tmpl [ req ] default_bits = 2048 # RSA key size encrypt_key = no # Protect private key default_md = sha512 # MD to use prompt = no # Prompt for DN distinguished_name = codesign_dn # DN template [ codesign_dn ] commonName = "$CERT" [ codesign_reqext ] keyUsage = critical,digitalSignature extendedKeyUsage = critical,codeSigning EOF echo Generating and installing lldb_codesign certificate # Generate a new certificate openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config "$TMPDIR/$CERT.tmpl" -extensions codesign_reqext -batch -out "$TMPDIR/$CERT.cer" -keyout "$TMPDIR/$CERT.key" > /dev/null 2>&1 [ $? -eq 0 ] || error Something went wrong when generating the certificate # Install the certificate in the system keychain sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain "$TMPDIR/$CERT.cer" > /dev/null 2>&1 [ $? -eq 0 ] || error Something went wrong when installing the certificate # Install the key for the certificate in the system keychain sudo security import "$TMPDIR/$CERT.key" -A -k /Library/Keychains/System.keychain > /dev/null 2>&1 [ $? -eq 0 ] || error Something went wrong when installing the key # Kill task_for_pid access control daemon sudo pkill -f /usr/libexec/taskgated > /dev/null 2>&1 # Exit indicating the certificate is now generated and installed exit 0
apple/swift-lldb
scripts/swig_bot.py
Python
80
714
85
NOASSERTION
2025-02-25T00:35:03.526736Z
2016-09-06T20:57:50+00:00Z
#!/usr/bin/env python """ SWIG generation top-level script. Supports both local and remote generation of SWIG bindings for multiple languages. """ # Python modules import argparse import logging import sys import traceback # LLDB modules import use_lldb_suite # swig_bot modules from swig_bot_lib import client from swig_bot_lib import server def process_args(args): parser = argparse.ArgumentParser( description='Run swig-bot client or server.') # Create and populate subparser arguments for when swig_bot is # run in client or server mode subparsers = parser.add_subparsers( help="Pass --help to a sub-command to print detailed usage") client_parser = subparsers.add_parser("client", help="Run SWIG generation client") client.add_subparser_args(client_parser) client_parser.set_defaults(func=run_client) server_parser = subparsers.add_parser("server", help="Run SWIG generation server") server.add_subparser_args(server_parser) server_parser.set_defaults(func=run_server) # Arguments to control logging verbosity. parser.add_argument( "--verbose", "-v", action="store_true", default=False, help="Increase logging verbosity level.") options = parser.parse_args(args) # Set logging level. if options.verbose: log_level = logging.DEBUG else: log_level = logging.NOTSET logging.basicConfig(level=log_level) logging.info("logging is using level: %d", log_level) return options def run_client(options): logging.info("Running swig_bot in client mode") client.finalize_subparser_options(options) client.run(options) def run_server(options): logging.info("Running swig_bot in server mode") server.finalize_subparser_options(options) server.run(options) if __name__ == "__main__": options = process_args(sys.argv[1:]) try: if options.func is None: logging.error( "Unknown mode specified. Expected client or server.") sys.exit(-1) else: options.func(options) except KeyboardInterrupt as e: logging.info("Ctrl+C received. Shutting down...") sys.exit(-1) except Exception as e: error = traceback.format_exc() logging.error("An error occurred running swig-bot.") logging.error(error)
apple/swift-lldb
scripts/utilsOsType.py
Python
80
866
103
NOASSERTION
2025-02-25T00:35:13.281154Z
2018-10-04T20:34:58+00:00Z
""" Utility module to determine the OS Python running on -------------------------------------------------------------------------- File: utilsOsType.py Overview: Python module to supply functions and an enumeration to help determine the platform type, bit size and OS currently being used. -------------------------------------------------------------------------- """ # Python modules: import sys # Provide system information # Third party modules: # In-house modules: # Instantiations: # Enumerations: #----------------------------------------------------------------------------- # Details: Class to implement a 'C' style enumeration type. # Gotchas: None. # Authors: Illya Rudkin 28/11/2013. # Changes: None. #-- if sys.version_info.major >= 3: from enum import Enum class EnumOsType(Enum): Unknown = 0 Darwin = 1 FreeBSD = 2 Linux = 3 NetBSD = 4 OpenBSD = 5 Windows = 6 kFreeBSD = 7 else: class EnumOsType(object): values = ["Unknown", "Darwin", "FreeBSD", "Linux", "NetBSD", "OpenBSD", "Windows", "kFreeBSD"] class __metaclass__(type): #++---------------------------------------------------------------- # Details: Fn acts as an enumeration. # Args: vName - (R) Enumeration to match. # Returns: Int - Matching enumeration/index. # Throws: None. #-- def __getattr__(cls, vName): return cls.values.index(vName) #++--------------------------------------------------------------------------- # Details: Reverse fast lookup of the values list. # Args: vI - (R) Index / enumeration. # Returns: Str - text description matching enumeration. # Throws: None. #-- def name_of(cls, vI): return EnumOsType.values[vI] #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- #++--------------------------------------------------------------------------- # Details: Determine what operating system is currently running on. # Args: None. # Returns: EnumOsType - The OS type being used ATM. # Throws: None. #-- def determine_os_type(): eOSType = EnumOsType.Unknown strOS = sys.platform if strOS == "darwin": eOSType = EnumOsType.Darwin elif strOS.startswith("freebsd"): eOSType = EnumOsType.FreeBSD elif strOS.startswith("linux"): eOSType = EnumOsType.Linux elif strOS.startswith("netbsd"): eOSType = EnumOsType.NetBSD elif strOS.startswith("openbsd"): eOSType = EnumOsType.OpenBSD elif strOS == "win32": eOSType = EnumOsType.Windows elif strOS.startswith("gnukfreebsd"): eOSType = EnumOsType.kFreeBSD return eOSType
apple/swift-lldb
source/lldb.cpp
C++
90
972
99
NOASSERTION
2025-02-25T00:35:18.326737Z
2019-04-17T18:39:30+00:00Z
//===-- lldb.cpp ------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/lldb-private.h" #include "llvm/ADT/StringExtras.h" using namespace lldb; using namespace lldb_private; #include "clang/Basic/Version.h" #include "swift/Basic/Version.h" #ifdef HAVE_VCS_VERSION_INC #include "VCSVersion.inc" #endif static const char *GetLLDBRevision() { #ifdef LLDB_REVISION return LLDB_REVISION; #else return nullptr; #endif } static const char *GetLLDBRepository() { #ifdef LLDB_REPOSITORY return LLDB_REPOSITORY; #else return NULL; #endif } #if LLDB_IS_BUILDBOT_BUILD static std::string GetBuildDate() { #if defined(LLDB_BUILD_DATE) return std::string(LLDB_BUILD_DATE); #else return std::string(); #endif } #endif #define QUOTE(str) #str #define EXPAND_AND_QUOTE(str) QUOTE(str) const char *lldb_private::GetVersion() { // On platforms other than Darwin, report a version number in the same style // as the clang tool. static std::string g_version_str; if (g_version_str.empty()) { g_version_str += "lldb version "; g_version_str += CLANG_VERSION_STRING; const char *lldb_repo = GetLLDBRepository(); const char *lldb_rev = GetLLDBRevision(); if (lldb_repo || lldb_rev) { g_version_str += " ("; if (lldb_repo) g_version_str += lldb_repo; if (lldb_rev) { g_version_str += " revision "; g_version_str += lldb_rev; } g_version_str += ")"; } #if LLDB_IS_BUILDBOT_BUILD std::string build_date = GetBuildDate(); if(!build_date.empty()) g_version_str += " (buildbot " + build_date + ")"; #endif auto const swift_version = swift::version::getSwiftFullVersion(); g_version_str += "\n" + swift_version; // getSwiftFullVersion() also prints clang and llvm versions, no // need to print them again. We keep this code here to not diverge // too much from upstream. #undef LLDB_UPSTREAM #ifdef LLDB_UPSTREAM std::string clang_rev(clang::getClangRevision()); if (clang_rev.length() > 0) { g_version_str += "\n clang revision "; g_version_str += clang_rev; } std::string llvm_rev(clang::getLLVMRevision()); if (llvm_rev.length() > 0) { g_version_str += "\n llvm revision "; g_version_str += llvm_rev; } #endif // LLDB_UPSTREAM } return g_version_str.c_str(); }