Skip to content

Commit

Permalink
Add CLI option for ensuring reproducible output
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1489
  • Loading branch information
treiher committed Dec 4, 2023
1 parent fbecae0 commit 32ca306
Show file tree
Hide file tree
Showing 260 changed files with 2,615 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support for FSF GNAT 13.2 (eng/recordflux/RecordFlux#1458)
- `--reproducible` option to `rflx generate` and `rflx convert` (eng/recordflux/RecordFlux#1489)

### Changed

Expand Down
7 changes: 4 additions & 3 deletions doc/user_guide/90-rflx-convert--help.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
usage: rflx convert [-h] {iana} ...
usage: rflx convert [-h] [--reproducible] {iana} ...

positional arguments:
{iana}
iana convert IANA registry into RecordFlux specifications
iana convert IANA registry into RecordFlux specifications

options:
-h, --help show this help message and exit
-h, --help show this help message and exit
--reproducible ensure reproducible output
2 changes: 2 additions & 0 deletions doc/user_guide/90-rflx-generate--help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ usage: rflx generate [-h] [-p PREFIX] [-n] [-d OUTPUT_DIRECTORY]
[--debug {built-in,external}]
[--ignore-unsupported-checksum]
[--integration-files-dir INTEGRATION_FILES_DIR]
[--reproducible]
[SPECIFICATION_FILE ...]

positional arguments:
Expand All @@ -19,3 +20,4 @@ options:
ignore checksum aspects during code generation
--integration-files-dir INTEGRATION_FILES_DIR
directory for the .rfi files
--reproducible ensure reproducible output
6 changes: 3 additions & 3 deletions doc/user_guide/90-rflx-validate--help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ positional arguments:
MESSAGE_IDENTIFIER identifier of the top-level message (e.g.,
Package::Message)

optional arguments:
options:
-h, --help show this help message and exit
--split-disjunctions split disjunctions before model validation (may have
severe performance impact)
-v VALID_SAMPLE_PATH known valid sample files or directories
-v VALID_SAMPLE_PATH known valid sample file or directory
-i INVALID_SAMPLE_PATH
known invalid sample files or directories
known invalid sample file or directory
-c CHECKSUM_MODULE name of the module containing the checksum functions
-o OUTPUT_FILE path to output file for validation report in JSON
format (file must not exist)
Expand Down
15 changes: 12 additions & 3 deletions rflx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse
import json
import logging
import os
import re
import shutil
import sys
Expand Down Expand Up @@ -220,6 +219,11 @@ def main( # noqa: PLR0915
help="directory for the .rfi files",
type=Path,
)
parser_generate.add_argument(
"--reproducible",
action="store_true",
help="ensure reproducible output",
)
parser_generate.add_argument(
"files",
metavar="SPECIFICATION_FILE",
Expand Down Expand Up @@ -362,6 +366,11 @@ def main( # noqa: PLR0915
"convert",
help="convert foreign specifications into RecordFlux specifications",
)
parser_convert.add_argument(
"--reproducible",
action="store_true",
help="ensure reproducible output",
)

convert_subparsers = parser_convert.add_subparsers(dest="subcommand")

Expand Down Expand Up @@ -497,7 +506,7 @@ def generate(args: argparse.Namespace) -> None:
Generator(
args.prefix,
workers=args.workers,
reproducible=os.environ.get("RFLX_REPRODUCIBLE") is not None,
reproducible=args.reproducible,
debug=Debug.BUILTIN
if args.debug == "built-in"
else Debug.EXTERNAL
Expand Down Expand Up @@ -634,7 +643,7 @@ def convert_iana(args: argparse.Namespace) -> None:
args.file,
args.always_valid,
args.output_directory,
os.environ.get("RFLX_REPRODUCIBLE") is not None,
args.reproducible,
)


Expand Down
15 changes: 14 additions & 1 deletion rflx/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,20 @@ def _check_template_file(self, filename: str) -> None:
@cached_property
def _license_header(self) -> str:
if self._reproducible:
return ""
return (
common.comment_box(
[
"",
"Generated by RecordFlux",
"",
"Copyright (C) AdaCore GmbH",
"",
"SPDX-License-Identifier: Apache-2.0",
"",
],
)
+ "\n"
)

today = date.today() # noqa: DTZ011
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
with RFLX.RFLX_Types;
Expand Down
10 changes: 10 additions & 0 deletions tests/feature/messages_with_implict_size/generated/rflx-test.ads
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
with RFLX.RFLX_Types;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
with RFLX.RFLX_Types;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
with RFLX.RFLX_Types;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Restrictions (No_Streams);
pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------------------------------
-- --
-- Generated by RecordFlux --
-- --
-- Copyright (C) AdaCore GmbH --
-- --
-- SPDX-License-Identifier: Apache-2.0 --
-- --
------------------------------------------------------------------------------

pragma Style_Checks ("N3aAbCdefhiIklnOprStux");
pragma Warnings (Off, "redundant conversion");
with RFLX.RFLX_Types;
Expand Down
Loading

0 comments on commit 32ca306

Please sign in to comment.