From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,80155a886d197693 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!y17g2000yqn.googlegroups.com!not-for-mail From: Chrono Newsgroups: comp.lang.ada Subject: Re: Conditional Compilation in Ada Date: Mon, 29 Jun 2009 05:01:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: <942d7aa6-a93b-45a3-b250-9398e2754af7@y17g2000yqn.googlegroups.com> References: <5618a901-6b05-4a60-8362-7821261da50b@f19g2000yqo.googlegroups.com> <768c8117-d8af-4a04-b27e-2e74b69c1e8b@y17g2000yqn.googlegroups.com> NNTP-Posting-Host: 201.7.145.1 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246276922 8346 127.0.0.1 (29 Jun 2009 12:02:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 29 Jun 2009 12:02:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y17g2000yqn.googlegroups.com; posting-host=201.7.145.1; posting-account=n9Sa1woAAACZc_iwSjaEkj9Lnt-XVrSr User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6710 Date: 2009-06-29T05:01:35-07:00 List-Id: Yes, I mean a GPS scenario. In my case it is a bit difficult to put files in a different folder for each scenario, due to I need to lead with a some thousands of files project. I used to have a solution with included a prepost compilation, a script launched before the unit compilation which turned up some part of the code to a commented one, so in "real" compilation, that part would not be compilated. I have a feeling that GPS has some way to do this without external scripts, a more ellegant solution, maybe using some compilation directives. My last implementation included some like this: package body My_Package is procedure Calculate_Data (My_Variable : out Some_Type) is begin --# if TARGET MY_Variable =3D 1; --# end If TARGET --# if HOST MY_Variable =3D 2; --# end If HOST end Calculate_Data; end My_Package; so I just discover a way to set two environments, e.g., TARGET and HOST, and compile each one according to the GPS scenario chosen. On 29 jun, 08:42, sjw wrote: > On Jun 29, 12:10=A0pm, Pablo wrote: > > > Hi, does someone know how to make conditional compilation in Ada with > > Scenarios? Say, I need to hide from compilation a part of an Ada code > > in some Scenario mode. > > When you say 'scenario' do you mean a GPS scenario? If not, you will > have to tell us more... > > The normal way of dealing with this problem is to put the alternate > codes in different directories and adjust the compiler's source path > to pick up the appropriate file. > > package body Target is > =A0 =A0.. > =A0 =A0function Get_Position (At_Time : Time) return Position is separate= ; > =A0 =A0.. > > then (with GNAT) the separate body will be target-get_position.adb. If > your scenarios are Real and Simulated, make subdirectories Real/ and > Simulated/ and place an appropriate implementation in each. Your GPR > might then look like > > =A0 =A0type Environment is ("Real", "Simulated"); > =A0 =A0Env : Environment :=3D external ("ENVIRONMENT"); > =A0 =A0case Env is > =A0 =A0 =A0 when "Real" =3D> Env_Path =3D "Real"; > =A0 =A0 =A0 when "Simulated" =3D> Env_Path =3D "Simulated"; > =A0 =A0end case; > =A0 =A0for Source_Dirs use ..... & Env_Path; > > (I haven't tested this particular example ...)