diff --git a/alire.toml b/alire.toml index 47412ba..51dbd69 100644 --- a/alire.toml +++ b/alire.toml @@ -8,9 +8,15 @@ maintainers = ["Max Reznik "] 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]] diff --git a/config/markdown_config.gpr b/config/markdown_config.gpr new file mode 100644 index 0000000..3a70ea4 --- /dev/null +++ b/config/markdown_config.gpr @@ -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; diff --git a/gnat/markdown.gpr b/gnat/markdown.gpr index 3d7dccc..45921dc 100644 --- a/gnat/markdown.gpr +++ b/gnat/markdown.gpr @@ -6,6 +6,7 @@ with "vss_text"; with "vss_regexp"; +with "../config/markdown_config.gpr"; project Markdown is @@ -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 diff --git a/gnat/tests/commonmark_tests.gpr b/gnat/tests/commonmark_tests.gpr index 868fe12..7b7c2f0 100644 --- a/gnat/tests/commonmark_tests.gpr +++ b/gnat/tests/commonmark_tests.gpr @@ -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 diff --git a/source/parser/implementation/markdown-implementation-auto_links.adb b/source/parser/implementation/markdown-implementation-auto_links.adb index f6957de..1f2b69f 100644 --- a/source/parser/implementation/markdown-implementation-auto_links.adb +++ b/source/parser/implementation/markdown-implementation-auto_links.adb @@ -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, diff --git a/source/parser/implementation/markdown-implementation-code_spans.adb b/source/parser/implementation/markdown-implementation-code_spans.adb index 8ea1804..a3e193c 100644 --- a/source/parser/implementation/markdown-implementation-code_spans.adb +++ b/source/parser/implementation/markdown-implementation-code_spans.adb @@ -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)); diff --git a/source/parser/implementation/markdown-implementation.ads b/source/parser/implementation/markdown-implementation.ads index 83a958b..3a89fa8 100644 --- a/source/parser/implementation/markdown-implementation.ads +++ b/source/parser/implementation/markdown-implementation.ads @@ -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); diff --git a/source/parser/markdown-annotations.ads b/source/parser/markdown-annotations.ads index 8f4402c..49ca541 100644 --- a/source/parser/markdown-annotations.ads +++ b/source/parser/markdown-annotations.ads @@ -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 diff --git a/testsuite/commonmark/prints.adb b/testsuite/commonmark/prints.adb index 1a9f2e7..70a9238 100644 --- a/testsuite/commonmark/prints.adb +++ b/testsuite/commonmark/prints.adb @@ -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;