Esempio n. 1
0
def writeResults(comp, opts):
    global mainclass
    global basepath

    javaclasses = comp.javaclasses

    if opts.bean is not None:
        jarfile = opts.bean
    else:
        jarfile = opts.jar              

    if jarfile is None:
        if not opts.deep and opts.package is not None:
            for jc in javaclasses:
                if isinstance(jc, TupleType):
                    jc = jc[0]
                if basepath is None:
                    basepath = '.'
                copyclass(jc, opts.workdir, basepath)
        sys.exit(0)

    print 'Building archive:', jarfile
    from jar import JavaArchive

    extraPackages = []

    if opts.all:
        addAll(extraPackages)
    elif opts.core:
        addCore(extraPackages)

    ja = JavaArchive(extraPackages)
    ja.addToManifest({'Main-Class': mainclass})
    for jc in javaclasses:
        if isinstance(jc, TupleType):
            ja.addClass(opts.workdir, jc[0], jc[1])
        else:
            ja.addClass(opts.workdir, jc)

    for dep in comp.trackJavaDependencies():
        ja.addEntry(dep)

    if opts.core or opts.all:
        import depend
        ja.addEntry(depend.getFile('org.python.modules.Setup'))
#        ze, jcs = depend.depends('org.python.modules.exceptions')
#        ja.addEntry(ze)
#        for jc in jcs:
#            ja.addEntry(depend.getFile(jc))

    ja.dump(jarfile)
Esempio n. 2
0
def writeResults(comp, opts):
    global mainclass
    global basepath

    javaclasses = comp.javaclasses

    if opts.bean is not None:
        jarfile = opts.bean
    else:
        jarfile = opts.jar

    if jarfile is None:
        if not opts.deep and opts.package is not None:
            for jc in javaclasses:
                if isinstance(jc, TupleType):
                    jc = jc[0]
                if basepath is None:
                    basepath = '.'
                copyclass(jc, opts.workdir, basepath)
        sys.exit(0)

    print 'Building archive:', jarfile
    from jar import JavaArchive

    extraPackages = []

    if opts.all:
        addAll(extraPackages)
    elif opts.core:
        addCore(extraPackages)

    ja = JavaArchive(extraPackages)
    ja.addToManifest({'Main-Class': mainclass})
    for jc in javaclasses:
        if isinstance(jc, TupleType):
            ja.addClass(opts.workdir, jc[0], jc[1])
        else:
            ja.addClass(opts.workdir, jc)

    for dep in comp.trackJavaDependencies():
        ja.addEntry(dep)

    if opts.core or opts.all:
        import depend
        ja.addEntry(depend.getFile('org.python.modules.Setup'))


#        ze, jcs = depend.depends('org.python.modules.exceptions')
#        ja.addEntry(ze)
#        for jc in jcs:
#            ja.addEntry(depend.getFile(jc))

    ja.dump(jarfile)
def compile(files, outdir):
    c = Compiler()
    for filename, classname in files:
        c.compilefile(filename, classname)
    c.dump(outdir)
    return c.files, c.javaclasses


if __name__ == '__main__':
    import sys
    filenames = sys.argv[1:]
    print filenames
    outdir = "."
    files = []
    for filename in filenames:
        outdir = os.path.dirname(filename)
        classname = os.path.splitext(os.path.basename(filename))[0]
        files.append( (filename, classname) )
    files, javaclasses = compile(files, outdir)

    #sys.exit() 

    print 'Building archive...'
    from jar import JavaArchive
    ja = JavaArchive([('org.python.core', []),])
    for jc in javaclasses:
        ja.addClass(outdir, jc)
    outjar = "c:\\jython\\tools\\jythonc2\\test\\t.jar"       
    ja.dump(outjar)
Esempio n. 4
0
    c = Compiler()
    for filename, classname in files:
        c.compilefile(filename, classname)
    c.dump(outdir)
    return c.files, c.javaclasses


if __name__ == '__main__':
    import sys
    filenames = sys.argv[1:]
    print filenames
    outdir = "."
    files = []
    for filename in filenames:
        outdir = os.path.dirname(filename)
        classname = os.path.splitext(os.path.basename(filename))[0]
        files.append((filename, classname))
    files, javaclasses = compile(files, outdir)

    #sys.exit()

    print 'Building archive...'
    from jar import JavaArchive
    ja = JavaArchive([
        ('org.python.core', []),
    ])
    for jc in javaclasses:
        ja.addClass(outdir, jc)
    outjar = "c:\\jython\\tools\\jythonc2\\test\\t.jar"
    ja.dump(outjar)