diff --git a/lkql_checker/src/gnatcheck-compiler.adb b/lkql_checker/src/gnatcheck-compiler.adb index b8f6e8d4b..8c2ffc598 100644 --- a/lkql_checker/src/gnatcheck-compiler.adb +++ b/lkql_checker/src/gnatcheck-compiler.adb @@ -1781,9 +1781,9 @@ package body Gnatcheck.Compiler is Args (Num_Args) := new String'("--target=codepeer"); end if; - if Process_Num > 1 then + if Arg.Jobs.Get > 1 then Num_Args := @ + 1; - Args (Num_Args) := new String'("-j" & Image (Process_Num)); + Args (Num_Args) := new String'("-j" & Image (Arg.Jobs.Get)); end if; if Prj /= "" then diff --git a/lkql_checker/src/gnatcheck-options.adb b/lkql_checker/src/gnatcheck-options.adb index 8988f6e1d..7b3fc9eab 100644 --- a/lkql_checker/src/gnatcheck-options.adb +++ b/lkql_checker/src/gnatcheck-options.adb @@ -1,5 +1,7 @@ with Gnatcheck.Output; use Gnatcheck.Output; +with System.Multiprocessors; + package body Gnatcheck.Options is procedure Warning (Self : in out Gnatcheck_Error_Handler; Msg : String) is begin @@ -11,4 +13,18 @@ package body Gnatcheck.Options is Error (Msg); end Error; + ------------------ + -- Jobs_Convert -- + ------------------ + + function Jobs_Convert (Arg : String) return Natural is + Value : constant Natural := Natural'Value (Arg); + begin + if Value = 0 then + return Natural (System.Multiprocessors.Number_Of_CPUs); + else + return Value; + end if; + end Jobs_Convert; + end Gnatcheck.Options; diff --git a/lkql_checker/src/gnatcheck-options.ads b/lkql_checker/src/gnatcheck-options.ads index bdc62e472..56e3e3a38 100644 --- a/lkql_checker/src/gnatcheck-options.ads +++ b/lkql_checker/src/gnatcheck-options.ads @@ -122,14 +122,6 @@ package Gnatcheck.Options is Files_Switch_Used : Boolean := False; -- True if the files= switch was used - Process_Num : Natural := 1; - -- The maximal number of cores used - -- -jN - - J_Specified : Boolean := False; - -- True if the -jN option was given. This is used to distinguish -j0 on a - -- uniprocessor from no -j switch. - ---------------------------------------- -- Flags computed from other settings -- ---------------------------------------- @@ -248,6 +240,8 @@ package Gnatcheck.Options is procedure Warning (Self : in out Gnatcheck_Error_Handler; Msg : String); procedure Error (Self : in out Gnatcheck_Error_Handler; Msg : String); + function Jobs_Convert (Arg : String) return Natural; + package Arg is Parser : Argument_Parser := Create_Argument_Parser (Help => "GNATcheck help", @@ -432,6 +426,15 @@ package Gnatcheck.Options is Default_Val => Null_Unbounded_String, Help => "do not process sources listed in filename"); + package Jobs is new Parse_Option + (Parser => Parser, + Short => "-j", + Name => "Jobs", + Arg_Type => Natural, + Default_Val => 1, + Convert => Jobs_Convert, + Help => "the maximal number of processes"); + function Quiet_Mode return Boolean is (Quiet.Get or else Brief.Get); function Short_Report return Boolean is (Brief.Get or else Short.Get); diff --git a/lkql_checker/src/gnatcheck-projects.adb b/lkql_checker/src/gnatcheck-projects.adb index 0d2539eee..ea30096e3 100644 --- a/lkql_checker/src/gnatcheck-projects.adb +++ b/lkql_checker/src/gnatcheck-projects.adb @@ -58,8 +58,6 @@ with GNATCOLL.Traces; with Rule_Commands; use Rule_Commands; -with System.Multiprocessors; - package body Gnatcheck.Projects is subtype Unbounded_String is Ada.Strings.Unbounded.Unbounded_String; @@ -1118,7 +1116,6 @@ package body Gnatcheck.Projects is "m? files= a " & "vP! " & -- project-specific options "-kp-version= " & - "j! " & "o= " & "ox= " & "l log " & @@ -1184,27 +1181,6 @@ package body Gnatcheck.Projects is end if; end if; - when 'j' => - if Full_Switch (Parser => Parser) = "j" - and then not First_Pass - then - begin - J_Specified := True; - Process_Num := - Natural'Value (Parameter (Parser => Parser)); - - if Process_Num = 0 then - Process_Num := - Positive (System.Multiprocessors.Number_Of_CPUs); - end if; - exception - when Constraint_Error => - Error ("Wrong Parameter of '-j' option: " & - Parameter (Parser => Parser)); - raise Parameter_Error; - end; - end if; - when 'l' => if not First_Pass then if Full_Switch (Parser => Parser) = "l" then diff --git a/lkql_checker/src/gnatcheck_main.adb b/lkql_checker/src/gnatcheck_main.adb index 56894b2c7..e5e1e608d 100644 --- a/lkql_checker/src/gnatcheck_main.adb +++ b/lkql_checker/src/gnatcheck_main.adb @@ -158,6 +158,7 @@ procedure Gnatcheck_Main is File : Ada.Text_IO.File_Type; Status : Boolean; Total_Jobs : Natural; + Process_Num : Natural := Arg.Jobs.Get; begin -- Compute number of files