Current state of SDLADA? Would like to get Rosetta Code Task Archimedean spiral working on MacOS arm64

Here’s a snippet of the current error log:

archimedean_spiral.adb:31:18: error: ambiguous call to "Draw"
archimedean_spiral.adb:31:18: error: possible interpretation at sdl-video-renderers.ads:104
archimedean_spiral.adb:31:18: error: possible interpretation at sdl-video-renderers.ads:169
archimedean_spiral.adb:58:80: (style) this line is too long [-gnatyM]
archimedean_spiral.adb:59:80: (style) this line is too long [-gnatyM]
archimedean_spiral.adb:63:12: error: ambiguous call to "Fill"
archimedean_spiral.adb:63:12: error: possible interpretation at sdl-video-renderers.ads:112
archimedean_spiral.adb:63:12: error: possible interpretation at sdl-video-renderers.ads:177

Thanks,
RBE

It does it here: if it finds brew on the path, then it’s HB; otherwise, if it finds port on the path, then it’s MP; otherwise, no distribution found. (HP, MP are obviously ‘package managers’, but fitted better into Alire as ‘distributions’).

Yeah, Ada_Switches is mine, it’s not something alr creates.

How are you using Draw and Fill??

You should check this: ada-lang-io/docs/learn/how-tos/starting_an_sdl2_project.mdx at 7e5b2414aa0685f15f075a044c8209d9bd41e857 · Lucretia/ada-lang-io · GitHub

Someone else here followed it.

Looking at this link now. Most of what I’m trying to do is to automate the specified changes rather than to manually make the changes. I follow (in general) what’s going on now.

RBE

Made slight progress. This is really frustrating. It’s almost like doing the Piñata thing but with a twist that the Piñata keeps randomly moving.

I think I’ll go on to something else until this matures a bit more.

RBE

I really don’t know what the problem is and you could be waiting a long time before the -gnat2022 switch becomes the default.

Here’s what I did:

$ alr init --bin test
Enter a short description of the crate: (default: '')
> 
Using default: ''
Select a software license for the crate?
  1. MIT OR Apache-2.0 WITH LLVM-exception
  2. MIT
  3. Apache-2.0 WITH LLVM-exception
  4. Apache-2.0
  5. BSD-3-Clause
  6. LGPL-3.0-or-later
  7. GPL-3.0-or-later WITH GCC-exception-3.1
  8. GPL-3.0-or-later
  9. Other...
Enter your choice index (first is default): 
> 
Enter a comma (',') separated list of tags to help people find your crate: (default: '')
> 
Using default: ''
Enter an optional Website URL for the crate: (default: '')
> 
Using default: ''
✓ test initialized successfully.

$ cd test/

$ alr with sdlada --use=https://github.com/ada-game-framework/sdlada.git
Cloning into '/tmp/test/alire/tmp/alr-mhvu.tmp'...
remote: Enumerating objects: 1279, done.
remote: Counting objects: 100% (1279/1279), done.
remote: Compressing objects: 100% (643/643), done.
remote: Total 1279 (delta 966), reused 785 (delta 583), pack-reused 0 (from 0)
Receiving objects: 100% (1279/1279), 471.31 KiB | 11.50 MiB/s, done.
Resolving deltas: 100% (966/966), done.
ⓘ Pulling sdlada branch ...
Already up to date.
warn: Spent 0.09 seconds exploring complete solutions                                                       
warn: Exploring incomplete solutions to dependencies, this may take some time...
warn: The following external dependencies are unavailable within Alire:
warn:    libsdl2^2.0.0
warn: They should be made available in the environment by the user.
warn: Generating possibly incomplete configuration because of missing dependencies
◶ Syncing build dir... warn: Generating possibly incomplete environment because of missing dependencies
Requested changes:                                                     

   ✓ sdlada ^2.5.124 (add)
warn: Spent 0.00 seconds exploring complete solutions
warn: Exploring incomplete solutions to dependencies, this may take some time...
                            
