mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-21 11:53:32 +01:00
Introduced irpf90.a
This commit is contained in:
parent
9a8335fee3
commit
ab735fc6a3
58
src/ninja.py
58
src/ninja.py
@ -52,11 +52,13 @@ def dress(f,in_root=False):
|
|||||||
|
|
||||||
def create_build_touches(list_of_other_o):
|
def create_build_touches(list_of_other_o):
|
||||||
"""
|
"""
|
||||||
Create the build command for the irp_touches.o file.
|
Create the build command for the irp_touches.o file and the irpf90.a library.
|
||||||
"""
|
"""
|
||||||
name = "irp_touches"
|
name = "irp_touches"
|
||||||
|
short_lib = "irpf90.a"
|
||||||
short_target_o = "%s.irp.o"%name
|
short_target_o = "%s.irp.o"%name
|
||||||
short_target_F90 = "%s.irp.F90"%name
|
short_target_F90 = "%s.irp.F90"%name
|
||||||
|
lib = dress(short_lib)
|
||||||
target_o = dress(short_target_o)
|
target_o = dress(short_target_o)
|
||||||
target_F90 = dress(short_target_F90)
|
target_F90 = dress(short_target_F90)
|
||||||
|
|
||||||
@ -71,13 +73,18 @@ def create_build_touches(list_of_other_o):
|
|||||||
" short_in = {short_target_F90}",
|
" short_in = {short_target_F90}",
|
||||||
" short_out = {short_target_o}",
|
" short_out = {short_target_o}",
|
||||||
"",
|
"",
|
||||||
|
"build {lib}: link_lib_{id} {target_o} {list_of_modules}",
|
||||||
|
" short_out = {short_lib}",
|
||||||
|
"",
|
||||||
] )
|
] )
|
||||||
|
|
||||||
result = result.format(
|
result = result.format(
|
||||||
id = irp_id ,
|
id = irp_id ,
|
||||||
|
lib = lib ,
|
||||||
list_of_modules = list_of_modules ,
|
list_of_modules = list_of_modules ,
|
||||||
short_target_F90 = os.path.split(short_target_F90)[1] ,
|
short_lib = short_lib ,
|
||||||
short_target_o = os.path.split(short_target_o)[1] ,
|
short_target_F90 = os.path.split(target_F90)[1] ,
|
||||||
|
short_target_o = os.path.split(target_o)[1] ,
|
||||||
target_F90 = target_F90 ,
|
target_F90 = target_F90 ,
|
||||||
target_o = target_o
|
target_o = target_o
|
||||||
)
|
)
|
||||||
@ -89,6 +96,7 @@ def create_build_target(t,list_of_other_o):
|
|||||||
"""
|
"""
|
||||||
name = t.filename
|
name = t.filename
|
||||||
|
|
||||||
|
irp_lib = dress("irpf90.a")
|
||||||
target = dress(name,in_root=True)
|
target = dress(name,in_root=True)
|
||||||
short_target_o = "%s.irp.o"%name
|
short_target_o = "%s.irp.o"%name
|
||||||
short_target_F90 = "%s.irp.F90"%name
|
short_target_F90 = "%s.irp.F90"%name
|
||||||
@ -102,7 +110,7 @@ def create_build_target(t,list_of_other_o):
|
|||||||
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
|
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
|
||||||
if modules[x].name in t.needed_modules ] + [ target_module_o ]
|
if modules[x].name in t.needed_modules ] + [ target_module_o ]
|
||||||
|
|
||||||
list_of_o = [ target_o, target_module_o ] + list_of_other_o
|
list_of_o = [ target_o, target_module_o, irp_lib ]
|
||||||
list_of_o = ' '.join(list_of_o)
|
list_of_o = ' '.join(list_of_o)
|
||||||
|
|
||||||
list_of_modules = map(dress, needed_modules) + list_of_other_o
|
list_of_modules = map(dress, needed_modules) + list_of_other_o
|
||||||
@ -115,11 +123,11 @@ def create_build_target(t,list_of_other_o):
|
|||||||
" short_out = {short_target}",
|
" short_out = {short_target}",
|
||||||
"",
|
"",
|
||||||
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_includes}",
|
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_includes}",
|
||||||
" short_in = {short_target_F90}",
|
" short_in = {short_target_F90}",
|
||||||
" short_out = {short_target_o}",
|
" short_out = {short_target_o}",
|
||||||
"",
|
"",
|
||||||
"build {target_module_o}: compile_fortran_{id} {target_module_F90}",
|
"build {target_module_o}: compile_fortran_{id} {target_module_F90}",
|
||||||
" short_in = {short_target_module_F90}",
|
" short_in = {short_target_module_F90}",
|
||||||
" short_out = {short_target_module_o}",
|
" short_out = {short_target_module_o}",
|
||||||
"",
|
"",
|
||||||
] )
|
] )
|
||||||
@ -129,11 +137,11 @@ def create_build_target(t,list_of_other_o):
|
|||||||
list_of_includes = list_of_includes ,
|
list_of_includes = list_of_includes ,
|
||||||
list_of_modules = list_of_modules ,
|
list_of_modules = list_of_modules ,
|
||||||
list_of_o = list_of_o ,
|
list_of_o = list_of_o ,
|
||||||
short_target_F90 = os.path.split(short_target_F90)[1] ,
|
short_target_F90 = os.path.split(target_F90)[1] ,
|
||||||
short_target_module_F90 = os.path.split(short_target_module_F90)[1] ,
|
short_target_module_F90 = os.path.split(target_module_F90)[1] ,
|
||||||
short_target_module_o = os.path.split(short_target_module_o)[1] ,
|
short_target_module_o = os.path.split(target_module_o)[1] ,
|
||||||
short_target = name ,
|
short_target = name ,
|
||||||
short_target_o = os.path.split(short_target_o)[1] ,
|
short_target_o = os.path.split(target_o)[1] ,
|
||||||
target_F90 = target_F90 ,
|
target_F90 = target_F90 ,
|
||||||
target_module_F90 = target_module_F90 ,
|
target_module_F90 = target_module_F90 ,
|
||||||
target_module_o = target_module_o ,
|
target_module_o = target_module_o ,
|
||||||
@ -170,11 +178,11 @@ def create_build_non_target(t,list_of_other_o):
|
|||||||
result = '\n'.join(
|
result = '\n'.join(
|
||||||
[
|
[
|
||||||
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_externals}",
|
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_externals}",
|
||||||
" short_in = {short_target_F90}",
|
" short_in = {short_target_F90}",
|
||||||
" short_out = {short_target}",
|
" short_out = {short_target}",
|
||||||
"",
|
"",
|
||||||
"build {target_module_o}: compile_fortran_{id} {target_module_F90} | {list_of_externals} {list_of_includes}",
|
"build {target_module_o}: compile_fortran_{id} {target_module_F90} | {list_of_externals} {list_of_includes}",
|
||||||
" short_in = {short_target_F90}",
|
" short_in = {short_target_F90}",
|
||||||
" short_out = {short_target_o}",
|
" short_out = {short_target_o}",
|
||||||
"",
|
"",
|
||||||
] )
|
] )
|
||||||
@ -184,9 +192,9 @@ def create_build_non_target(t,list_of_other_o):
|
|||||||
list_of_externals = list_of_externals ,
|
list_of_externals = list_of_externals ,
|
||||||
list_of_includes = list_of_includes ,
|
list_of_includes = list_of_includes ,
|
||||||
list_of_modules = list_of_modules ,
|
list_of_modules = list_of_modules ,
|
||||||
short_target_F90 = os.path.split(short_target_F90)[1] ,
|
short_target_F90 = os.path.split(target_F90)[1] ,
|
||||||
short_target = name ,
|
short_target = name ,
|
||||||
short_target_o = os.path.split(short_target_o)[1] ,
|
short_target_o = os.path.split(target_o)[1] ,
|
||||||
target_F90 = target_F90 ,
|
target_F90 = target_F90 ,
|
||||||
target_module_F90 = target_module_F90 ,
|
target_module_F90 = target_module_F90 ,
|
||||||
target_module_o = target_module_o ,
|
target_module_o = target_module_o ,
|
||||||
@ -208,15 +216,19 @@ def create_build_remaining(f):
|
|||||||
target_o = target_o.replace(cwd,os.path.join(cwd,irpdir))
|
target_o = target_o.replace(cwd,os.path.join(cwd,irpdir))
|
||||||
|
|
||||||
if extension.lower() in [ 'f', 'f90' ]:
|
if extension.lower() in [ 'f', 'f90' ]:
|
||||||
result = "build {target_o}: compile_fortran_{id} {target_i}"
|
result = [ "build {target_o}: compile_fortran_{id} {target_i}" ]
|
||||||
elif extension.lower() in [ 'c' ]:
|
elif extension.lower() in [ 'c' ]:
|
||||||
result = "build {target_o}: compile_c_{id} {target_i}"
|
result = [ "build {target_o}: compile_c_{id} {target_i}" ]
|
||||||
elif extension.lower() in [ 'cxx', 'cpp' ]:
|
elif extension.lower() in [ 'cxx', 'cpp' ]:
|
||||||
result = "build {target_o}: compile_cxx_{id} {target_i}"
|
result = [ "build {target_o}: compile_cxx_{id} {target_i}" ]
|
||||||
|
|
||||||
result = result.format(
|
result += [ " short_in = {short_target_i}",
|
||||||
|
" short_out = {short_target_o}", "" ]
|
||||||
|
result = '\n'.join(result).format(
|
||||||
target_o = target_o,
|
target_o = target_o,
|
||||||
target_i = target_i,
|
target_i = target_i,
|
||||||
|
short_target_o = os.path.split(target_o)[1],
|
||||||
|
short_target_i = os.path.split(target_i)[1],
|
||||||
id = irp_id
|
id = irp_id
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
@ -259,6 +271,9 @@ def run():
|
|||||||
try: FC = os.environ["FC"]
|
try: FC = os.environ["FC"]
|
||||||
except KeyError: FC="gfortran -ffree-line-length-none -I ."
|
except KeyError: FC="gfortran -ffree-line-length-none -I ."
|
||||||
|
|
||||||
|
try: AR = os.environ["AR"]
|
||||||
|
except KeyError: AR="ar"
|
||||||
|
|
||||||
try: CC = os.environ["CC"]
|
try: CC = os.environ["CC"]
|
||||||
except KeyError: CC="gcc -I ."
|
except KeyError: CC="gcc -I ."
|
||||||
|
|
||||||
@ -315,11 +330,15 @@ def run():
|
|||||||
" command = {CXX} {CXXFLAGS} -c $in -o $out",
|
" command = {CXX} {CXXFLAGS} -c $in -o $out",
|
||||||
" description = C++ : $short_in -> $short_out",
|
" description = C++ : $short_in -> $short_out",
|
||||||
"",
|
"",
|
||||||
|
"rule link_lib_{id}",
|
||||||
|
" command = {AR} crf $out $in" ,
|
||||||
|
" description = Link: $short_out",
|
||||||
|
"",
|
||||||
"rule link_{id}",
|
"rule link_{id}",
|
||||||
" command = {FC} $in {LIB} -o $out" ,
|
" command = {FC} $in {LIB} -o $out" ,
|
||||||
" description = Link: $short_out"]
|
" description = Link: $short_out"]
|
||||||
|
|
||||||
output = [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS) ]
|
output = [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, AR=AR) ]
|
||||||
|
|
||||||
|
|
||||||
# All modules : list of Fmodule objects
|
# All modules : list of Fmodule objects
|
||||||
@ -374,6 +393,7 @@ def run():
|
|||||||
|
|
||||||
for i in l_targets:
|
for i in l_targets:
|
||||||
output.append(create_build_target(i, l_common_o))
|
output.append(create_build_target(i, l_common_o))
|
||||||
|
# output.append(create_build_target(i))
|
||||||
|
|
||||||
# Remaining files
|
# Remaining files
|
||||||
for i in l_common_s:
|
for i in l_common_s:
|
||||||
|
Loading…
Reference in New Issue
Block a user