From 424c3d9b15aa936cf510c39c491cea3b7e34435d Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 24 Mar 2023 12:51:08 +0100 Subject: [PATCH] Unicode documentation (#1332) * Document Alire policy on Unicode * Add control over -gnatW8 switch * Tweak documentation and tests * Document in AEP the -gnatW8 effects * Reformat long lines * Add comp.lang.ada references * Renamed source encoding switches * Use Compiler_Default for no switches * Update catalog doc to match new source encoding types * Fix wrong mix of Wide_String with UTF-16 * Bump dependencies --- alire.toml | 6 +- deps/clic | 2 +- deps/semantic_versioning | 2 +- deps/simple_logging | 2 +- doc/AEPs/aep-0004.md | 123 +++++++++++++ doc/catalog-format-spec.md | 3 + doc/unicode.md | 165 ++++++++++++++++++ src/alire/alire-properties-build_switches.adb | 17 ++ src/alire/alire-properties-build_switches.ads | 4 +- src/alire/alire-utils-switches.adb | 18 +- src/alire/alire-utils-switches.ads | 77 +++++--- .../build_profile/custom_switches/test.py | 4 +- 12 files changed, 382 insertions(+), 41 deletions(-) create mode 100644 doc/AEPs/aep-0004.md create mode 100644 doc/unicode.md diff --git a/alire.toml b/alire.toml index 8d381337..e5e37818 100644 --- a/alire.toml +++ b/alire.toml @@ -47,8 +47,8 @@ windows = { ALIRE_OS = "windows" } [[pins]] aaa = { url = "https://github.com/mosteo/aaa", commit = "906d9eaf4fb8efabfbc3d8cfb34d04ceec340e13" } ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" } -clic = { url = "https://github.com/alire-project/clic", commit = "102bc38c7e9469112145e12100449664b5c74764" } +clic = { url = "https://github.com/alire-project/clic", commit = "5b46b3c57fd0c6a62db1608c9f5573b1866e0dbe" } gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "92bb91130a9ec628b4c48b7ef9fe7f24d9dc25fa" } -semantic_versioning = { url = "https://github.com/alire-project/semantic_versioning", commit = "c2345fca8b685d6d3fc9334fac81140a0cdbea89" } -simple_logging = { url = "https://github.com/alire-project/simple_logging", commit = "2b62010b6d66c106c65eb9ae604aabcf64522fac" } +semantic_versioning = { url = "https://github.com/alire-project/semantic_versioning", commit = "2f23fc5f6b4855b836b599adf292fed9c0ed4144" } +simple_logging = { url = "https://github.com/alire-project/simple_logging", commit = "3505dc645f3eef6799a486aae223d37e88cfc4d5" } stopwatch = { url = "https://github.com/mosteo/stopwatch", commit = "f607a63b714f09bbf6126de9851cbc21cf8666c9" } diff --git a/deps/clic b/deps/clic index 102bc38c..5b46b3c5 160000 --- a/deps/clic +++ b/deps/clic @@ -1 +1 @@ -Subproject commit 102bc38c7e9469112145e12100449664b5c74764 +Subproject commit 5b46b3c57fd0c6a62db1608c9f5573b1866e0dbe diff --git a/deps/semantic_versioning b/deps/semantic_versioning index c2345fca..2f23fc5f 160000 --- a/deps/semantic_versioning +++ b/deps/semantic_versioning @@ -1 +1 @@ -Subproject commit c2345fca8b685d6d3fc9334fac81140a0cdbea89 +Subproject commit 2f23fc5f6b4855b836b599adf292fed9c0ed4144 diff --git a/deps/simple_logging b/deps/simple_logging index 2b62010b..3505dc64 160000 --- a/deps/simple_logging +++ b/deps/simple_logging @@ -1 +1 @@ -Subproject commit 2b62010b6d66c106c65eb9ae604aabcf64522fac +Subproject commit 3505dc645f3eef6799a486aae223d37e88cfc4d5 diff --git a/doc/AEPs/aep-0004.md b/doc/AEPs/aep-0004.md new file mode 100644 index 00000000..f204cbba --- /dev/null +++ b/doc/AEPs/aep-0004.md @@ -0,0 +1,123 @@ + AEP: 4 + Title: -gnatW8 impact on Alire + Author: Alejandro R. Mosteo + Status: Draft + Created: 21-feb-2023 + +Abstract +======== + +Herein is documented the impact of enabling `-gnatW8` by default in Alire, and +mitigating measures and circumstances. + +Details +======= + +GNAT, by default, uses Latin-1 as the default character set [1][3], as specified +by the Ada 83 standard. + +Later revisions opened the door to use UTF-16 and UTF-32. GNAT governs the +encodings to expect and accept through the `-gnatW` and `-gnati` switches [2]. + +When no switch is given, a source is considered Latin-1 unless it starts with a +UTF-8 BOM identifier, in which case the file is compiled as if `-gnatW8` were +supplied. + +Trouble arises because the same source can be compiled multiple times (e.g., +specifications or generic bodies) with different switches in effect. + +For example, a crate may want to use full Unicode (in conformance with the Ada +standard), and will set `-gnatW8`. A dependency, though, uses Latin-1 encoding +and no switch. The dependency will compile properly on its own, but when used +as a dependency it may cause errors as a Latin-1 file is compiled as UTF-8. This +will happen even if no `-gnatW8` is given if the root file uses a BOM and the +dependency file uses plain Latin-1. + +This means there is no universal solution, as GNAT may always cause conflicts +whenever there are files using different encodings, no matter if their +respective projects use the appropriate encoding switches, or the UTF-8 files +are properly BOM-marked. + +Trying to stay Unicode-agnostic would be a possibility, but crates can get +surreptitiously into the index that compile properly on their own, but later +cause conflicts when used in combination with other crates. + +The impact of adding `-gnatW8` to all new crates is mitigated in the case of +dependencies compiled as libraries that use Latin-1 encoding in non-generic +bodies and not supplying `-gnatW8` themselves. These dependencies will still be +built properly, and won't cause errors in clients of such a library. + +Proposal +======== + +The modern course of action seems to be to mandate UTF-8 encoding for all +sources in the Alire ecosystem, and enable `-gnatW8` in the default project +files created by Alire. At least this way, after a transition period, the +problem is in the past for good. This is also in conformance with recent Ada +standards. + +As mitigations, we can fix or notify all crates already in the index before the +launch of Alire 2.0. We can also check during index submission that sources are +either UTF-8-encoded or plain ASCII to avoid the introduction of new +potentially problematic crates. + +Impacted crates +=============== + +The following crates fail to compile when `-gnatW8` is unconditionally applied +(via `gprbuild -gnatW8`). Some failures are caused by dependencies and not by +the crate itself. Some others are expected to fail, as they use Latin-1 +encoding. Still others, however, are already using UTF-8 encoding, but relying +on assumptions of UTF-8 strings being literally interpreted as byte sequences +instead of Latin-1 strings, even when using the `String` type. + +Not all of them are problematic, as non-generic bodies won't "contaminate" a +client, and can be used as-is by `-gnatW8`-enabled crates. Several of them are +already maintained by Alire developers. + +FAIL:apdf=5.0.3 + pdf_out_demo.adb:70:54: illegal wide character +FAIL:awa=2.4.0 + asf-converters-numbers.adb:131:53: error: literal out of range of type Standard.Character +FAIL:awa_unit=2.4.0 + asf-converters-numbers.adb:131:53: error: literal out of range of type Standard.Character +FAIL:excel_writer=17.0.1 + excel_out_demo.adb:125:39: illegal wide character + csv2html.adb:19:13: illegal wide character +FAIL:mandelbrot_ascii=1.0.0 + mandelbrot_ascii.adb:105:05: literal out of range of type Standard.Character +FAIL:pico_examples=2.0.0 + main.adb:34:70: error: literal out of range of type Standard.Character +FAIL:progress_indicators=0.0.1 + progress_indicators-bars.adb:32:46: literal out of range of type Standard.Character +FAIL:semantic_versioning=2.1.0 + semantic_versioning-demo.adb:101:47: literal out of range of type Standard.Character +FAIL:septum=0.0.7 + progress_indicators-bars.adb:32:46: literal out of range of type Standard.Character +FAIL:serverfaces=1.5.0 + asf-converters-numbers.adb:131:53: error: literal out of range of type Standard.Character +FAIL:serverfaces_unit=1.5.0 + asf-converters-numbers.adb:131:53: error: literal out of range of type Standard.Character +FAIL:simple_logging=1.2.0 + simple_logging.adb:121:25: literal out of range of type Standard.Character + +References +========== + +[1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-2-1.html +[2] https://docs.adacore.com/live/wave/gnat_ugn/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#character-set-control +[3] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-3-5-2.html + +comp.lang.ada +============= +Discussions related to Unicode at comp.lang.ada and elsewhere: + +https://groups.google.com/g/comp.lang.ada/c/l0aflBePm_E/ +https://two-wrongs.com/unicode-strings-in-ada-2012 +https://groups.google.com/g/comp.lang.ada/c/QeKNbHFqPEg/ + + +Copyright +========= + +This document has been placed in the public domain. diff --git a/doc/catalog-format-spec.md b/doc/catalog-format-spec.md index 72a9abd1..62b8b4ae 100644 --- a/doc/catalog-format-spec.md +++ b/doc/catalog-format-spec.md @@ -640,6 +640,9 @@ static, i.e. they cannot depend on the context. - `Ada12` - `Ada2022` - `GNAT_Extensions` + - `Source_Encoding` + - `Compiler_Default` + - `UTF-8` For example, to enable all run-time checks in the release profile: ```toml diff --git a/doc/unicode.md b/doc/unicode.md new file mode 100644 index 00000000..e6da160d --- /dev/null +++ b/doc/unicode.md @@ -0,0 +1,165 @@ +# Unicode guidelines + +Unicode is the solution to work with character sets other than ASCII or, in the +case of Ada, beyond Latin-1, which was the character set chosen for the +`Character` type. There are a number of considerations for the use of Unicode +in Ada and in Alire crates, detailed in this section. + +## TL;DR + +Alire v2.0 and onwards expects sources to be UTF-8 (through the `-gnatW8` +switch). Input/Output must be done using specialized crates (e.g. `vss`, +`uxstrings`) or with `Wide_Wide_Text_IO` (for unencoded/UTF-32 strings) or with +`Streams_IO/GNAT.IO` (for UTF-8-encoded strings). Avoid `Text_IO` unless you +are sure of what you're doing (using Latin-1 strings). Some friction may happen +with older sources not using UTF-8. + +Read on for the gory details. +## Alire assumptions and configuration + +By default, any crate initialized via `alr init` will have the `-gnatW8` switch +in its build configuration, which presumes UTF-8 encoding of sources, and +tweaks some internals of the compiler accordingly. + +This means that source files **must** use UTF-8 encoding when not using plain +ASCII. + +Since GNAT compiles specifications and generic bodies in the context of the +client project, once internalization is enabled in some parts of a build, it +becomes necessary for all parts of the build to use the same `-gnatW8` setting. +Otherwise, a file containing non-ASCII literals could be interpreted +differently depending on the compilation context (as a standalone library or +from a client of such a library). + +Most old GNAT projects are likely not to have `-gnatW8` enabled (although an +UTF-8 file with BOM marker will have the same effect). For crates that do not +contain string literals outside of ASCII or engage on I/O of such strings, this +should not make any difference. For those for which internationalization +matters, however, there is no sensible way forward but to embrace Unicode, with +UTF-8 being the standard encoding nowadays for files and terminals. + +This means that a certain amount of breakage might happen for 'legacy' +libraries not yet adapted to `-gnatW8`. From the Alire project we are trying to +get in front of this problem with early detection of such libraries in the +Alire ecosystem, and universally using `-gnatW8` from version 2.0 on. + +## Recommendations + +You can use a library designed to shield you from Unicode details, such as +`vss` or `uxstrings`. + +Otherwise, these recommendations should keep you safe: + +1. Use `-gnatW8` to compile (this is Alire's default) and save your sources in UTF-8 encoding. +1. Use Wide_Wide_String to store any text that may exceed the ASCII character set. + 1. Alternatively, use `Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode` to get UTF-8 strings from Unicode literals. +1. Convert if necessary at the time of output to the desired encoding for display/storage. + 1. By default, Ada.Wide_Wide_Text_IO will use UTF-8 encoding if `-gnatW8` is in effect. + 1. Most modern plain text formats expect UTF-8 encoding. + 1. On Linux terminals this is the usual default. + 1. On Windows 10: + 1. You can enable UTF-8 once by running `chcp 65001` in your terminal. + 1. You can enable UTF-8 in terminals system-wide. + - This will break programs assuming the default Windows 10 encoding. + 1. On Windows 11, UTF-8 terminals are the default. +1. You can use `GNAT.IO` or `Ada.Streams.Stream_IO` to output properly encoded strings, as they don't manipulate the bytes. +1. You **cannot** use `Ada.Text_IO` to output UTF-8-encoded `String` variables, as Latin-1 encoding is expected. + +You can experiment with the `utf8test` crate at +https://github.com/mosteo/utf8test to check how your environment behaves in +regard to UTF-8 output. + +## Ada and GNAT string encoding basics + +Properly working with Unicode in Ada relies on these bits of info: + +- The Ada Standard designates the full Unicode character for its repertoire [1], but: +- The default encoding used by GNAT, unless a BOM is found, is Latin-1 [2]. +- The standard `Character` type is Latin-1 [3], so: +- `Ada.Text_IO` expects Latin-1-encoded strings (superset of ASCII), incompatible with UTF-8. +- `Ada.Wide_Wide_Text_IO` expects UTF-32 strings, that is, regular `Wide_Wide_Strings` in practice. + +It is common to use `String` to store byte sequences in different encodings. +This is a source of problems when going out of ASCII, as depending on how these +strings are populated, they may easily end being either Latin-1 or UTF-8 or +something else. + +UTF-8-encoded strings are more memory-efficient, but cannot be used to iterate +over characters without help of support libraries. `Wide_Wide_Strings` retain +the 1:1 index-to-character ratio, so they are efficient for such iterations. +`Wide_Strings`, which are defined to hold 2-byte Unicode code points (although +conceivably they could also be used with UTF-16), are probably a middle-ground +not useful in general anymore. + +## Migrating 'old' code + +1. Save all source files as UTF-8 (see e.g. `iconv`). +1. Add `-gnatW8` to your compiler switches. +1. Fix any errors that arise due to `String` literals containing characters outside of the Latin-1 range (see next section). +1. Look for suspect uses of `Ada.Text_IO` and replace it with `Ada.Wide_Wide_Text_IO` or `GNAT.IO` or `Ada.Streams.Stream_IO`. + - Use `Ada.Characters.Conversions.To_Wide_Wide_String` to convert Latin-1 strings to UTF-32. + - Use `Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode` to convert UTF-8 strings to UTF-32. + - Use `Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode` to convert UTF-32 strings to UTF-8. + +## Common pitfalls + +A particularity of `-gnatW8` is that it may affect compilation units in other +projects, for example when specifications or generic bodies are 'withed', as +these are compiled also in the context of the client project. This may cause +issues when not all projects use `-gnatW8`, even if projects in isolation work +properly. + +Trouble may thus arise from inconsistencies between source file encoding and +`-gnatW8` being in effect, or even simply by saving Latin-1 files as UTF-8 in +order to enable `-gnatW8`: + +- Latin-1 (or other non UTF-8) sources compiled with -gnatW8 will likely cause +"illegal wide character" errors, as Latin-1 literals will be invalid UTF-8 +sequences. +- UTF-8 sources compiled without -gnatW8 will result in mangled output as the +UTF-8 sequences are misinterpreted as Latin-1, where most bytes are a valid +character code. +- Latin-1 sources saved to UTF-8 and compiled with -gnatW8 may result in +"literal out of range of type Standard.Character" errors when characters +outside of Latin-1 are assigned to a regular `Character` instead of +`Wide_Wide_Character`. + - Example: `X : String := "€";` + - Will work without `-gnatW8`, resulting in a three-byte string. + - Will err with `-gnatW8`, as '€' is out of `Character` range. + - In this case, the code has to be adapted to use `Wide_Wide_String`/`Wide_Wide_Character`, or the string manually encoded as UTF-8 (which will **not** be apt for use with `Ada.Text_IO`): + `subtype UTF8_String is String;` + `X : UTF8_String := Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode ("€");` + + +See a few more examples: + +``` +O_Acute : constant Character := 'ó'; +-- With Latin-1 source and -gnatW8, it will fail as 'ó' won't be a proper UTF-8 sequence in the input file. +-- With UTF-8 source and -gnatW8, it will work **but** it will be stored in Latin-1 encoding in memory. +-- It can be converted to a Wide_Wide_String (that will be in UTF-32) +-- with `Ada.Characters.Conversions.To_Wide_Wide_String`. In this case, +-- using `Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode` would be wrong, +-- as the String is Latin-1 and not UTF-8 despite the source file encoding being UTF-8. + +Bye : constant String := "Adiós"; +-- Without -gnatW8 but UTF-8 sources without a BOM marker, this will end being an UTF-8 byte sequence, +-- as it is interpreted literally as Latin-1 characters. +-- With -gnatW8, the UTF-8 will be properly loaded and converted to Latin-1 for the in-memory representation. + +Bye : constant String (1 .. 5) := "Adiós"; +-- This is proper for a Latin-1-encoded file and compiling without -gnatW8. +-- With -gnatW8 and an UTF-8 file, it will work properly and also end as a 5-byte Latin-1 string. +-- With -gnatW8 but with Latin-1-encoded file, it will fail as the sequence won't be proper UTF-8. +-- Without -gnatW8 but with an UTF-8 file it will fail as the sequence will be 6 bytes long. + +Euro : constant String := "€"; +-- Without -gnatW8 and a UTF-8-encoded file, this results in a 3-byte UTF-8 string. +-- With -gnatW8 and a UTF-8-encoded file, this results in an error as '€' is outside of Character. +``` + +## References + +[1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-2-1.html +[2] https://docs.adacore.com/live/wave/gnat_ugn/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#character-set-control +[3] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-3-5-2.html \ No newline at end of file diff --git a/src/alire/alire-properties-build_switches.adb b/src/alire/alire-properties-build_switches.adb index 25242155..b8ed461d 100644 --- a/src/alire/alire-properties-build_switches.adb +++ b/src/alire/alire-properties-build_switches.adb @@ -41,6 +41,10 @@ package body Alire.Properties.Build_Switches is is new Utils.Did_You_Mean.Enum_Suggestion (Ada_Version_Kind, Utils.Did_You_Mean.Lower_Case); + function Source_Encoding_Suggestion + is new Utils.Did_You_Mean.Enum_Suggestion + (Source_Encoding_Kind, Utils.Did_You_Mean.Lower_Case); + ----------------------- -- Switch_Suggestion -- ----------------------- @@ -57,6 +61,7 @@ package body Alire.Properties.Build_Switches is when Runtime_Checks => return Runtime_Checks_Suggestion (Str); when Style_Checks => return Style_Checks_Suggestion (Str); when Ada_Version => return Ada_Version_Suggestion (Str); + when Source_Encoding => return Source_Encoding_Suggestion (Str); end case; end Switch_Suggestion; @@ -132,6 +137,8 @@ package body Alire.Properties.Build_Switches is Result.Style_Checks := (Custom => True, List => List); when Ada_Version => Result.Ada_Version := (Custom => True, List => List); + when Source_Encoding => + Result.Source_Encoding := (Custom => True, List => List); end case; elsif T.Kind = TOML_String then @@ -194,6 +201,14 @@ package body Alire.Properties.Build_Switches is Result.Ada_Version := (Custom => False, Value => K); end; + when Source_Encoding => + declare + K : constant Source_Encoding_Kind := + Source_Encoding_Kind'Value (T.As_String); + begin + Result.Source_Encoding := (Custom => False, Value => K); + end; + end case; exception when Constraint_Error => @@ -266,6 +281,8 @@ package body Alire.Properties.Build_Switches is Sw.Style_Checks := M.Style_Checks; when Ada_Version => Sw.Ada_Version := M.Ada_Version; + when Source_Encoding => + Sw.Source_Encoding := M.Source_Encoding; end case; end Apply; diff --git a/src/alire/alire-properties-build_switches.ads b/src/alire/alire-properties-build_switches.ads index 003c7b0f..93207e3b 100644 --- a/src/alire/alire-properties-build_switches.ads +++ b/src/alire/alire-properties-build_switches.ads @@ -24,7 +24,9 @@ package Alire.Properties.Build_Switches with Preelaborate is when Style_Checks => Style_Checks : Style_Checks_Switches; when Ada_Version => - Ada_Version : Ada_Version_Switches; + Ada_Version : Ada_Version_Switches; + when Source_Encoding => + Source_Encoding : Source_Encoding_Switches; end case; end record; diff --git a/src/alire/alire-utils-switches.adb b/src/alire/alire-utils-switches.adb index c0dce158..b99caf38 100644 --- a/src/alire/alire-utils-switches.adb +++ b/src/alire/alire-utils-switches.adb @@ -203,19 +203,29 @@ package body Alire.Utils.Switches is -- Get_List -- -------------- + function Get_List (S : Source_Encoding_Switches) return Switch_List + is (if S.Custom + then S.List + else + (case S.Value is + when Compiler_Default => Empty_List, + when UTF_8 => Empty_List.Append (GNAT_UTF8_Encoding))); + + -------------- + -- Get_List -- + -------------- + function Get_List (C : Switches_Configuration) return Switch_List is begin return Empty_List - -- Unconditional switches - .Append (GNAT_UTF8_Encoding) -- - .Append (Get_List (C.Optimization)) .Append (Get_List (C.Debug_Info)) .Append (Get_List (C.Runtime_Checks)) .Append (Get_List (C.Compile_Checks)) .Append (Get_List (C.Contracts)) .Append (Get_List (C.Style_Checks)) - .Append (Get_List (C.Ada_Version)); + .Append (Get_List (C.Ada_Version)) + .Append (Get_List (C.Source_Encoding)); end Get_List; end Alire.Utils.Switches; diff --git a/src/alire/alire-utils-switches.ads b/src/alire/alire-utils-switches.ads index b2f9ea49..72d5775e 100644 --- a/src/alire/alire-utils-switches.ads +++ b/src/alire/alire-utils-switches.ads @@ -30,7 +30,8 @@ is Compile_Checks, Runtime_Checks, Style_Checks, - Ada_Version); + Ada_Version, + Source_Encoding); type Optimization_Kind is (Performance, Size, Debug); @@ -52,6 +53,11 @@ is Ada83, Ada95, Ada05, Ada12, Ada2022, GNAT_Extensions); + type Source_Encoding_Kind is + (Compiler_Default, -- Default behavior of GNAT, no switches set (Latin1) + UTF_8 -- -gnatW8, UTF-8 sources, full literals & identifiers + ); + type Optimization_Switches (Custom : Boolean := False) is record case Custom is @@ -108,6 +114,14 @@ is end case; end record; + type Source_Encoding_Switches (Custom : Boolean := False) + is record + case Custom is + when True => List : Switch_List; + when False => Value : Source_Encoding_Kind; + end case; + end record; + function Get_List (S : Optimization_Switches) return Switch_List; function Get_List (S : Debug_Info_Switches) return Switch_List; function Get_List (S : Runtime_Checks_Switches) return Switch_List; @@ -115,45 +129,50 @@ is function Get_List (S : Contracts_Switches) return Switch_List; function Get_List (S : Style_Checks_Switches) return Switch_List; function Get_List (S : Ada_Version_Switches) return Switch_List; + function Get_List (S : Source_Encoding_Switches) return Switch_List; type Switches_Configuration is record - Optimization : Optimization_Switches; - Debug_Info : Debug_Info_Switches; - Runtime_Checks : Runtime_Checks_Switches; - Compile_Checks : Compile_Checks_Switches; - Contracts : Contracts_Switches; - Style_Checks : Style_Checks_Switches; - Ada_Version : Ada_Version_Switches; + Optimization : Optimization_Switches; + Debug_Info : Debug_Info_Switches; + Runtime_Checks : Runtime_Checks_Switches; + Compile_Checks : Compile_Checks_Switches; + Contracts : Contracts_Switches; + Style_Checks : Style_Checks_Switches; + Ada_Version : Ada_Version_Switches; + Source_Encoding : Source_Encoding_Switches; end record; function Get_List (C : Switches_Configuration) return Switch_List; Default_Release_Switches : constant Switches_Configuration - := (Optimization => (Custom => False, Value => Performance), - Debug_Info => (Custom => False, Value => No), - Runtime_Checks => (Custom => False, Value => Default), - Compile_Checks => (Custom => False, Value => None), - Contracts => (Custom => False, Value => No), - Style_Checks => (Custom => False, Value => No), - Ada_Version => (Custom => False, Value => Compiler_Default)); + := (Optimization => (Custom => False, Value => Performance), + Debug_Info => (Custom => False, Value => No), + Runtime_Checks => (Custom => False, Value => Default), + Compile_Checks => (Custom => False, Value => None), + Contracts => (Custom => False, Value => No), + Style_Checks => (Custom => False, Value => No), + Ada_Version => (Custom => False, Value => Compiler_Default), + Source_Encoding => (Custom => False, Value => UTF_8)); Default_Validation_Switches : constant Switches_Configuration - := (Optimization => (Custom => False, Value => Performance), - Debug_Info => (Custom => False, Value => Yes), - Runtime_Checks => (Custom => False, Value => Everything), - Compile_Checks => (Custom => False, Value => Errors), - Contracts => (Custom => False, Value => Yes), - Style_Checks => (Custom => False, Value => Yes), - Ada_Version => (Custom => False, Value => Compiler_Default)); + := (Optimization => (Custom => False, Value => Performance), + Debug_Info => (Custom => False, Value => Yes), + Runtime_Checks => (Custom => False, Value => Everything), + Compile_Checks => (Custom => False, Value => Errors), + Contracts => (Custom => False, Value => Yes), + Style_Checks => (Custom => False, Value => Yes), + Ada_Version => (Custom => False, Value => Compiler_Default), + Source_Encoding => (Custom => False, Value => UTF_8)); Default_Development_Switches : constant Switches_Configuration - := (Optimization => (Custom => False, Value => Debug), - Debug_Info => (Custom => False, Value => Yes), - Runtime_Checks => (Custom => False, Value => Default), - Compile_Checks => (Custom => False, Value => Warnings), - Contracts => (Custom => False, Value => No), - Style_Checks => (Custom => False, Value => Yes), - Ada_Version => (Custom => False, Value => Compiler_Default)); + := (Optimization => (Custom => False, Value => Debug), + Debug_Info => (Custom => False, Value => Yes), + Runtime_Checks => (Custom => False, Value => Default), + Compile_Checks => (Custom => False, Value => Warnings), + Contracts => (Custom => False, Value => No), + Style_Checks => (Custom => False, Value => Yes), + Ada_Version => (Custom => False, Value => Compiler_Default), + Source_Encoding => (Custom => False, Value => UTF_8)); private Empty_List : constant Switch_List := diff --git a/testsuite/tests/build_profile/custom_switches/test.py b/testsuite/tests/build_profile/custom_switches/test.py index 2f768c55..b82a6388 100644 --- a/testsuite/tests/build_profile/custom_switches/test.py +++ b/testsuite/tests/build_profile/custom_switches/test.py @@ -40,6 +40,7 @@ for path in manifests: manifest.write('"*".contracts = ["-contracts-switch"]\n') manifest.write('"*".style_checks = ["-style-switch", "-style-switch2"]\n') manifest.write('"*".ada_version = ["-ada-version"]\n') + manifest.write('"*".source_encoding = ["-source-encoding"]\n') run_alr('update') @@ -51,7 +52,8 @@ expected_switches = ['-opt-switch', '-contracts-switch', '-style-switch', '-style-switch2', - '-ada-version'] + '-ada-version', + '-source-encoding'] check_config(lib1_config, 'release', expected_switches) check_config(lib2_config, 'release', expected_switches) -- 2.39.5