Ejemplo n.º 1
0
def run(args):
    if sys.version_info < (3, 4):
        print('Meson works correctly only with python 3.4+.')
        print('You have python %s.' % sys.version)
        print('Please update your environment')
        return 1
    if args[-1] == 'secret-handshake':
        args = args[:-1]
        handshake = True
    else:
        handshake = False
    args = mesonlib.expand_arguments(args)
    if not args:
        return 1
    options = parser.parse_args(args[1:])
    if options.print_version:
        print(coredata.version)
        return 0
    args = options.directories
    if len(args) == 0 or len(args) > 2:
        print('%s <source directory> <build directory>' % sys.argv[0])
        print('If you omit either directory, the current directory is substituted.')
        return 1
    dir1 = args[0]
    if len(args) > 1:
        dir2 = args[1]
    else:
        dir2 = '.'
    this_file = os.path.abspath(__file__)
    while os.path.islink(this_file):
        resolved = os.readlink(this_file)
        if resolved[0] != '/':
            this_file = os.path.join(os.path.dirname(this_file), resolved)
        else:
            this_file = resolved

    try:
        app = MesonApp(dir1, dir2, this_file, handshake, options)
    except Exception as e:
        # Log directory does not exist, so just print
        # to stdout.
        print('Error during basic setup:\n')
        print(e)
        return 1
    try:
        app.generate()
    except Exception as e:
        if isinstance(e, MesonException):
            if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'):
                mlog.log(mlog.red('\nMeson encountered an error in file %s, line %d, column %d:' % (e.file, e.lineno, e.colno)))
            else:
                mlog.log(mlog.red('\nMeson encountered an error:'))
            mlog.log(e)
        else:
            traceback.print_exc()
        return 1
    return 0
Ejemplo n.º 2
0
            keys.sort()
            optarr = []
            for key in keys:
                opt = options[key]
                if (opt.choices is None) or (len(opt.choices) == 0):
                    # Zero length list or string
                    choices = ''
                else:
                    # A non zero length list or string, convert to string
                    choices = str(opt.choices)
                optarr.append([key, opt.description, opt.value, choices])
            self.print_aligned(optarr)


if __name__ == '__main__':
    args = mesonlib.expand_arguments(sys.argv[:])
    if not args:
        sys.exit(1)
    options = parser.parse_args(args[1:])
    if len(options.directory) > 1:
        print('%s <build directory>' % sys.argv[0])
        print(
            'If you omit the build directory, the current directory is substituted.'
        )
        sys.exit(1)
    if len(options.directory) == 0:
        builddir = os.getcwd()
    else:
        builddir = options.directory[0]
    try:
        c = Conf(builddir)
Ejemplo n.º 3
0
            keys = list(options.keys())
            keys.sort()
            optarr = []
            for key in keys:
                opt = options[key]
                if (opt.choices is None) or (len(opt.choices) == 0):
                  # Zero length list or string
                  choices = '';
                else:
                  # A non zero length list or string, convert to string
                  choices = str(opt.choices);
                optarr.append([key, opt.description, opt.value, choices])
            self.print_aligned(optarr)

if __name__ == '__main__':
    args = mesonlib.expand_arguments(sys.argv[:])
    if not args:
        sys.exit(1)
    options = parser.parse_args(args[1:])
    if len(options.directory) > 1:
        print('%s <build directory>' % sys.argv[0])
        print('If you omit the build directory, the current directory is substituted.')
        sys.exit(1)
    if len(options.directory) == 0:
        builddir = os.getcwd()
    else:
        builddir = options.directory[0]
    try:
        c = Conf(builddir)
        if len(options.sets) > 0:
            c.set_options(options.sets)
Ejemplo n.º 4
0
def run(args):
    if sys.version_info < (3, 3):
        print('Meson works correctly only with python 3.3+.')
        print('You have python %s.' % sys.version)
        print('Please update your environment')
        return 1
    if args[-1] == 'secret-handshake':
        args = args[:-1]
        handshake = True
    else:
        handshake = False
    args = mesonlib.expand_arguments(args)
    if not args:
        return 1
    options = parser.parse_args(args[1:])
    if options.print_version:
        print(coredata.version)
        return 0
    args = options.directories
    if len(args) == 0 or len(args) > 2:
        print('%s <source directory> <build directory>' % sys.argv[0])
        print(
            'If you omit either directory, the current directory is substituted.'
        )
        return 1
    dir1 = args[0]
    if len(args) > 1:
        dir2 = args[1]
    else:
        dir2 = '.'
    this_file = os.path.abspath(__file__)
    while os.path.islink(this_file):
        resolved = os.readlink(this_file)
        if resolved[0] != '/':
            this_file = os.path.join(os.path.dirname(this_file), resolved)
        else:
            this_file = resolved

    try:
        app = MesonApp(dir1, dir2, this_file, handshake, options)
    except Exception as e:
        # Log directory does not exist, so just print
        # to stdout.
        print('Error during basic setup:\n')
        print(e)
        return 1
    try:
        app.generate()
    except Exception as e:
        if isinstance(e, MesonException):
            if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(
                    e, 'colno'):
                mlog.log(
                    mlog.red(
                        '\nMeson encountered an error in file %s, line %d, column %d:'
                        % (e.file, e.lineno, e.colno)))
            else:
                mlog.log(mlog.red('\nMeson encountered an error:'))
            mlog.log(e)
        else:
            traceback.print_exc()
        return 1
    return 0