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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c35edbbda4c7f58f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Conditional compilation in Ada? Date: Wed, 17 Nov 2004 09:36:41 +0100 Message-ID: <419B0D99.9030106@mailinator.com> References: <2vv6vfF2q17krU1@uni-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de mk3ExHOaglrvFu/4cik8SwU3yst05KsC8HeDX08ffjnHklEpE= User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en In-Reply-To: <2vv6vfF2q17krU1@uni-berlin.de> Xref: g2news1.google.com comp.lang.ada:6243 Date: 2004-11-17T09:36:41+01:00 List-Id: Nick Roberts wrote: > "Marius Amado Alves" wrote in message > news:mailman.103.1100630792.10401.comp.lang.ada@ada-france.org... > >>>Any hints? >> >>Gnatprep. > > > In a little more detail, declare the things that differ (types, associated > operations) in two separate packages, say Stuff_For_Playstation and > Stuff_For_XBox, then put something like this: > > Compile_Target := XBox > > into a text file called "targspec.txt" (say), and then something like this > in the appropriate places in your source files: > > with Stuff_For_$Compile_Target; > ... > package Target_Specific renames Stuff_For_$Compile_Target; > ... > Target_Specific.Reset_Joystick; -- or whatever > > and rename every so doctored source file myfile.ads to myfile.adsp (and > myfile.adb to myfile.adbp) and then run: > > gnatprep myfile.adsp myfile.ads targspec.txt -c -r > > for each such source file, and then compile as normal. Documentation for > gnatprep is in the GNAT User's Guide. > > Obviously, you change "Compile_Target := XBox" to "Compile_Target := > Playstation" to recompile for a different target. > > The idea is to minimise the number of times you use a $ macro or #if in your > source files, within reason, and put as much as possible into the different > specific packages. Things tend to be easier to debug this way. You may find > that you do not have to use gnatprep at all, but instead you could just have > a separate file "target_specific.ads" which contains the two lines: > > with Stuff_For_XBox; > package Target_Specific renames Stuff_For_XBox; > > which you simply change to: > > > with Stuff_For_Playstation; > package Target_Specific renames Stuff_For_Playstation; > > in order to recompile for a different target. What I do is to have a folder for every platform-specific code. It must conform to a predefined spec, as suggested. Then I have two rules in a Makefile. One issues the gnatmake -Iplatform1 and the other -Iplatform2.