Skip to content
Snippets Groups Projects
Commit e2266e90 authored by Virgile Prevosto's avatar Virgile Prevosto Committed by Andre Maroneze
Browse files

headers & lint

parent 35db023b
No related branches found
No related tags found
No related merge requests found
...@@ -266,8 +266,8 @@ README* header_spec=.ignore ...@@ -266,8 +266,8 @@ README* header_spec=.ignore
/share/win32_installer.iss header_spec=.ignore /share/win32_installer.iss header_spec=.ignore
/share/win32_manual_installation_step.txt header_spec=.ignore /share/win32_manual_installation_step.txt header_spec=.ignore
/share/compliance/*.json header_spec=.ignore /share/compliance/*.json header_spec=.ignore
/share/machdeps/.machdep_*.validated header_spec=.ignore
/share/machdeps/machdep-schema.json header_spec=.ignore /share/machdeps/machdep-schema.json header_spec=.ignore
/share/machdeps/machdep_*.json header_spec=.ignore
/share/machdeps/machdep-schema.yaml header_spec=.ignore /share/machdeps/machdep-schema.yaml header_spec=.ignore
/share/machdeps/machdep_*.yaml header_spec=.ignore /share/machdeps/machdep_*.yaml header_spec=.ignore
/tests/**/* header_spec=.ignore /tests/**/* header_spec=.ignore
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# for more details (enclosed in the file licenses/LGPLv2.1). # # for more details (enclosed in the file licenses/LGPLv2.1). #
# # # #
########################################################################## ##########################################################################
MANUAL_MACHDEPS=machdep_gcc_x86_16.yaml machdep_msvc_x86_64.yaml MANUAL_MACHDEPS=machdep_gcc_x86_16.yaml machdep_msvc_x86_64.yaml
update-all: machdep_*.yaml $(MANUAL_MACHDEPS:%=.%.validated) update-all: machdep_*.yaml $(MANUAL_MACHDEPS:%=.%.validated)
......
/**************************************************************************/
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* 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, version 2.1. */
/* */
/* It 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. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/**************************************************************************/
#include <errno.h> #include <errno.h>
/* Mandatory */ /* Mandatory */
......
/**************************************************************************/
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* 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, version 2.1. */
/* */
/* It 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. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/**************************************************************************/
#include <limits.h> #include <limits.h>
int path_max_is = PATH_MAX; int path_max_is = PATH_MAX;
......
...@@ -86,12 +86,12 @@ parser.add_argument( ...@@ -86,12 +86,12 @@ parser.add_argument(
parser.add_argument( parser.add_argument(
"--check", "--check",
action="store_true", action="store_true",
help="checks that the generated machdep is conforming to the schema" help="checks that the generated machdep is conforming to the schema",
) )
parser.add_argument( parser.add_argument(
"--check-only", "--check-only",
action="store_true", action="store_true",
help="must be used in conjunction with --from-file to check that the provided input file is conforming to the schema" help="must be used in conjunction with --from-file to check that the provided input file is conforming to the schema",
) )
args, other_args = parser.parse_known_args() args, other_args = parser.parse_known_args()
...@@ -99,6 +99,7 @@ args, other_args = parser.parse_known_args() ...@@ -99,6 +99,7 @@ args, other_args = parser.parse_known_args()
if not args.compiler_flags: if not args.compiler_flags:
args.compiler_flags = ["-c"] args.compiler_flags = ["-c"]
def make_schema(): def make_schema():
schema_filename = my_path.parent / "machdep-schema.yaml" schema_filename = my_path.parent / "machdep-schema.yaml"
with open(schema_filename, "r") as schema: with open(schema_filename, "r") as schema:
...@@ -124,6 +125,7 @@ def check_machdep(machdep): ...@@ -124,6 +125,7 @@ def check_machdep(machdep):
warnings.warn("machdep object is not conforming to machdep schema") warnings.warn("machdep object is not conforming to machdep schema")
return False return False
if args.from_file: if args.from_file:
orig_file = open(args.from_file, "r") orig_file = open(args.from_file, "r")
orig_machdep = yaml.safe_load(orig_file) orig_machdep = yaml.safe_load(orig_file)
...@@ -141,6 +143,7 @@ if args.from_file: ...@@ -141,6 +143,7 @@ if args.from_file:
else: # old version of the schema used a single string else: # old version of the schema used a single string
args.cpp_arch_flags = orig_machdep["cpp_arch_flags"].split() args.cpp_arch_flags = orig_machdep["cpp_arch_flags"].split()
def print_machdep(machdep): def print_machdep(machdep):
if args.from_file and args.in_place: if args.from_file and args.in_place:
args.dest_file = open(args.from_file, "w") args.dest_file = open(args.from_file, "w")
...@@ -148,12 +151,14 @@ def print_machdep(machdep): ...@@ -148,12 +151,14 @@ def print_machdep(machdep):
args.dest_file = sys.stdout args.dest_file = sys.stdout
yaml.dump(machdep, args.dest_file, indent=4, sort_keys=True) yaml.dump(machdep, args.dest_file, indent=4, sort_keys=True)
def make_machdep(): def make_machdep():
machdep = {} machdep = {}
for key in schema.keys(): for key in schema.keys():
machdep[key] = None machdep[key] = None
return machdep return machdep
machdep = make_machdep() machdep = make_machdep()
compilation_command = [args.compiler] + args.cpp_arch_flags + args.compiler_flags compilation_command = [args.compiler] + args.cpp_arch_flags + args.compiler_flags
...@@ -256,10 +261,10 @@ def cleanup_cpp(output): ...@@ -256,10 +261,10 @@ def cleanup_cpp(output):
return " ".join(macro) return " ".join(macro)
def find_macros_value(output,is_list=False,entry=None): def find_macros_value(output, is_list=False, entry=None):
msg = re.compile("(\w+)_is = ([^;]+);") msg = re.compile("(\w+)_is = ([^;]+);")
if is_list: if is_list:
assert(entry) assert entry
machdep[entry] = {} machdep[entry] = {}
for res in re.finditer(msg, output): for res in re.finditer(msg, output):
name = res.group(1) name = res.group(1)
...@@ -276,6 +281,7 @@ def find_macros_value(output,is_list=False,entry=None): ...@@ -276,6 +281,7 @@ def find_macros_value(output,is_list=False,entry=None):
if args.verbose: if args.verbose:
print(f"compiler output is:{output}") print(f"compiler output is:{output}")
for (f, typ) in source_files: for (f, typ) in source_files:
p = my_path / f p = my_path / f
cmd = compilation_command + [str(p)] cmd = compilation_command + [str(p)]
...@@ -307,7 +313,7 @@ for (f, typ) in source_files: ...@@ -307,7 +313,7 @@ for (f, typ) in source_files:
if name in machdep: if name in machdep:
machdep[name] = {} machdep[name] = {}
continue continue
find_macros_value(cleanup_cpp(proc.stdout.decode()),is_list=True,entry=name) find_macros_value(cleanup_cpp(proc.stdout.decode()), is_list=True, entry=name)
continue continue
if typ == "has__builtin_va_list": if typ == "has__builtin_va_list":
# Special case: compilation success determines presence or absence # Special case: compilation success determines presence or absence
......
/**************************************************************************/
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* 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, version 2.1. */
/* */
/* It 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. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/**************************************************************************/
#include <stdio.h> #include <stdio.h>
int bufsiz_is = BUFSIZ; int bufsiz_is = BUFSIZ;
......
/**************************************************************************/
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* 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, version 2.1. */
/* */
/* It 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. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/**************************************************************************/
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -338,10 +338,10 @@ let yaml_dict_to_list = function ...@@ -338,10 +338,10 @@ let yaml_dict_to_list = function
Result.( Result.(
bind acc bind acc
(fun l -> (fun l ->
match Yaml.Util.to_string v with match Yaml.Util.to_string v with
| Ok s -> Ok((k,s) :: l) | Ok s -> Ok((k,s) :: l)
| Error (`Msg s) -> | Error (`Msg s) ->
Error (`Msg ("Unexpected value for key " ^ k ^ ": " ^ s)))) Error (`Msg ("Unexpected value for key " ^ k ^ ": " ^ s))))
in in
List.fold_left make_one (Ok []) l List.fold_left make_one (Ok []) l
| _ -> Error (`Msg "Unexpected YAML value instead of dictionary of strings") | _ -> Error (`Msg "Unexpected YAML value instead of dictionary of strings")
...@@ -434,9 +434,9 @@ let get_machdep () = ...@@ -434,9 +434,9 @@ let get_machdep () =
let print_machdep_header () = let print_machdep_header () =
if Kernel.PrintMachdepHeader.get () then begin if Kernel.PrintMachdepHeader.get () then begin
Machdep.gen_all_defines Format.std_formatter (get_machdep()); Machdep.gen_all_defines Format.std_formatter (get_machdep());
raise Cmdline.Exit raise Cmdline.Exit
end else Cmdline.nop end else Cmdline.nop
let () = Cmdline.run_after_exiting_stage print_machdep_header let () = Cmdline.run_after_exiting_stage print_machdep_header
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment