From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:1b91:b0:742:32aa:5f1e with SMTP id dv17-20020a05620a1b9100b0074232aa5f1emr3210040qkb.0.1677701330964; Wed, 01 Mar 2023 12:08:50 -0800 (PST) X-Received: by 2002:a9d:187:0:b0:68b:d1d3:c40d with SMTP id e7-20020a9d0187000000b0068bd1d3c40dmr2601559ote.4.1677701330777; Wed, 01 Mar 2023 12:08:50 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 1 Mar 2023 12:08:50 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2871:8e00:2560:f7fe:4bfd:fe03; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 2a02:1210:2871:8e00:2560:f7fe:4bfd:fe03 References: <2bee0de5-2d5c-44a7-bdab-a1d266855c96n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <018c257d-44cd-49cd-aac8-8c2b2cf616c4n@googlegroups.com> Subject: Re: Build order with gprbuild From: Gautier write-only address Injection-Date: Wed, 01 Mar 2023 20:08:50 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 6413 Xref: reader01.eternal-september.org comp.lang.ada:64992 List-Id: Between normal Ada projects, everything works as you describe (and as expec= ted). However, in the special case where project B, instead of transforming Ada f= iles into .o files, transforms other kind of files into Ada files that are = with-ed by units of project A, things get off the road: project A doesn't s= ee out-of-date Ada files produced by project B. Here is a full example. Files are reproduced below (they are meant to land = into the same directory). Then you do the following commands: gprbuild -P fuzzy_gen.gpr gprbuild -P code_generation.gpr gnatstudio -P main.gpr First build launched from GNAT Studio does the following on my machine: Compile [Ada] main.adb [Fuzzy] x789.cfg Ada file "fuzzy_x789.adb" is up to date [Fuzzy] x456.cfg Ada file "fuzzy_x456.adb" is up to date [Fuzzy] x123.cfg Ada file "fuzzy_x123.adb" is up to date [Ada] fuzzy_x123.adb [Ada] fuzzy_x456.adb [Ada] fuzzy_x789.adb Bind [gprbind] main.bexch [Ada] main.ali Link [link] main.adb Second build has an expected output as well: Compile [Fuzzy] x789.cfg Ada file "fuzzy_x789.adb" is up to date [Fuzzy] x456.cfg Ada file "fuzzy_x456.adb" is up to date [Fuzzy] x123.cfg Ada file "fuzzy_x123.adb" is up to date gprbuild: "main.exe" up to date Now, say you modify x123.cfg and save it. Compile [Fuzzy] x789.cfg Ada file "fuzzy_x789.adb" is up to date [Fuzzy] x456.cfg Ada file "fuzzy_x456.adb" is up to date [Fuzzy] x123.cfg Converting "x123.cfg" into "fuzzy_x123.adb"... gprbuild: "main.exe" up to date That's *not* what I would like: gprbuild did not detect the out-of-date fil= e "fuzzy_x123.adb" in time. A second call to gprbuild compiles the changed "fuzzy_x123.adb" and all is = well, but it is one step too late. The files =3D=3D=3D=3D=3D=3D=3D=3D=3D 1) The code generator =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D fuzzy_gen.gpr: ------------- project Fuzzy_Gen is for Object_Dir use "obj"; for Exec_Dir use "gen"; for Create_Missing_Dirs use "True"; for Main use ("fuzzy_gen.adb"); end Fuzzy_Gen; fuzzy_gen.adb: ------------- with Ada.Calendar, Ada.Command_Line, Ada.Directories, Ada.Text_IO; procedure Fuzzy_Gen is use Ada.Command_Line, Ada.Directories, Ada.Text_IO; procedure Convert (arg : String) is cfg : constant String :=3D Simple_Name (arg); cfg_file_name : constant String :=3D "../" & cfg; ada_unit_name : constant String :=3D "fuzzy_" & cfg (cfg'First .. cfg'Last - 4); ada_file_name : constant String :=3D ada_unit_name & ".adb"; cfg_in, ada_out : File_Type; use type Ada.Calendar.Time; begin if Exists (ada_file_name) and then Modification_Time (ada_file_name) >=3D Modification_Time (cfg_file_name) then Put_Line ("Ada file """ & ada_file_name & """ is up to date"); return; end if; Put_Line ("Converting """ & cfg & """ into """ & ada_file_name & """..."); Open (cfg_in, In_File, cfg_file_name); Create (ada_out, Out_File, ada_file_name); Put_Line (ada_out, "function " & ada_unit_name & " return String is"); Put_Line (ada_out, "begin"); Put_Line (ada_out, " return """ & Get_Line (cfg_in) & """;"); Put_Line (ada_out, "end;"); Close (cfg_in); Close (ada_out); end Convert; begin if Argument_Count =3D 0 then Put_Line (Current_Error, "config file name missing"); else Convert (Argument (1)); end if; end Fuzzy_Gen; 2) The project that generates Ada files ("project B") =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D code_generation.gpr: ------------------- project Code_Generation is for Languages use ("Fuzzy"); for Source_Dirs use ("."); for Object_Dir use "gen"; for Objects_Linked ("Fuzzy") use "False"; package Naming is for Body_Suffix ("Fuzzy") use ".cfg"; end Naming; package Compiler is for Driver ("Fuzzy") use "fuzzy_gen"; end Compiler; end Code_Generation; x123.cfg: -------- 123 x456.cfg: -------- 456 x789.cfg: -------- 789 3) The main project (project A) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D main.gpr: -------- with "code_generation.gpr"; project Main is for Source_Dirs use (".", "gen"); for Object_Dir use "obj"; for Create_Missing_Dirs use "True"; for Main use ("main.adb"); end Main; main.adb: -------- with Ada.Text_IO; with Fuzzy_X123, Fuzzy_X456, Fuzzy_X789; procedure Main is begin Ada.Text_IO.Put ("Messages from elsewhere:" & " """ & Fuzzy_X123 & '"' & " """ & Fuzzy_X456 & '"' & " """ & Fuzzy_X789 & '"'); end;