#!/usr/bin/perl -w
# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer. 
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution. 
# 3.  Neither the name of Apple Inc. ("Apple") nor the names of
#     its contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission. 
#
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use strict;

use FindBin;
use Getopt::Long;

use lib $FindBin::Bin;
use webkitdirs;
use VCSUtils;

sub checkPythonVersion()
{
    # Will exit 0 if Python is 2.5 or greater, non-zero otherwise.
    `python -c "import sys;sys.exit(sys.version_info[:2] < (2,5))"`;
    return exitStatus($?) == 0;
}

sub main()
{
    my $checkOnly = 0;
    my $showHelp = 0;
    my $getOptionsResult = GetOptions(
        'check-only!' => \$checkOnly,
        'help|h' => \$showHelp,
    );
    if (!$getOptionsResult || $showHelp) {
        print STDERR <<HELP;
Usage: $0 [options]
  --check-only        Check python version only.
  -h|--help           Show this help message.
HELP
        return 1;
    }
    # Congrats, your Python is fine.
    return 0 if checkPythonVersion();

    return 1 if $checkOnly;

    print "Your Python version is insufficient to run WebKit's Python code.  Please update.\n";
    print "See http://trac.webkit.org/wiki/PythonGuidelines for more info.\n";
    return 1;
}

exit(main());
