From b4a6ade63f0055d9b03fde7fa673cd57e5a714f9 Mon Sep 17 00:00:00 2001 From: Eric Fayolle Date: Tue, 22 Mar 2022 17:51:14 +0100 Subject: [PATCH] Constuction des .xsd, driver_xsd, tests_python des .comm et .xml par GNUmakefile --- ReacteurNumerique/GNUmakefile | 135 ++++++++++++++++++++++++++++++++++ Tools/generateStructure.py | 33 +++++++++ Tools/generateXML.py | 36 +++++++++ Tools/generateXSD.py | 33 +++++++++ Tools/qtEficasGui.py | 46 ++++++++++++ Tools/validateDataSet.py | 36 +++++++++ config/GNUmakefile.env | 2 +- config/test_driver_subst.py | 2 +- 8 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 ReacteurNumerique/GNUmakefile create mode 100755 Tools/generateStructure.py create mode 100755 Tools/generateXML.py create mode 100755 Tools/generateXSD.py create mode 100755 Tools/qtEficasGui.py create mode 100755 Tools/validateDataSet.py diff --git a/ReacteurNumerique/GNUmakefile b/ReacteurNumerique/GNUmakefile new file mode 100644 index 00000000..a7876cb0 --- /dev/null +++ b/ReacteurNumerique/GNUmakefile @@ -0,0 +1,135 @@ +.SUFFIXES: .xsd .py _driver.py _test_driver_0.comm _test_driver_1.comm _test_driver_0.xml _test_driver_1.xml _test_driver_0.py _test_driver_1.py .comm .xml +#TODO : Supprimer les suffixes inutiles depuis l'utilisation des des règles pattern au lieu des règles suffixes +#TODO : Ajouter la dépendance entre le make .xml et la présence du driver +.PHONY: xsdAll driverAll +SHELL=bash + +ifdef EFICAS4VIMMP_ROOT +srcdir?=${EFICAS4VIMMP_ROOT} +else +srcdir?=.. +endif + +confdir?=$(srcdir)/config +tooldir=$(srcdir)/Tools + +# Règle en tête de Makefile +all: driverAll + +include $(confdir)/GNUmakefile.env + +#PYXB ?=pyxbgen +#PYXB ?=pyxbgen-py3 + +ifndef PYXB + ifeq (, $(shell which pyxbgen)) + ifeq (, $(shell which pyxbgen-py3)) + $(error "No pyxbgen $(PATH), consider installing pyxb") + else + PYXB =pyxbgen-py3 + endif + else + PYXB =pyxbgen + endif +endif + +################# REGLES DE CONSTRUCTION ######################## + +#Dépendances entre catalogues : +define cata_dependencies = +# Exemple: cata_gromacs$1 : cata_Vimmp$1 +endef + +#Définition des dépendances pour le modèle .py +$(eval $(call cata_dependencies,.py)) +#Définition des dépendances pour le modèle .xsd +$(eval $(call cata_dependencies,.xsd)) + +# $(subst .py,.xsd,cata_dependencies) + +cata_files= \ +cata_RN_EDG_PN.py + +cata_basename=$(cata_files:%.py=%) +xsd_files = $(cata_files:%.py=%.xsd) +driver_files= $(cata_files:%.py=%_driver.py) + +xsdAll: $(xsd_files) +driverAll: exec.sh environ.sh qtEficas.sh $(driver_files) +# qtEficasSlm.sh + + +# Exemple PyxB : $(PYXB) -m $(basename $@) -u $< --location-prefix-rewrite http://chercheurs.edf.com/logiciels/vimmp= --write-for-customization \ +# L'utilisation de $? ne fonctionne pas si l'on ne modifie qu'un seul catalogue car il liste uniquement les fichiers modifiés et pyxb détecte +# que l'autre fichier en dépend et qu'il n'a pas été regénéré en même temps: $^ +.py.xsd: + $(tooldir)/generateXSD.py -c $(abspath $<) + +.xsd_driver.py: + $(PYXB) -m $(basename $@) -u $^ --write-for-customization + xmllint --path $(confdir) --schema XMLSchema11_local.xsd --noout $^ + +#Les Tools eficas ont besoins d'un chemin absolu +#ATTENTION : La .sufix rule n'autorise pas les dépendances après le : (sinon la ligne entière est un nom de fichier bizzare) +#_test_driver_$1.comm_test_driver_$1.xml: +# il faut les définir à part +# TODO : +#.SECONDEXPANSION: +#%_test_driver_$1.xml : %_test_driver_$1.comm $$(realpath $$(*).py) $$(*)_driver.py + +define test_xml_rule = +%_test_driver_$1.xml : %_test_driver_$1.comm $$(realpath $$(*).py) + echo -e "\n\n------ $$(*)_driver.py ----------\n" + @echo -e "\n\n------ Generate xml test file $$(@) ------\n" + @[[ -f $$(*).py ]] || (echo "Le fichier catalogue $$(*).py est introuvable" && false) + $(tooldir)/generateXML.py -c $$(abspath $$(*).py) $$< +endef + + +#ATTENTION : La .sufix rule n'autorise pas les dépendances après le : (sinon la ligne entière est un nom de fichier bizzare) +#_test_driver_$1.comm_test_driver_$1.py: +# il faut les définir à part +define test_driver_rule = +%_test_driver_$1.py : %_test_driver_$1.comm $(confdir)/test_driver_subst.py + @echo -e "\n\n------ Generate xml test driver $$(@) ------\n" + sed -e "s,@module@,$$(*)_driver,g" -e "s,@file@,$$(<:%.comm=%.xml),g" $$(confdir)/test_driver_subst.py > $$(@) && \ + chmod +x $$(<:%.comm=%.py); +endef + +#Définition des règles de construction pour les tests +#$(eval $(call test_driver_rule,0)) +#$(eval $(call test_driver_rule,1)) +$(foreach it,0 1 2 3 4 5 6 7 8 9, $(eval $(call test_xml_rule,$(it))) ) +$(foreach it,0 1 2 3 4 5 6 7 8 9, $(eval $(call test_driver_rule,$(it))) ) + +#test_driver_xml:= $(patsubst %.comm,%.xml,$(wildcard *_test_driver_?.comm)) +#test_driver_py:= $(patsubst %.comm,%.py,$(wildcard *_test_driver_?.comm)) + +new_test_driver_xml:= $(foreach it,$(cata_basename), $(patsubst %.comm,%.xml,$(wildcard $(it)_test_driver_?.comm)) ) +new_test_driver_py:= $(foreach it,$(cata_basename), $(patsubst %.comm,%.py,$(wildcard $(it)_test_driver_?.comm)) ) + +#$(info $(new_test_driver_xml) "----" $(cata_basename) ) +#$(info $(new_test_driver_py) "----" $(cata_basename) ) + +# xml: +# @echo "Reminder: a .comm file is needed for this step" +# ../tools/generateXML.py -c cata_1.py cata_1_test_1.comm + +check test: testAll + +################# REGLES DE TESTS ######################## + +testAll: exec.sh driverAll $(new_test_driver_py) $(new_test_driver_xml) + for i in $(new_test_driver_py) ; do echo -e "\n\n------ Launching $$i ------" && ./exec.sh python3 $$i ; done +# for i in `ls *_test_driver*.py` ; do echo -e "\n\n------ Launching $$i ------" && ./exec.sh python $$i || break ; done + +################# REGLES DE NETTOYAGE ######################## + +clean: + rm -f *.pyc *~ qtEficasSlm.sh exec.sh environ.sh + rm -rf raw binding.py __pycache__ + rm -f $(xsd_files) $(driver_files) *test_driver_?.py *test_driver_?.xml + +cleantest: + rm -f *test_driver_?.py *test_driver_?.xml + diff --git a/Tools/generateStructure.py b/Tools/generateStructure.py new file mode 100755 index 00000000..d1341e07 --- /dev/null +++ b/Tools/generateStructure.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + cree le .xsd associe au .py + generateXSD.py -c leCatalogueAVECSONNOMCOMPLET POUR TROUVER LE DRIVER + 23 avril +""" +# Modules Python +# Modules Eficas +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) + +from InterfaceQT4 import eficas_go +eficas_go.genereStructure(code='NonConnu') diff --git a/Tools/generateXML.py b/Tools/generateXML.py new file mode 100755 index 00000000..dbc99449 --- /dev/null +++ b/Tools/generateXML.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +"" + cree le .xml associe au .comm + generateXML.py -c leCatalogue le.comm + 23 avril + +""" +# Modules Python +# Modules Eficas + +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../')) + +from InterfaceQT4 import eficas_go +eficas_go.genereXML(code='NonConnu') diff --git a/Tools/generateXSD.py b/Tools/generateXSD.py new file mode 100755 index 00000000..813d874e --- /dev/null +++ b/Tools/generateXSD.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + cree le .xsd associe au .py + generateXSD.py -c leCatalogueAVECSONNOMCOMPLET POUR TROUVER LE DRIVER + 23 avril +""" +# Modules Python +# Modules Eficas +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) + +from InterfaceQT4 import eficas_go +eficas_go.genereXSD(code='NonConnu') diff --git a/Tools/qtEficasGui.py b/Tools/qtEficasGui.py new file mode 100755 index 00000000..8c568ee9 --- /dev/null +++ b/Tools/qtEficasGui.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + Ce module sert a lancer EFICAS contre l avis de Pascale sans directory associee + Dans ce cas on peut taper + a) de n importe ou sans avoir rien positionne : + /leCheminVersTools/qtEficasGui.py -c leFichierCatalogueAvecSonPathComplet + b) En ayant positionne le PYTHONPATH avec la directory qui contient ce qu il faut + c est a dire le prefs.py et prefs_leCode.py + exemple pour Adao + /leCheminVersTools/qtEficasGui.py -k Adao + /leCheminVersTools/qtEficasGui.py -k Adao -v V95 + version du 23 avril + +""" +# Modules Python +# Modules Eficas + +import sys +import os + +repIni=os.path.dirname(os.path.abspath(__file__)) +INSTALLDIR=os.path.join(repIni,'..') +sys.path[:0]=[INSTALLDIR] +#sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../..')) + +from InterfaceQT4 import eficas_go +eficas_go.lanceEficas(code='NonConnu') diff --git a/Tools/validateDataSet.py b/Tools/validateDataSet.py new file mode 100755 index 00000000..763f0fc0 --- /dev/null +++ b/Tools/validateDataSet.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +"" + cree le .xml associe au .comm + generateXML.py -c leCatalogue le.comm + 23 avril + +""" +# Modules Python +# Modules Eficas + +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../')) + +from InterfaceQT4 import eficas_go +eficas_go.validateDataSet(code='NonConnu') diff --git a/config/GNUmakefile.env b/config/GNUmakefile.env index 5a3f8eff..918cf4ec 100644 --- a/config/GNUmakefile.env +++ b/config/GNUmakefile.env @@ -8,7 +8,7 @@ ifndef confdir $(error "La variable confdir doit être définie pour utiliser GNUmakefile.env" endif ifndef tooldir -$(error "La variable confdir doit être définie pour utiliser GNUmakefile.env" +$(error "La variable tooldir doit être définie pour utiliser GNUmakefile.env" endif # " pour emacs beautifying diff --git a/config/test_driver_subst.py b/config/test_driver_subst.py index e494f2af..bd7d9edc 100755 --- a/config/test_driver_subst.py +++ b/config/test_driver_subst.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # -*- coding:utf-8 -*- import sys -- 2.39.2