Skip to content
Snippets Groups Projects
Commit 9ea4207ed984 authored by Kurt Smith's avatar Kurt Smith
Browse files

added fwrap.py commandline script

parent 255c970b8714
Branches
No related tags found
No related merge requests found
import os, sys import os, sys, shutil
from fparser import api from fparser import api
from fparser import block_statements from fparser import block_statements
from Visitor import PrintTree, KindResolutionVisitor, \ from Visitor import PrintTree, KindResolutionVisitor, \
...@@ -6,6 +6,18 @@ ...@@ -6,6 +6,18 @@
CHeaderGenerator, PxdGenerator, CyHeaderGenerator, \ CHeaderGenerator, PxdGenerator, CyHeaderGenerator, \
CyImplGenerator CyImplGenerator
def main():
from optparse import OptionParser
parser = OptionParser()
parser.add_option('--outdir', dest='outdir', default=os.path.curdir, help='base of output directory')
parser.add_option('--indir', dest='indir', default=os.path.curdir, help='directory of fortran source files')
parser.add_option('--projname', dest='projectname', default='fwrap_default', help='name of fwrap project -- will be the name of the directory.')
options, sources = parser.parse_args()
wrap(sources, options.outdir, options.indir, options.projectname)
def setup_project(projectname, src_dir, outdir): def setup_project(projectname, src_dir, outdir):
fq_projdir = os.path.join(outdir, projectname) fq_projdir = os.path.join(outdir, projectname)
if os.path.isdir(fq_projdir): if os.path.isdir(fq_projdir):
...@@ -17,7 +29,7 @@ ...@@ -17,7 +29,7 @@
def wrap(filenames, directory, outdir, projectname): def wrap(filenames, directory, outdir, projectname):
projectname = projectname.lower().strip() projectname = projectname.strip()
projdir = setup_project(projectname, directory, outdir) projdir = setup_project(projectname, directory, outdir)
...@@ -50,6 +62,10 @@ ...@@ -50,6 +62,10 @@
# write out the makefile # write out the makefile
gen_makefile(projectname, filenames, directory, projdir) gen_makefile(projectname, filenames, directory, projdir)
# copy the fortran source files to the project dir.
for fname in filenames:
shutil.copy(fname, projdir)
def gen_makefile(projname, src_files, src_dir, out_dir): def gen_makefile(projname, src_files, src_dir, out_dir):
import sys import sys
PYTHON = '/usr/bin/python2.6' PYTHON = '/usr/bin/python2.6'
......
#! /usr/bin/env python
from Main import main
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment