From 552be3a8a8e85c4e40d8fc53daaac39bdce23b90 Mon Sep 17 00:00:00 2001 From: Stefano Zaghi Date: Mon, 11 Mar 2024 10:26:10 +0100 Subject: [PATCH] fix bug on preprocessing, add missin include --- src/main/python/fobis/ParsedFile.py | 24 +++++++++++++++--- .../__pycache__/Compiler.cpython-310.pyc | Bin 9832 -> 9832 bytes .../fobis/__pycache__/Gcov.cpython-310.pyc | Bin 9234 -> 9232 bytes .../__pycache__/ParsedFile.cpython-310.pyc | Bin 14607 -> 15033 bytes .../__pycache__/cli_parser.cpython-310.pyc | Bin 14780 -> 14780 bytes .../fobis/__pycache__/fobis.cpython-310.pyc | Bin 17145 -> 17184 bytes src/main/python/fobis/fobis.py | 8 +++--- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/python/fobis/ParsedFile.py b/src/main/python/fobis/ParsedFile.py index 9b84236..0cef87d 100644 --- a/src/main/python/fobis/ParsedFile.py +++ b/src/main/python/fobis/ParsedFile.py @@ -116,6 +116,8 @@ def apply_styles(graph): __str_kw_ieee_exceptions__ = r"[Ii][Ee][Ee][Ee]_[Ee][Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn][Ss]" __str_kw_ieee_arithmetic__ = r"[Ii][Ee][Ee][Ee]_[Aa][Rr][Ii][Tt][Hh][Mm][Ee][Tt][Ii][Cc]" __str_kw_ieee_features__ = r"[Ii][Ee][Ee][Ee]_[Ff][Ee][Aa][Tt][Uu][Rr][Ee][Ss]" +__str_kw_openacc__ = r"[Oo][Pp][Ee][Nn][Aa][Cc][Cc]" +__str_kw_omp_lib__ = r"[Oo][Mm][Pp]_[Ll][Ii][Bb]" __str_kw_module__ = r"[Mm][Oo][Dd][Uu][Ll][Ee]" __str_kw_submodule__ = r"[Ss][Uu][Bb][Mm][Oo][Dd][Uu][Ll][Ee]" __str_kw_program__ = r"[Pp][Rr][Oo][Gg][Rr][Aa][Mm]" @@ -157,6 +159,14 @@ def apply_styles(graph): __str_kw_use__ + # keyword "use" r"\s+" + __str_kw_ieee_features__ + # keyword intrinsic module ieee_features r"(?P(.*))") +__str_use_mod_openacc__ = (r"^(\s*)" + # eventual initial white spaces + __str_kw_use__ + # keyword "use" + r"\s+" + r"(.*)" + __str_kw_openacc__ + r".*" + # keyword intrinsic module openacc + r"(?P(.*))") +__str_use_mod_omp_lib__ = (r"^(\s*)" + # eventual initial white spaces + __str_kw_use__ + # keyword "use" + r"\s+" + r"(.*)" + __str_kw_omp_lib__ + r".*" + # keyword intrinsic module omp_lib + r"(?P(.*))") __str_include__ = (r"^(\s*|\#)" + # eventual initial white spaces or "#" character __str_kw_include__ + # keyword "include" r"(\s+)" + # 1 or more white spaces @@ -196,12 +206,16 @@ def apply_styles(graph): __regex_use_mod_ieee_exceptions__ = re.compile(__str_use_mod_ieee_exceptions__) __regex_use_mod_ieee_arithmetic__ = re.compile(__str_use_mod_ieee_arithmetic__) __regex_use_mod_ieee_features__ = re.compile(__str_use_mod_ieee_features__) +__regex_use_mod_openacc__ = re.compile(__str_use_mod_openacc__) +__regex_use_mod_omp_lib__ = re.compile(__str_use_mod_omp_lib__) __regex_use_intrinsic_modules__ = [__regex_use_mod_intrinsic__, __regex_use_mod_iso_fortran_env__, __regex_use_mod_iso_c_binding__, __regex_use_mod_ieee_exceptions__, __regex_use_mod_ieee_arithmetic__, - __regex_use_mod_ieee_features__] + __regex_use_mod_ieee_features__, + __regex_use_mod_openacc__, + __regex_use_mod_omp_lib__] __regex_mpifh__ = re.compile(__str_mpifh__) # alternative "open and read"... it should avoid encoding issues with python 2.X vs 3.X @@ -297,7 +311,7 @@ def sort_dependencies(self): self.pfile_dep_all.sort(key=operator.attrgetter('order'), reverse=True) return - def parse(self, inc, preprocessor='cpp', preproc=''): + def parse(self, inc=['.INC', '.F', '.FOR', '.FPP', '.F77', '.F90', '.F95', '.F03', '.F08'], preprocessor='cpp', preproc='', include=''): """ Parse the file creating its the dependencies list and the list of modules names that self eventually contains. @@ -309,12 +323,14 @@ def parse(self, inc, preprocessor='cpp', preproc=''): preprocessor name preproc : str preprocessor flags + include : list + include directories """ self.module_names = [] self.submodule_names = [] self.dependencies = [] - if self.extension in ['.INC', '.F', '.FOR', '.FPP', '.F77', '.F90', '.F95', '.F03', '.F08']: + if self.extension in inc: preprocessor_exist = False for path in os.environ["PATH"].split(os.pathsep): preprocessor_exist = os.path.exists(os.path.join(path, preprocessor)) @@ -325,7 +341,7 @@ def parse(self, inc, preprocessor='cpp', preproc=''): preprocessor += ' -C -w ' elif preprocessor == 'fpp': preprocessor += ' -w ' - source = str(check_output(preprocessor + ' ' + preproc + ' ' + self.name, shell=True, stderr=STDOUT, encoding='UTF-8')) + source = str(check_output(preprocessor + ' ' + preproc + ' ' + '-I'.join(include) + ' ' + self.name, shell=True, stderr=STDOUT, encoding='UTF-8')) source = source.replace('\\n', '\n') else: source = str(openReader(self.name).read()) diff --git a/src/main/python/fobis/__pycache__/Compiler.cpython-310.pyc b/src/main/python/fobis/__pycache__/Compiler.cpython-310.pyc index 7a3c6149316204417ec1353582ec00790060e713..319622238358860a48ad392598eccbd01e3a9981 100644 GIT binary patch delta 21 bcmaFi^TLNGpO=@50SIy$UZ!s3iBSUpOKApy delta 21 bcmaFi^TLNGpO=@50SG3wMtKOm9#u~MX|Xev!a7O2B8^JoXBGm|%OL=q8P znYb{9x01MYsWGGrO^k^vW8AVa?;rRRbfLamoY4i7=Jeci&fJ-I-<$37^RjHmUvgLeStYl*J%CD`n*qT&nz+<99!mDw`~7T3%xrVg4|mNuCvO*=LHw zGoAmORvlLB260)`33~VpdiY%SS#&H>7 z8sG}R3_yuiQ;U2%-lUGoWiGI=3D0BAz0~Ir*LQlp3A5DgJuS*1Noe~mh3M0$!AjkN*qQ{RKeMCZF)-;!?xlE~vqA`O z(66}*$zW{wA+&o&ALY}uI5aG5)48GfO(r?2OHO&jFkK8^8z0bm&9-YM(&{QEI0koB z!H8XLz+7iAw)qd_MSwfti8epxD&d9w9_5^$ mbG>D3^S7`-?+St|o~04Pwzw$oi*RaqMQ`Vi2_9X~zxV^L89EvO delta 1047 zcmZvb&rcIk5XW8UkL`9#TcNF}E!!4_79u|s42qhFR0OP$fW)V9UD`)k-R^GQzKWcP zClgP`cTrLLz9xCCJu5N31!4i@PW z+3mm_Z}1^76Fdq=0?_L=xCvq2EuNMXxre8U|JCu+52fM;@*8HYx{L`DaZ^b()75fQ zsWz`^`{y)buePdF2l;KcM^izMrk0z^?eW)9?X9KYN6#<{IGCzbrv^q6NCQ`}Sw?N3 zZ5^wIwu}u2iCVd=mNlv&R)}m*AaU{@F4ZV5BWcmZP3;>UnHVY*kgre}8y+3Z`N$xQ zV+b$|I1V@g7-93#>-=@Rjvkax@&xi4a6Pp3HTt=g=by#C3A49f zdJd8YIOUhS@07f7jeS?*e9XU;9&e7Dh;^r* zi``u1T8YNC)2CwYtjH}mZ37ap=PaMe3X~NyiyKI?HHRLnQQdF|d}(|%>lMqY7`U{m z5lVt^YMi4Uyi|pWP7-1f(zu`V;9USuwD^i^lp8V+QHQEJl&E*sRBYfXHmPQ)Dhj(< oyGAfi#8j5ac66h5*I22UC8}E{H|5<5n+${rSOu(j;dKYW}RyZ`_I diff --git a/src/main/python/fobis/__pycache__/ParsedFile.cpython-310.pyc b/src/main/python/fobis/__pycache__/ParsedFile.cpython-310.pyc index 17cb35510fd672c557577458009cf9c28a45bf34..b584345537e08fe4810caa1d032b321b9c89c919 100644 GIT binary patch delta 2439 zcmZuwX>1!s6y8~{?e!7ow&UD~+r(~@=4z7WKAWV?)ub1;j7dG))M?^4Yxf{HG9-Z> zP-q#TEg)(GrIboYl`9Y+(H~Sus1oplKSZLU5&|KRs!CLdA_Q;7aq6_}YQFjAd*6HW zW<7pM{^XEhCMikF!Q(&uyJXpW#*m9Xyt?5M3fb#$lf51{OEo4Ax0pC-Gt8|f&fc)1 zwSiU!TKkH=Wkv4*-MXSRCTO-5ttmm$htU%P5l+kkoe-#s2SBT%hJ<(* z#H$nH@w{%_Db<1wjoN#pyzo}3A%g6^jCBC(W2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Z{|yzr}8` zTbo2wV2l0@yU}#1=zX4E&*d^3YYsw;9c}(2cVW#quu$vH@@c+unoF9?n_Q;Y<<@&9 k{Uqlz>}q&5WZ3=i88+TF!~E?>%Ov>sYj|u?RJly~2Z0CosQ>@~ diff --git a/src/main/python/fobis/__pycache__/cli_parser.cpython-310.pyc b/src/main/python/fobis/__pycache__/cli_parser.cpython-310.pyc index 5c0f5ec9c0fcb05b2ec10e6e73edad3d5bca670c..47918212ab92a39771827cb59e0bef73dd4f2840 100644 GIT binary patch delta 21 bcmdl}yr-BapO=@50SIy$UZ!s3*00rFfL?tVTg_GWGG>6XGmjAVM<|c;Q*^(b75#^Y-TK~m|P$t%UChFPef9>qJ*b} zIg5P(Zw+Gy!$PJSrWE#Grdrk-rlQoz6GX*=z#4^8IC@za8S?mQShM)RBK%-d5Gu>r z%go47!@NMahIJt$BSWEdp#ab+B2cHK$1ry?*0R;I*RTT}7C%`|RGRVWWGhiw%cmt= z?TkPt^1z+Q4RzvEh@(2dj;iG-;i=(3a@r-3(=5nxT3ccL=1Zbn%#19P?@Gvs6%_#k zQj@u8Dv&Cg4kADTli!F*PL`8=$|yRSMQR3P(c~FYjm#>HGLvPbB|-FN3+aRE02zsD AM*si- delta 466 zcmb7=PfG$p7{=$Faou%y-86S473~s*9qSZy%kNM@A>|sl2mg#qAk3DaWghG@L>)@>y=3!oDUY_6c`j_x|0Y)tvRgtL5-fQ`*cyEBIDxxLg zG#_}%T-ki_fFTDtn7S_ULkxycK!>}19L-XI&oC8?keGD}+ziExw(41Cy_& k@Ay;NTh2ietAN}1!_*W=Lk^YzPYtX?NZga7V&-w}8-J;J2mk;8 diff --git a/src/main/python/fobis/fobis.py b/src/main/python/fobis/fobis.py index 6fd3d20..8414f9c 100644 --- a/src/main/python/fobis/fobis.py +++ b/src/main/python/fobis/fobis.py @@ -258,9 +258,9 @@ def parse_files(configuration, src_dir=None, is_doctest=False): all(exc not in os.path.dirname(filename) for exc in configuration.cliargs.exclude_dirs)): pfile = ParsedFile(name=os.path.join(src_dir, filename), is_doctest=is_doctest) if is_doctest: - pfile.parse(inc=configuration.cliargs.inc, preprocessor=configuration.cliargs.doctests_preprocessor, preproc=configuration.cliargs.preproc) + pfile.parse(inc=configuration.cliargs.inc, preprocessor=configuration.cliargs.doctests_preprocessor, preproc=configuration.cliargs.preproc, include=configuration.cliargs.include) else: - pfile.parse(inc=configuration.cliargs.inc, preproc=configuration.cliargs.preproc) + pfile.parse(inc=configuration.cliargs.inc, preproc=configuration.cliargs.preproc, include=configuration.cliargs.include) pfiles.append(pfile) else: for root, _, files in os.walk(src_dir): @@ -271,9 +271,9 @@ def parse_files(configuration, src_dir=None, is_doctest=False): filen = os.path.join(root, filename) pfile = ParsedFile(name=filen, is_doctest=is_doctest) if is_doctest: - pfile.parse(inc=configuration.cliargs.inc, preprocessor=configuration.cliargs.doctests_preprocessor, preproc=configuration.cliargs.preproc) + pfile.parse(inc=configuration.cliargs.inc, preprocessor=configuration.cliargs.doctests_preprocessor, preproc=configuration.cliargs.preproc, include=configuration.cliargs.include) else: - pfile.parse(inc=configuration.cliargs.inc, preproc=configuration.cliargs.preproc) + pfile.parse(inc=configuration.cliargs.inc, preproc=configuration.cliargs.preproc, include=configuration.cliargs.include) pfiles.append(pfile) return pfiles