⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 whale_package.py.svn-base

📁 Complete support for EBNF notation; Object-oriented parser design; C++ output; Deterministic bottom-
💻 SVN-BASE
字号:
#!/usr/bin/python# Copyright (C) 2002 Vladimir Prus. Permission to copy, use, modify, sell and# distribute this software is granted, provided this copyright notice appears# in all copies and modified versions are clearly marked as such. This software# is provided "as is" without express or implied warranty, and with no claim as# to is suitability for any purpose.import stagesimport osimport sysimport getoptimport shutilimport getpassfrom ftplib import FTPfrom popen2 import popen2whale_path = "http://zigzag.cs.msu.su:7813/repos/whale/trunk"libraries_path = "http://chronos.cs.msu.su/~ghost/projects/whale/whale-libs.tar.gz"wd_path = "http://zigzag.cs.msu.su:7813/repos/wd"dolphin_path = "http://hirvi.cs.queensu.ca/dolphin/dolphin-current-src.zip"wd_libraries_path = "http://chronos.cs.msu.su/~ghost/projects/whale/wd_libraries.tar.bz2"upload_server = "hirvi.cs.queensu.ca"upload_dir = "whale/data"upload_user = "ghost"notify_addresses = ["okhotin@cs.queensu.ca", "ghost@cs.msu.su"]def src():    if not slave:        try:            print "Checking out the sources."            os.system("svn co " + whale_path + " -d src")            os.mkdir("src")        except:            pass    return 0def libraries():    if not slave:        shutil.copytree("src", "src-with-libs")        if os.access("whale-libs.tar.gz", os.F_OK):            os.remove("whale-libs.tar.gz")        os.system("wget " + libraries_path)        os.system("tar -C src-with-libs -xvzf whale-libs.tar.gz")    return 0def generate_files():    if not slave:        os.chdir("src-with-libs/src")        os.system("whale parser.whl")        os.system("dolphin lexical.dlp")        os.chdir("../..")    return 0def generate_bootstrap():    if os.name == 'posix':        os.chdir("src-with-libs")        f = open("build-linux-gcc.sh", "w")        f.write("#/bin/sh\n\n")        f.close()        os.system("boost-build -sTOOLS=gcc  -sBUILD=\"release <runtime-link>static\" -d0 -d+2 -n >> build-linux-gcc.sh")        os.system("chmod a+x build-linux-gcc.sh")        os.chdir("..")    elif os.name == 'nt':        os.chdir("src-with-libs")        os.system("boost-build -sTOOLS=borland  -sBUILD=\"release <runtime-link>static\" -d0 -d+2 -n >> build-win-borland.bat")        os.chdir("..")    return 0def complete():    if not slave:        os.mkdir("src-complete")        shutil.copytree("src-with-libs", "src-complete/whale")        os.chdir("src-complete")        os.system("svn co " + wd_path + " -d wd ")        os.chdir("wd/src")        os.system("wget " + wd_libraries_path)        os.system("tar --bzip2 -xvf wd_libraries.tar.bz2")        os.remove("wd_libraries.tar.bz2")        os.chdir("../..")        os.system("wget " + dolphin_path)        os.system("unzip dolphin-current-src.zip")        os.remove("dolphin-current-src.zip")        os.chdir("..")    return 0def generate_files2():    if not slave:        os.chdir("src-complete/wd/src")        os.system("whale wd_parser.whl")        os.system("dolphin wd_lexer.dlp")        os.chdir("../../..")    return 0def generate_bootstrap2():    if os.name == 'posix':        os.chdir("src-complete/wd")        f = open("build-linux-gcc.sh", "w")        f.write("#/bin/sh\n\n")        f.close()        os.system("boost-build -sTOOLS=gcc  -sBUILD=\"release <runtime-link>static\" -d0 -d+2 -n >> build-linux-gcc.sh")        os.system("chmod a+x build-linux-gcc.sh")        os.chdir("../..")    elif os.name == 'nt':        os.chdir("src-complete/wd")        os.system("boost-build -sTOOLS=borland  -sBUILD=\"release <runtime-link>static\" -d0 -d+2 -n >> build-win-borland.bat")        os.chdir("../..")    return 0def build():    if os.name == 'posix':        shutil.copytree("src-with-libs", "posix-build")        os.chdir("posix-build")        os.system("ln -s `which g++-3.0` g++")        os.system("export PATH=.:$PATH && ./build-linux-gcc.sh")        os.chdir("..")    elif os.name == 'nt':        shutil.copytree("src-with-libs", "nt-build")        os.chdir("nt-build")        os.system(".\\build-win-borland.bat")        os.chdir("..")    return 0def build2():    if os.name == 'posix':        shutil.copytree("src-complete", "posix-build-complete")        os.chdir("posix-build-complete/wd")        os.system("./build-linux-gcc.sh")        os.chdir("../dolphin")        os.system("make -fMakefile.g++")        os.chdir("../..")    elif os.name == 'nt':        shutil.copytree("src-complete", "nt-build-complete")        os.chdir("nt-build-complete/wd")        os.system(".\\build-win-borland.bat")        os.chdir("../dolphin")        os.system("make -fMakefile.bcc")        os.chdir("../..")    return 0def package():    if not slave:        os.symlink("src", "whale")        os.system("tar --dereference --bzip2 -cf " + source + ".tar.bz2 whale")        os.system("zip -r " + source + ".zip whale")        os.remove("whale")        os.symlink("src-with-libs", "whale")        os.system("tar --dereference --bzip2 -cf " + source_with_libs + ".tar.bz2 whale")        os.system("zip -r " + source_with_libs + ".zip whale")        os.remove("whale")        os.symlink("src-complete", "whale")        os.system("tar --dereference --bzip2 -cf " + source_with_everything + ".tar.bz2 whale")        os.system("zip -r " + source_with_everything + ".zip whale")        os.remove("whale")        os.mkdir("whale")        os.symlink(os.path.abspath("posix-build/build/src/bin/whale/gcc/release/runtime-link-static/whale"), "whale/whale")        os.system("tar --dereference --bzip2 -cf " + linux_bin + ".tar.bz2 whale")        os.symlink(os.path.abspath("posix-build-complete/dolphin/dolphin"), "whale/dolphin")        os.symlink(os.path.abspath("posix-build-complete/wd/build/src/bin/wd/gcc/release/runtime-link-static/wd"), "whale/wd")        os.system("tar --dereference --bzip2 -cf " + linux_bin_complete + ".tar.bz2 whale")        shutil.rmtree("whale")        os.mkdir("whale")        os.symlink(os.path.abspath("nt-build/build/src/bin/whale.exe/borland/release/runtime-link-static/whale.exe"), "whale/whale.exe")        os.system("zip -r " + win_bin + ".zip whale")        os.symlink(os.path.abspath("nt-build-complete/dolphin/dolphin.exe"), "whale/dolphin.exe")        os.symlink(os.path.abspath("nt-build-complete/wd/build/src/bin/wd.exe/borland/release/runtime-link-static/wd.exe"), "whale/wd.exe")        os.system("zip -r " + win_bin_complete + ".zip whale")        shutil.rmtree("whale")    return 0def upload():    if not slave:        ftp = FTP(upload_server)        ftp.set_debuglevel(1)        ftp.set_pasv(0)        passwd = getpass.getpass("FTP password:")        ftp.login(upload_user, passwd)        ftp.cwd(upload_dir)        for file in [source + ".tar.bz2", source + ".zip",                     source_with_libs + ".tar.bz2", source_with_libs + ".zip",                     source_with_everything + ".tar.bz2", source_with_everything + ".zip",                     linux_bin + ".tar.bz2", linux_bin_complete + ".tar.bz2",                     win_bin + ".zip", win_bin_complete + ".zip"]:            data = open(file)            ftp.storbinary("STOR " + file, data)    return 0def notify():    if not slave:        for a in notify_addresses:            (child_out, child_in) = popen2("mail -s \"Whale\" " + a)            child_in.write("""Hello,this is automatic notification that whale packages for version %s werebuild and published.Yours,whale_package.py""" % (version,))            child_in.close()    return 0stages_list = [src, libraries, generate_files, generate_bootstrap,               complete, generate_files2, generate_bootstrap2, build, build2, package,               upload, notify]try:    (opts_l, args) = getopt.getopt(sys.argv[1:], "", ["slave"])    opts = {}    for e in opts_l:        opts[e[0]] = e[1]except:    print "Usage: whale_package.py [--slave] version slave_host_names"    sys.exit(1)if not opts.has_key("--slave") and len(args) == 0:    print "Usage: whale_package.py [--slave] version slave_host_names"    sys.exit(1)if opts.has_key("--slave"):    slave = 1    stages.start_server(stages_list)else:    slave = 0    version = args[0]    slave_hosts = args[1:]    source = "whale-" + version + "-src"    source_with_libs = source + "-with-libraries"    source_with_everything = source + "-augmented"    linux_bin = "whale-" + version + "-linux-i386"    linux_bin_complete = "whale-" + version + "-linux-i386-augmented"    win_bin = "whale-" + version + "-win32-i386"    win_bin_complete = "whale-" + version + "-win32-i386-augmented"    stages.run_stages(stages_list, slave_hosts)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -