10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-12-22 04:13:34 +01:00

Cleaned build

This commit is contained in:
Anthony Scemama 2015-06-02 15:54:06 +02:00
parent 3b97748adc
commit c70b96dd58
8 changed files with 43 additions and 370 deletions

View File

@ -1,262 +0,0 @@
#!/bin/bash
EZFIO_ROOT=$( cd $(dirname "${BASH_SOURCE}")/.. ; pwd -P )
function _ezfio_py()
{
python ${EZFIO_ROOT}/Python/ezfio.py $@
}
function _ezfio_usage()
{
echo "
Usage:
ezfio set_file EZFIO_DIRECTORY
ezfio unset_file
ezfio has DIRECTORY ITEM
ezfio get DIRECTORY ITEM
ezfio set DIRECTORY ITEM VALUE : Scalar values
ezfio set DIRECTORY ITEM : Array values read from stdin
ezfio set_verbose
ezfio unset_verbose
"
}
function _require_ezfio_file()
{
if [[ -z ${EZFIO_FILE} ]]
then
echo "EZFIO directory not set: try 'ezfio set_file'"
return 1
fi
if [[ ! -d ${EZFIO_FILE} ]]
then
echo "EZFIO directory not accessible: try 'ezfio set_file'"
return 1
fi
}
function _require_first_argument()
{
if [[ -z $1 ]]
then
_ezfio_usage
echo "Error: First argument not set"
return 1
else
return 0
fi
}
function _require_second_argument()
{
if [[ -z $2 ]]
then
_ezfio_usage
echo "Error: Second argument not set"
return 1
fi
}
function _ezfio_set_verbose()
{
function _ezfio_info()
{
echo "$1"
}
return 0
}
function _ezfio_unset_verbose()
{
function _ezfio_info()
{
:
}
return 0
}
function _ezfio_set_file()
{
_require_first_argument $@ || return 1
if [[ ! -d $1 ]]
then
mkdir -p $1 || return 1
fi
export EZFIO_FILE=$1
_ezfio_info "Set file ${EZFIO_FILE}"
return 0
}
function _ezfio_unset_file()
{
_require_ezfio_file || return 1
_ezfio_info "Unset file ${EZFIO_FILE}"
unset EZFIO_FILE
return 0
}
function _ezfio_has()
{
_require_ezfio_file || return 1
_require_first_argument $@ || return 1
if [[ ! -d ${EZFIO_FILE}/${1,,} ]]
then
return 1
fi
if [[ -z $2 ]]
then
return 0
fi
_ezfio_py has $@ && return 0 || return 1
}
function _ezfio_get()
{
_require_ezfio_file || return 1
if [[ -z $1 ]]
then
ls ${EZFIO_FILE} && return 0 || return 1
fi
if [[ -z $2 ]]
then
ls ${EZFIO_FILE}/${1,,} && return 0 || return 1
fi
_ezfio_py get $@ && return 0 || return 1
}
function _ezfio_set()
{
_require_ezfio_file || return 1
_require_first_argument $@ || return 1
_require_second_argument $@ || return 2
if [[ -z $3 ]]
then
_ezfio_py set $@ || return 1
else
echo $3 | _ezfio_py set $1 $2 || return 1
fi
return 0
}
#---
function ezfio()
{
case $1 in
"has")
shift
_ezfio_has $@
;;
"set")
shift
_ezfio_set $@
;;
"get")
shift
_ezfio_get $@
;;
"set_file")
shift
_ezfio_set_file $@
;;
"unset_file")
shift
_ezfio_unset_file
;;
"set_verbose")
_ezfio_set_verbose
;;
"unset_verbose")
_ezfio_unset_verbose
;;
*)
_ezfio_usage
;;
esac
}
_ezfio_unset_verbose
# Completion
_Complete()
{
local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
prev2="${COMP_WORDS[COMP_CWORD-2]}"
if [[ -n ${EZFIO_FILE} && -d ${EZFIO_FILE} ]]
then
case "${prev2}" in
set|has|get)
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE}/${prev} ; ls | sed 's/\.gz//' )" -- $cur ) )
return 0
;;
esac
case "${prev}" in
unset_file|set_verbose|unset_verbose)
COMPREPLY=()
return 0
;;
set|has|get)
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE} ; \ls -d */ | sed 's|/||g')" -- $cur ) )
return 0
;;
*)
COMPREPLY=( $(compgen -W 'has get set unset_file \
set_verbose unset_verbose -h' -- $cur ) )
return 0
;;
esac
else
case "${prev}" in
set_verbose|unset_verbose)
COMPREPLY=()
return 0
;;
set_file)
COMPREPLY=( $(compgen -W "$(\ls -d */ | sed 's|/||g')" -- ${cur} ) )
return 0
;;
*)
COMPREPLY=( $(compgen -W 'set_file \
set_verbose unset_verbose -h' -- $cur ) )
return 0
;;
esac
fi
}
complete -F _Complete ezfio

View File

@ -1,18 +1,24 @@
include version
rule build_generated_ninja
command = python configure.py
command = python $in ninja
description = Creating generated.ninja
generator = 1
rule run_ninja
command = ninja -f $in
command = bash -c 'source make.config ; bash -c "$$NINJA -f $in"'
description = Building Fortran library
rule build_archive
command = git archive --format=tar HEAD > EZFIO.${version}.tar && mkdir -p EZFIO && cd EZFIO && tar -xvf ../EZFIO.${version}.tar && cd .. && rm EZFIO.${version}.tar && tar -zcvf EZFIO.${version}.tar.gz EZFIO && rm -rf EZFIO
description = Building archive
build make.config generated.ninja: build_generated_ninja | configure.py
rule clean_all
command = bash -c 'source make.config ; bash -c "$$NINJA -f $in -t clean ; $$NINJA -t clean" ; rm -rf src/IRPF90_{temp,man} src/*.pyc'
description = Cleaning directory
build make.config generated.ninja: build_generated_ninja configure.py
build all: run_ninja generated.ninja
default all
@ -20,3 +26,5 @@ default all
build EZFIO.${VERSION}.tar.gz: build_archive
build archive: phony EZFIO.${VERSION}.tar.gz
build clean: clean_all generated.ninja

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
import os
import os,sys
with open("version",'r') as f:
version = f.read().strip().rsplit('=')[1]
@ -19,13 +19,18 @@ d_default = {
def create_make_config():
if sys.argv[-1] == 'ninja':
fmt = '{0}="{1}"\n'
else:
fmt = '{0}={1}\n'
with open("make.config",'w') as out:
for var,default in d_default.iteritems():
try:
cur = os.environ[var]
except KeyError:
cur = default
out.write('{0}={1}\n'.format(var,cur))
out.write(fmt.format(var,cur))
def read_make_config():
@ -53,10 +58,7 @@ def create_build_ninja():
"""
IRPF90_temp/build.ninja irpf90.make irpf90_entities
tags libezfio_groups-gen.py libezfio_util-gen.py
""".split() ] + \
"""
Python/ezfio.py Ocaml/ezfio.ml
""".split()
""".split() ]
d["irpf90_sources"] = [ "src/{0}".format(x) for x in
"""
@ -64,7 +66,7 @@ def create_build_ninja():
libezfio_file.irp.f create_python.py
libezfio_groups.irp.f ezfio-head.py
libezfio_util.irp.f ezfio-tail.py read_config.py
f_types.py test.py create_bash.py groups.py
f_types.py test.py groups.py
""".split() ] + [ "make.config" ]
d["irpf90_files"] = ' '.join(d["irpf90_files"])
@ -96,6 +98,13 @@ rule build_libezfio_irp_a
command = cp lib/libezfio.a lib/libezfio_irp.a ; {AR} dv lib/libezfio_irp.a irp_stack.irp.o > /dev/null ; {RANLIB} lib/libezfio_irp.a
description = Building libezfio_irp.a
rule build_python
command = cd src ; python create_python.py
description = Building Python module
rule build_ocaml
command = cd src ; python create_ocaml.py
description = Building Ocaml module
build make.config: build_make_config | configure.py
@ -108,6 +117,9 @@ build lib/libezfio.a: build_libezfio_a | src/IRPF90_temp/irpf90.a
build lib/libezfio_irp.a: build_libezfio_irp_a | lib/libezfio.a
build Python/ezfio.py: build_python | lib/libezfio.a
build Ocaml/ezfio.ml: build_ocaml | lib/libezfio.a
"""

View File

@ -36,7 +36,7 @@ include ../version
.PHONY: static all
all: static
all: static ../Python/ezfio.py ../Ocaml/ezfio.ml
static: ../lib/libezfio.a ../lib/libezfio_irp.a
@ -51,6 +51,10 @@ static: ../lib/libezfio.a ../lib/libezfio_irp.a
$(AR) dv ../lib/libezfio_irp.a irp_stack.irp.o
$(RANLIB) ../lib/libezfio_irp.a
test: static
$(FC) -o $@ IRPF90_temp/run.irp.F90 -L../lib/ -lezfio
../Python/ezfio.py:
python create_python.py
../Ocaml/ezfio.ml:
python create_ocaml.py

View File

@ -1,89 +0,0 @@
#!/usr/bin/env python
# EZFIO is an automatic generator of I/O libraries
# Copyright (C) 2009 Anthony SCEMAMA, CNRS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Anthony Scemama
# LCPQ - IRSAMC - CNRS
# Universite Paul Sabatier
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
import re
from read_config import groups
from groups_templates import *
from f_types import t_short, f2ocaml
import os
import sys
def run():
head = []
tail = []
file = open("../version","r")
v = file.readline()
file.close()
v = v.split('=')[1].strip()
l = os.getcwd().replace('/src','')
head += ["""let version = "%s";;"""%(v),
"""let library = "%s";;"""%(l)]
for group in groups.keys():
for var,type,dims,command in groups[group]:
if command is not "":
continue
dims_py = str(dims)
for g in groups.keys():
dims_py = dims_py.replace(g,'self.'+g)
var = var.lower()
group = group.lower()
strdims = tuple(map(lambda x: '('+str(x)+')',dims))
strdims = str(strdims).replace("'","")
if len(dims) == 1:
strdims = strdims[:-2]+")"
dim_max = strdims[1:-1].replace(',','*')
type_set = type
if type.lower().startswith('character'):
type_set = 'character*(*)'
d = { 'type_short': f2ocaml[t_short(type)],
'type': type,
'type_set': type_set,
'var': var,
'group': group,
'dims': strdims}
if dims == ():
tail += ['let get_%(group)s_%(var)s () = read_%(type_short)s "%(group)s" "%(var)s";;' %(d),
'let set_%(group)s_%(var)s = write_%(type_short)s "%(group)s" "%(var)s" ;;' %(d) ,
'let has_%(group)s_%(var)s () = has "%(group)s" "%(var)s" ;;' %(d) ]
else:
tail += ['let get_%(group)s_%(var)s () = read_%(type_short)s_array "%(group)s" "%(var)s";;' %(d),
'let set_%(group)s_%(var)s = write_%(type_short)s_array "%(group)s" "%(var)s";;' %(d) ,
'let has_%(group)s_%(var)s () = has_array "%(group)s" "%(var)s" ;;' %(d) ]
file = open('ezfio.sh','r')
template = file.read()
file.close()
template = template.replace("(*$HEAD*)",'\n'.join(head))
template = template.replace("(*$TAIL*)",'\n'.join(tail))
file = open('../Bash/ezfio-gen.sh','w')
file.write(template)
file.close()

View File

@ -87,3 +87,7 @@ def run():
file.write(template)
file.close()
if __name__ == '__main__':
run()

View File

@ -29,3 +29,5 @@ def run():
with open(f,'r') as inp:
out.write(inp.read())
if __name__ == '__main__':
run()

View File

@ -355,12 +355,6 @@ print >>file_py, """
file_py.close()
import create_ocaml
create_ocaml.run()
import create_python
create_python.run()
END_SHELL
BEGIN_PROVIDER [ integer, libezfio_buffer_rank ]