Skip to content

Commit

Permalink
Merge branch 'topic/ada2022' into 'master'
Browse files Browse the repository at this point in the history
Use Ada 2022 and Alire

See merge request eng/ide/markdown!16
  • Loading branch information
godunko committed May 12, 2023
2 parents 0fd9063 + 002b07e commit b9fcbb1
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 29 deletions.
8 changes: 7 additions & 1 deletion alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ maintainers = ["Max Reznik <[email protected]>"]
maintainers-logins = ["reznikmm"]
licenses = "Apache-2.0"

configuration.disabled = true
project-files = ["gnat/markdown.gpr"]

[configuration]
generate_ada = false
generate_c = false

[build-switches]
"*".ada_version = "Ada2022"

[[depends-on]]
vss = "^22.0.0"
[[pins]]
Expand Down
118 changes: 118 additions & 0 deletions config/markdown_config.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
--
-- Copyright (C) 2020-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--

-- This file is stub to build Markdown outside of the Alire environment. Alire
-- will overwrite it during builds.
--
-- Set of switches for all build modes are the same with Alire. Project
-- specific switches should be added in Markdown project file itself.

abstract project Markdown_Config is
Crate_Version := "wavefront";
Crate_Name := "markdown";

Alire_Host_OS := "linux";

Alire_Host_Arch := "x86_64";

Alire_Host_Distro := "ubuntu";
External_Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " ");
Development_Ada_Compiler_Switches :=
(
"-Og" -- Optimize for debug
,"-ffunction-sections" -- Separate ELF section for each function
,"-fdata-sections" -- Separate ELF section for each variable
,"-g" -- Generate debug info
,"-gnatwa" -- Enable all warnings
,"-gnatw.X" -- Disable warnings for No_Exception_Propagation
,"-gnatVa" -- All validity checks
,"-gnaty3" -- Specify indentation level of 3
,"-gnatya" -- Check attribute casing
,"-gnatyA" -- Use of array index numbers in array attributes
,"-gnatyB" -- Check Boolean operators
,"-gnatyb" -- Blanks not allowed at statement end
,"-gnatyc" -- Check comments
,"-gnaty-d" -- Disable check no DOS line terminators present
,"-gnatye" -- Check end/exit labels
,"-gnatyf" -- No form feeds or vertical tabs
,"-gnatyh" -- No horizontal tabs
,"-gnatyi" -- Check if-then layout
,"-gnatyI" -- check mode IN keywords
,"-gnatyk" -- Check keyword casing
,"-gnatyl" -- Check layout
,"-gnatym" -- Check maximum line length
,"-gnatyn" -- Check casing of entities in Standard
,"-gnatyO" -- Check that overriding subprograms are explicitly marked as such
,"-gnatyp" -- Check pragma casing
,"-gnatyr" -- Check identifier references casing
,"-gnatyS" -- Check no statements after THEN/ELSE
,"-gnatyt" -- Check token spacing
,"-gnatyu" -- Check unnecessary blank lines
,"-gnatyx" -- Check extra parentheses
,"-gnat2022" -- Ada 2022 Mode
);
Validation_Ada_Compiler_Switches :=
(
"-O3" -- Optimize for performance
,"-gnatn" -- Enable inlining
,"-ffunction-sections" -- Separate ELF section for each function
,"-fdata-sections" -- Separate ELF section for each variable
,"-g" -- Generate debug info
,"-gnato" -- Enable numeric overflow checking
,"-gnatwa" -- Enable all warnings
,"-gnatw.X" -- Disable warnings for No_Exception_Propagation
,"-gnatVa" -- All validity checks
,"-gnatwe" -- Warnings as errors
,"-gnata" -- Enable assertions and contracts
,"-gnaty3" -- Specify indentation level of 3
,"-gnatya" -- Check attribute casing
,"-gnatyA" -- Use of array index numbers in array attributes
,"-gnatyB" -- Check Boolean operators
,"-gnatyb" -- Blanks not allowed at statement end
,"-gnatyc" -- Check comments
,"-gnaty-d" -- Disable check no DOS line terminators present
,"-gnatye" -- Check end/exit labels
,"-gnatyf" -- No form feeds or vertical tabs
,"-gnatyh" -- No horizontal tabs
,"-gnatyi" -- Check if-then layout
,"-gnatyI" -- check mode IN keywords
,"-gnatyk" -- Check keyword casing
,"-gnatyl" -- Check layout
,"-gnatym" -- Check maximum line length
,"-gnatyn" -- Check casing of entities in Standard
,"-gnatyO" -- Check that overriding subprograms are explicitly marked as such
,"-gnatyp" -- Check pragma casing
,"-gnatyr" -- Check identifier references casing
,"-gnatyS" -- Check no statements after THEN/ELSE
,"-gnatyt" -- Check token spacing
,"-gnatyu" -- Check unnecessary blank lines
,"-gnatyx" -- Check extra parentheses
,"-gnat2022" -- Ada 2022 Mode
);
Release_Ada_Compiler_Switches :=
(
"-O3" -- Optimize for performance
,"-gnatn" -- Enable inlining
,"-ffunction-sections" -- Separate ELF section for each function
,"-fdata-sections" -- Separate ELF section for each variable
,"-gnat2022" -- Ada 2022 Mode
);

