Skip to content

Commit

Permalink
Add Analyze and Safe build targets for Pico
Browse files Browse the repository at this point in the history
The Analyze target is meant to be run with GNAT SAS on a CI server,
since it forces deep mode analysis. The Safe target is meant to provide
a "safe image" compile that has runtime checking and optimization turned
off. This can work around compile bugs or runtime check bugs in a last
resort image.
  • Loading branch information
dinkelk committed Aug 15, 2024
1 parent 4926b2f commit 92c8ab9
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
2 changes: 1 addition & 1 deletion redo/environments/pico.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from util import target
from os import environ, path

target.set_target("Pico")
target.set_target_if_not_set("Pico")
try:
adamant_dir = environ['ADAMANT_DIR']
except KeyError:
Expand Down
40 changes: 40 additions & 0 deletions redo/targets/gpr/pico_analyze.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
with "pico_bsp.gpr";

project pico_analyze extends all "a_bareboard_debug.gpr" is

-----------------------------------------------
-- These lines of code must be included at the
-- top of every Adamant based .gpr file. They
-- are used to connect the Adamant build system
-- to GPRBuild.
-----------------------------------------------
for Source_Dirs use a_adamant.SOURCE_DIRS;
for Object_Dir use a_adamant.OBJECT_DIR;
for Exec_Dir use a_adamant.EXEC_DIR;

-- Specify cross compiler ARM target and Ravenscar runtime:
for Target use "arm-eabi";
for Runtime ("Ada") use "embedded-rpi-pico";
-- C++ not supported for arm-eabi currently.
for Languages use ("Ada", "C", "ASM_CPP");

-- Common binder switches:
package Binder is
for Switches ("Ada") use a_bareboard_base.Binder'Switches ("Ada") &
-- Store tracebacks in exception occurrences
-- https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gnat_ugn_unw/Switches-for-gnatbind.html
("-E");
end Binder;

package Linker is
for Switches ("Ada") use a_bareboard_base.Linker'Switches ("Ada");
end Linker;

-- Force analysis into "deep" mode
package Analyzer is
for Switches ("analyze") use a_bareboard_debug.Analyzer'Switches ("analyze") &
("--mode=deep");
for Additional_Patterns use a_bareboard_debug.Analyzer'Additional_Patterns;
end Analyzer;

end pico_analyze;
33 changes: 33 additions & 0 deletions redo/targets/gpr/pico_safe.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
with "pico_bsp.gpr";

project pico_development extends all "a_bareboard_safe.gpr" is

-----------------------------------------------
-- These lines of code must be included at the
-- top of every Adamant based .gpr file. They
-- are used to connect the Adamant build system
-- to GPRBuild.
-----------------------------------------------
for Source_Dirs use a_adamant.SOURCE_DIRS;
for Object_Dir use a_adamant.OBJECT_DIR;
for Exec_Dir use a_adamant.EXEC_DIR;

-- Specify cross compiler ARM target and Ravenscar runtime:
for Target use "arm-eabi";
for Runtime ("Ada") use "embedded-rpi-pico";
-- C++ not supported for arm-eabi currently.
for Languages use ("Ada", "C", "ASM_CPP");

-- Common binder switches:
package Binder is
for Switches ("Ada") use a_bareboard_base.Binder'Switches ("Ada") &
-- Store tracebacks in exception occurrences
-- https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gnat_ugn_unw/Switches-for-gnatbind.html
("-E");
end Binder;

package Linker is
for Switches ("Ada") use a_bareboard_base.Linker'Switches ("Ada");
end Linker;

end pico_development;
39 changes: 39 additions & 0 deletions redo/targets/pico.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,42 @@ def gpr_project_file(self):
os.environ["EXAMPLE_DIR"],
"redo" + os.sep + "targets" + os.sep + "gpr" + os.sep + "pico_debug.gpr",
)


class Pico_Safe(Pico_Base):
def description(self):
return """This target compiles for the Raspberry Pi Pico microprocessor. This is the
last resort image compilation. It has all runtime checks and assertions
disabled. It has optimization disabled. This is meant to create a different
binary than the Pico_Production target in order to possibly circumvent any compiler
bugs or runtime check bugs."""

def gpr_project_file(self):
return os.path.join(
os.environ["EXAMPLE_DIR"],
"redo"
+ os.sep
+ "targets"
+ os.sep
+ "gpr"
+ os.sep
+ "pico_safe.gpr",
)


class Pico_Analyze(Pico_Base):
"""Analyze target which runs GNAT SAS in deep mode."""
def description(self):
return ("Same as Pico_Debug except it adds deep mode switch for GNAT SAS.")

def gpr_project_file(self):
return os.path.join(
os.environ["EXAMPLE_DIR"],
"redo"
+ os.sep
+ "targets"
+ os.sep
+ "gpr"
+ os.sep
+ "pico_analyze.gpr",
)

0 comments on commit 92c8ab9

Please sign in to comment.