Changes to dependency solution:

   New solution is incomplete.
   +📦      make    4.4.1   (new,indirect,executable in path)
   +📌      sdlada  2.5.124 (new,path=alire/cache/pins/sdlada,url=https://github.com/ada-game-framework/sdlada.git)
   Missing:
   +❗      libsdl2 ^2.0.0  (new,indirect,missing)

Do you want to proceed?
[Y] Yes  [N] No  (default is No) y
warn: The following external dependencies are unavailable within Alire:
warn:    libsdl2^2.0.0
warn: They should be made available in the environment by the user.

$ alr build
warn: Generating possibly incomplete configuration because of missing dependencies
◷ Syncing build dir... warn: Generating possibly incomplete environment because of missing dependencies
ⓘ Running pre-build actions for sdlada=2.5.124...                      
make: Entering directory '/tmp/test/alire/cache/pins/sdlada/build/gnat'
mkdir -p gen/src/
gprbuild -p -XSDL_MODE=debug -XSDL_PLATFORM=linux \
        -Ptools.gpr
Setup
   [mkdir]        object directory for project Tools
Compile
   [Ada]          gen_keyboard.adb
   [Ada]          scancodes.ads
   [Ada]          utils.adb
Bind
   [gprbind]      gen_keyboard.bexch
   [Ada]          gen_keyboard.ali
Link
   [link]         gen_keyboard.adb
./gen/debug/tools/gen_keyboard > gen/src/sdl-events-keyboards.ads
make: Leaving directory '/tmp/test/alire/cache/pins/sdlada/build/gnat'
ⓘ Building test=0.1.0-dev/test.gpr...
Setup
   [mkdir]        object directory for project SDLAda
   [mkdir]        object directory for project Test
   [mkdir]        exec directory for project Test
Compile
   [Ada]          test.adb
   [C]            version.c
   [Ada]          sdl_linker.ads
   [Ada]          sdl-video.adb
   [Ada]          sdl-video-windows.adb
   [Ada]          sdl-video-windows-manager.adb
   [Ada]          sdl-video-windows-makers.adb
   [Ada]          sdl-video-textures.adb
   [Ada]          sdl-video-textures-makers.adb
   [Ada]          sdl-video-surfaces.adb
   [Ada]          sdl-video-surfaces-makers.adb
   [Ada]          sdl-video-renderers.adb
   [Ada]          sdl-video-renderers-makers.adb
   [Ada]          sdl-video-rectangles.adb
   [Ada]          sdl-video-pixels.ads
   [Ada]          sdl-video-pixel_formats.adb
   [Ada]          sdl-video-palettes.adb
   [Ada]          sdl-video-gl.adb
   [Ada]          sdl-video-displays.adb
   [Ada]          sdl-rwops.adb
   [Ada]          sdl-rwops-streams.adb
   [Ada]          sdl-inputs.ads
   [Ada]          sdl-inputs-mice.adb
   [Ada]          sdl-inputs-mice-cursors.adb
   [Ada]          sdl-inputs-keyboards.adb
   [Ada]          sdl-inputs-joysticks.adb
   [Ada]          sdl-inputs-joysticks-makers.adb
   [Ada]          sdl-inputs-joysticks-game_controllers.adb
   [Ada]          sdl-inputs-joysticks-game_controllers-makers.adb
   [Ada]          sdl-events.ads
   [Ada]          sdl-events-windows.ads
   [Ada]          sdl-events-touches.ads
   [Ada]          sdl-events-mice.ads
   [Ada]          sdl-events-keyboards.adb
sdl-video-gl.adb:669:07: warning: "Result" is not modified, could be declared constant [-gnatwk]
   [Ada]          sdl-events-joysticks.adb
   [Ada]          sdl-events-joysticks-game_controllers.adb
   [Ada]          sdl-events-files.ads
   [Ada]          sdl-events-events.adb
   [Ada]          sdl-events-controllers.ads
   [Ada]          sdl-audio.adb
   [Ada]          sdl-audio-sample_formats.ads
   [Ada]          sdl-audio-devices.adb
   [Ada]          sdl.adb
   [Ada]          sdl-versions.adb
   [Ada]          sdl-timers.adb
   [Ada]          sdl-power.adb
   [Ada]          sdl-platform.adb
   [Ada]          sdl-log.adb
   [Ada]          sdl-libraries.adb
   [Ada]          sdl-hints.adb
   [Ada]          sdl-filesystems.adb
   [Ada]          sdl-error.adb
   [Ada]          sdl-cpus.adb
   [Ada]          sdl-clipboard.adb
   [Ada]          sdl-c_pointers.ads
Build Libraries
   [gprlib]       sdlada.lexch
   [archive]      libsdlada.a
   [index]        libsdlada.a
Bind
   [gprbind]      test.bexch
   [Ada]          test.ali
Link
   [link]         test.adb
✓ Build finished successfully in 4.89 seconds.

Then to add in SDL:

diff --git a/src/test.adb b/src/test.adb
index e03b30c..1c365b5 100644
--- a/src/test.adb
+++ b/src/test.adb
@@ -1,3 +1,5 @@
+with SDL;
+
 procedure Test is
 begin
    null;
diff --git a/test.gpr b/test.gpr
index 699cbb0..0b315de 100644
--- a/test.gpr
+++ b/test.gpr
@@ -8,7 +8,8 @@ project Test is
    for Main use ("test.adb");
 
    package Compiler is
-      for Default_Switches ("Ada") use Test_Config.Ada_Compiler_Switches;
+      for Default_Switches ("Ada") use Test_Config.Ada_Compiler_Switches &
+        ("-gnat2022");
    end Compiler;
 
    package Binder is

Then compiled:

$ alr build
warn: Generating possibly incomplete configuration because of missing dependencies
◷ Syncing build dir... warn: Generating possibly incomplete environment because of missing dependencies
ⓘ Running pre-build actions for sdlada=2.5.124...                      
make: Entering directory '/tmp/test/alire/cache/pins/sdlada/build/gnat'
mkdir -p gen/src/
make: Leaving directory '/tmp/test/alire/cache/pins/sdlada/build/gnat'
ⓘ Building test=0.1.0-dev/test.gpr...
Compile
   [Ada]          test.adb
test.adb:1:06: warning: unit "SDL" is not referenced [-gnatwu]
Bind
   [gprbind]      test.bexch
   [Ada]          test.ali
Link
   [link]         test.adb
✓ Build finished successfully in 0.43 seconds.
1 Like

I don’t think that my inability to follow the instructions provided is a fault of insufficient maturity of the Ada compiler. I’m also not the one that is not fully mature (I’m way over-ripe!). I really don’t think that the instructions are sufficiently clear in order to obtain a functional SDL-ADA infrastructure that will suffice for the Rosetta Code tasks that already are written in Ada and use SDL.

Please show me the steps that you would do to make any of the Rosetta Code tasks, that are written in Ada, that use SDL, on a Mac with arm, without modification of the Rosetta Code task code. If you needed to modify any of the SDL_ADA infrastructure code in order to do that, then update the documentation accordingly.

Thanks,
RBE

1 Like

Apologies if I offended anyone. I was (and still am) quite frustrated with this, so I’ll just let it go, it is not worth getting this frustrated and it is not worth insulting people who are vastly smarter than I.

RBE

Just try the 3 steps I showed. I don’t know anything about rosetta code and I don’t have a mac.

My version (very little different from @Lucretia ’s):

$ alr init --bin archimedean_spiral
         (accept all the defaults)
$ alr with sdlada --use=https://github.com/ada-game-framework/sdlada.git

Go into src/ and replace archimedean_spiral.adb with the one from Rosetta Code.

alr build -- -gnat2022

and end with the same errors @Ret_Build_Engineer noted above.

The fixes for the errors are:

(1) add with SDL.Video.Rectangles; to the context clauses

(2) replace

         Renderer.Draw
           (Point => (X => Width  / 2 + SDL.C.int (R * Cos (T, 2.0 * Pi)),
                      Y => Height / 2 - SDL.C.int (R * Sin (T, 2.0 * Pi))));

by

         Renderer.Draw
           (Point =>
              SDL.Video.Rectangles.Point'
                (X => Width / 2 + SDL.C.int (R * Cos (T, 2.0 * Pi)),
                 Y => Height / 2 - SDL.C.int (R * Sin (T, 2.0 * Pi))));

(3) replace

   Renderer.Fill (Rectangle => (0, 0, Width, Height));

by

   Renderer.Fill
     (Rectangle => SDL.Video.Rectangles.Rectangle'(0, 0, Width, Height));

The problem was that Renderer.Draw and Renderer.Fill both have overlays, with the different overlays distinguished by the type of the parameter; so we have to tell the compiler which one we mean by using qualified expressions (ARM 4.7).

2 Likes

Enable_Screen renames Enable_Video; -- Deprecated.
could be replaced with:
Enable_Screen : Init_Flags renames Enable_Video; -- Deprecated.
or else adding
Pragma Ada_2022;
to the top of the file.

Or as I point out above, put -gnat2022 flag in your gpr file, it’s a 2022 lib.

— as I said above. This could be in your alire.toml or in sdlada’s alire.toml (but I seem to remember that there were issues when some units were in Ada2022 and some not?).

If it has to be in a GPR, shouldn’t it be in sdlada’s?

The [build-switches] version above ends up in config/archimedean_spiral.gpr.

1 Like

It is in SDLAda’s gpr file, it’s used to compile the cached sdlada, but not when using the packages from SDLAda.

I intend to look into setting up a starter template project next year, but don’t know how to work that into alire, so will need advice from @AJ-Ianozi.

Hi Simon;

It works. Thanks for your help.

The only thing I need to do to satisfy myself regarding this specific problem is convert the process of the hand-editing of the Ada source as you have shown into a patch process so that the entire build process cvan be completely encapsulated in the bash script driver. I still am working out a self-inflicted bug with my patch creation and usage which I will resolve myself.

I will try (soon) to look at the other Rosetta Code tasks that were written in Ada using SDL and see if I can leverage what knowledge I have gained here to in order to have success locally reproducing them.

Thanks again,
RBE

Indeed, I did alr -v build and there it was – but not when compiling archimedean_spiral.adb.

In this case you don’t need to: I’ve updated the Rosetta Code page.

1 Like

Simon;

Thank you.

There is one VERY SMALL issue that might be of interest for those who are using MacPorts and Alire:

There is a benign failure when calling port (MacPort command) looking for make, which does not exist as a port, at the end of the “alr with” command:

Error: Port make not found

Is this due to a problem with my PATH environment variable? Why is it looking for make from MacPorts?

Anyway, the build process continues successfully to the end.

Thanks so much for your assistance/guidance.

RBE