type Build_Profile_Kind is ("release", "validation", "development");
Build_Profile : Build_Profile_Kind :=
external ("MARKDOWN_BUILD_PROFILE", external ("BUILD_PROFILE", "development"));

Ada_Compiler_Switches := ();
case Build_Profile is
when "release" =>
Ada_Compiler_Switches := External_Ada_Compiler_Switches & Release_Ada_Compiler_Switches;
when "validation" =>
Ada_Compiler_Switches := External_Ada_Compiler_Switches & Validation_Ada_Compiler_Switches;
when "development" =>
Ada_Compiler_Switches := External_Ada_Compiler_Switches & Development_Ada_Compiler_Switches;
end case;

end Markdown_Config;
38 changes: 16 additions & 22 deletions gnat/markdown.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

with "vss_text";
with "vss_regexp";
with "../config/markdown_config.gpr";

project Markdown is

Expand All @@ -29,60 +30,53 @@ project Markdown is

for Library_Kind use Library_Type;

Ada_Switches := ();
Ada_Coverage_Switches := ();
Markdown_Ada_Compiler_Switches := ();
Coverage_Ada_Compiler_Switches := ();
Linker_Options := ();

case Build_Mode is
when "prod" =>
Ada_Switches := (
-- Compile with optimizations
"-O2",

Markdown_Ada_Compiler_Switches := (
-- Generate debug information: this is useful to get meaningful
-- tracebacks.
"-g"
);

when "dev" =>
Ada_Switches := (
-- Compile with no optimization and with debug information to ease
-- investigation in debuggers.
"-Og", "-g",

Markdown_Ada_Compiler_Switches := (
-- Enable warnings and stylechecks.
"-gnatwa", -- turn on all info/warnings
"-gnatygoO",
"-gnatygo",
-- g check standard GNAT style rules
-- o check subprogram bodies in alphabetical order
-- O check overriding indicators

-- Enable assertions and all validity checking options
"-gnata", "-gnatVa",
-- Enable assertions
"-gnata",

-- Enable stack overflow checks
"-fstack-check"
);

when "coverage" =>
Ada_Switches := (
-- Compile with no optimization and with debug information to ease
-- investigation in debuggers.
"-Og", "-g");
Markdown_Ada_Compiler_Switches := ();

Ada_Coverage_Switches := (
Coverage_Ada_Compiler_Switches := (
-- Enable coverage code instrumentation.
"--coverage");

Linker_Options := ("--coverage");
end case;

Ada_Compiler_Switches :=
Markdown_Config.Ada_Compiler_Switches
& Markdown_Ada_Compiler_Switches
& Coverage_Ada_Compiler_Switches;

-- All packages below are expected to be used when there is no subproject
-- specific switches are necessary. Please keep this packages as simple as
-- possible and never hardcode any switches to simplify future support.

package Compiler is
for Default_Switches ("Ada") use Ada_Switches & Ada_Coverage_Switches;
for Default_Switches ("Ada") use Ada_Compiler_Switches;
end Compiler;

package Linker is
Expand Down
2 changes: 1 addition & 1 deletion gnat/tests/commonmark_tests.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project CommonMark_Tests is
for Main use ("commonmark_tests.adb", "gnatdoc_tests.adb");

package Compiler is
for Default_Switches ("Ada") use Markdown.Ada_Switches & ("-gnatW8");
for Default_Switches ("Ada") use Markdown.Ada_Compiler_Switches & ("-gnatW8");
end Compiler;

package Binder is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ package body Markdown.Implementation.Auto_Links is
end if;

Vector.Append
((Kind => Markdown.Annotations.Link,
(Markdown.Annotations.Annotation'
(Kind => Markdown.Annotations.Link,
From => 1,
To => Plain.Character_Length,
Destination => URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ package body Markdown.Implementation.Code_Spans is
Plain := Text.Slice (Start, Stop);

Vector.Append
((Kind => Markdown.Annotations.Code_Span,
(Markdown.Annotations.Annotation'
(Kind => Markdown.Annotations.Code_Span,
From => 1,
To => Plain.Character_Length));

Expand Down
3 changes: 2 additions & 1 deletion source/parser/implementation/markdown-implementation.ads
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ package Markdown.Implementation is

type Abstract_Block is abstract tagged limited record
Counter : System.Atomic_Counters.Atomic_Counter;
end record;
end record
with No_Task_Parts;

function Assigned (Value : access Abstract_Block'Class) return Boolean is
(Value /= null);
Expand Down
2 changes: 1 addition & 1 deletion source/parser/markdown-annotations.ads
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package Markdown.Annotations is
(Positive, HTML_Attribute);
-- A vector of HTML attributes

type Annotation (Kind : Annotation_Kind := Link) is record
type Annotation (Kind : Annotation_Kind := Annotation_Kind'First) is record
From : VSS.Strings.Character_Index := 1;
To : VSS.Strings.Character_Count := 0;
-- Corresponding segment in the plain text
Expand Down
2 changes: 1 addition & 1 deletion testsuite/commonmark/prints.adb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package body Prints is

Tag : constant array
(Markdown.Annotations.Emphasis .. Markdown.Annotations.Strong)
of VSS.Strings.Virtual_String := ("em", "strong");
of VSS.Strings.Virtual_String := ["em", "strong"];

procedure Print_Annotated_Text
(Writer : in out HTML_Writers.Writer;
Expand Down

0 comments on commit b9fcbb1

Please sign in to comment.