10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-12-22 20:33:42 +01:00

Corrected ninja bugs

This commit is contained in:
Anthony Scemama 2015-06-25 14:59:35 +02:00
parent 71f5255582
commit 0cce47969a
4 changed files with 52 additions and 36 deletions

View File

@ -25,7 +25,7 @@
include version include version
include make.config include make.config
.PHONY: default clean veryclean archive configure .PHONY: default clean veryclean archive
default: make.config default: make.config
cd src && $(MAKE) cd src && $(MAKE)
@ -34,7 +34,6 @@ clean:
- bash -c "[[ -f lib/libezfio.a ]] && rm $$PWD/lib/*" - bash -c "[[ -f lib/libezfio.a ]] && rm $$PWD/lib/*"
- bash -c "[[ -f Python/ezfio.py ]] && rm $$PWD/Python/*" - bash -c "[[ -f Python/ezfio.py ]] && rm $$PWD/Python/*"
- bash -c "[[ -f Ocaml/ezfio.ml ]] && rm $$PWD/Ocaml/*" - bash -c "[[ -f Ocaml/ezfio.ml ]] && rm $$PWD/Ocaml/*"
- bash -c "[[ -f Bash/ezfio.sh ]] && rm $$PWD/Bash/*"
- $(MAKE) -C $$PWD/src veryclean - $(MAKE) -C $$PWD/src veryclean
archive: distclean archive: distclean

View File

@ -1,16 +1,16 @@
include version include version
rule build_generated_ninja rule build_generated_ninja
command = python $in ninja command = python configure.py
description = Creating generated.ninja description = Creating generated.ninja
generator = 1
rule run_ninja rule run_ninja
command = bash -c 'source .make.config.sh ; exec bash -c "$$NINJA -f $in"' command = bash -c 'source .make.config.sh ; $$NINJA -f $in'
description = Building Fortran library description = Building Fortran library
pool = console
rule build_archive 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 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 description = Building archive
rule clean_all rule clean_all
@ -18,9 +18,10 @@ rule clean_all
description = Cleaning directory description = Cleaning directory
build make.config .make.config.sh generated.ninja: build_generated_ninja configure.py build make.config .make.config.sh generated.ninja impossible_target: build_generated_ninja
build all: run_ninja generated.ninja build all: run_ninja generated.ninja
default all default all
build EZFIO.${VERSION}.tar.gz: build_archive build EZFIO.${VERSION}.tar.gz: build_archive

View File

@ -2,6 +2,20 @@
import os,sys import os,sys
def write_if_different(filename,s):
try:
with open(filename, "r") as f:
ref = f.read()
except:
ref = ""
if ref == s:
return
else:
with open(filename, "w") as f:
f.write(s)
with open("version",'r') as f: with open("version",'r') as f:
version = f.read().strip().rsplit('=')[1] version = f.read().strip().rsplit('=')[1]
@ -13,22 +27,37 @@ d_default = {
"RANLIB" : 'ranlib', "RANLIB" : 'ranlib',
"AR" : 'ar', "AR" : 'ar',
"NINJA" : 'ninja', "NINJA" : 'ninja',
"CONFIG_FILES" :
' '.join([ os.path.join("config",x) for x in os.listdir('config') if x != '.empty'])
} }
CONFIG_FILES=' '.join([ os.path.join("config",x) for x in os.listdir('config') if x != '.empty'])
def create_make_config(): def create_make_config():
try:
d = read_make_config()
except:
d = {}
fmt = { "make.config" :'{0}={1}\n' , fmt = { "make.config" :'{0}={1}\n' ,
".make.config.sh": '{0}="{1}"\n' } ".make.config.sh": 'export {0}="{1}"\n' }
for filename in fmt:
with open(filename,'w') as out:
for var,default in d_default.iteritems(): for var,default in d_default.iteritems():
if var not in d:
try: try:
cur = os.environ[var] cur = os.environ[var]
except KeyError: except KeyError:
cur = default cur = default
out.write(fmt[filename].format(var,cur)) d[var]=cur
for filename in fmt:
out = ""
for var,default in d_default.iteritems():
cur = d[var]
out += fmt[filename].format(var,cur)
write_if_different(filename,out)
return d
def read_make_config(): def read_make_config():
@ -47,9 +76,7 @@ def read_make_config():
def create_build_ninja(): def create_build_ninja():
create_make_config() d=create_make_config()
d = read_make_config()
d["irpf90_files"] = [ "src/{0}".format(x) for x in d["irpf90_files"] = [ "src/{0}".format(x) for x in
""" """
@ -71,20 +98,13 @@ def create_build_ninja():
template = """ template = """
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
rule build_make_config
command = python configure.py
description = Creating make.config
rule compile_irpf90 rule compile_irpf90
command = cd src ; {IRPF90} --ninja command = bash -c 'source .make.config.sh ; cd src ; {IRPF90} --ninja'
description = Compiling IRPF90 description = Compiling IRPF90
rule build_irpf90_a rule build_irpf90_a
command = {NINJA} -C src/IRPF90_temp command = {NINJA} -C src/IRPF90_temp && touch $out
description = Compiling Fortran files description = Compiling Fortran files
rule build_libezfio_a rule build_libezfio_a
@ -103,9 +123,6 @@ rule build_ocaml
command = cd src ; python create_ocaml.py command = cd src ; python create_ocaml.py
description = Building Ocaml module description = Building Ocaml module
build make.config: build_make_config | configure.py
build {irpf90_files}: compile_irpf90 | {irpf90_sources} {CONFIG_FILES} build {irpf90_files}: compile_irpf90 | {irpf90_sources} {CONFIG_FILES}
build src/IRPF90_temp/irpf90.a: build_irpf90_a | {irpf90_files} build src/IRPF90_temp/irpf90.a: build_irpf90_a | {irpf90_files}
@ -119,9 +136,8 @@ build Python/ezfio.py: build_python | lib/libezfio.a
build Ocaml/ezfio.ml: build_ocaml | lib/libezfio.a build Ocaml/ezfio.ml: build_ocaml | lib/libezfio.a
""" """
d["CONFIG_FILES"] = CONFIG_FILES
with open('generated.ninja','w') as f: write_if_different('generated.ninja',template.format(**d))
f.write(template.format(**d))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1 +1 @@
VERSION=1.3.0 VERSION=1.3.1