Skip to content

tools: port populateUiInformation.php to Python - #1112

Open
Coastrnaut wants to merge 1 commit into
buddhi1980:masterfrom
Coastrnaut:tools/populate-ui-information-python
Open

Coastrnaut wants to merge 1 commit into
buddhi1980:masterfrom
Coastrnaut:tools/populate-ui-information-python

Conversation

@Coastrnaut

Copy link
Copy Markdown
Collaborator

Part of porting the PHP tools to Python, one PR per tool (see also #1107, #1108, #1109, #1110, #1111). With all of them in, tools/common.inc.php is no longer used and can be removed.

This replaces tools/populateUiInformation.php with tools/populate_ui_information.py. It is meant to do exactly what the PHP does, so the tool no longer needs a PHP install:

  • update the information boxes in formula/ui/*.ui from formula/definition
  • generate formula/opencl/*.cl
  • write the .fract configs and render missing formula thumbnails (mandelbulber2 + ImageMagick)
  • write deploy/formulaData.csv, parameterNames.txt and all_fractal_definitions.h (with nondry)
  • test-compile the OpenCL formulas with checkCl

Usage is unchanged: dry run by default, plus nondry, verbose, warning and checkCl. It uses Python 3.6+ and the standard library only. highlight, clang-format, mandelbulber2, ImageMagick and clang come from PATH, or from the HIGHLIGHT, CLANG_FORMAT, MANDELBULBER_EXEC_PATH, CONVERT and CLANG environment variables.

Equivalence check

The PHP (8.4) and the port were run side by side on identical copies of master, in dry, nondry (twice), verbose, warning and checkCl runs. Every file either one wrote was byte-identical (469 files on the first nondry: the ui files, .fract configs, two new .cl; formulaData.csv, parameterNames.txt and all_fractal_definitions.h came out equal to the committed ones), and the printed reports matched. A second nondry changed nothing on either side. The internal-name upgrade path (git mv of renamed formula files) was tested too, and rendering a thumbnail for one formula.

Not exercised with the real tools: highlight wasn't available, so both sides used the same deterministic stand-in — the code boxes in the ui files were compared as "same highlight output passed through the same way", not against real highlight output. Likewise checkCl ran only without a compiler (the "clang missing" path), and ImageMagick wasn't installed. A dry run on a machine with highlight should show the ui files unchanged.

Small differences

  • It stops with a message when highlight or clang-format is missing, instead of emptying the code boxes or writing unformatted .cl files.
  • mandelbulber2 is also found on PATH.
  • It does not print the script's own header comment.
  • It is slower than the PHP (about 80 s against 50 s for a dry run).

Generated files

The 459 generated .cl files change only in their "autogenerated by" line, which now names the new script. tools/README.md is updated.

Not part of this PR, but the tool reports them on master: chebyshev_bulb.cl and dual_power_mandelbox.cl have not been generated yet, and six formulas have no thumbnail.

populate_ui_information.py does what populateUiInformation.php did: it
reads formula/definition, updates the information boxes in the formula
.ui files, generates formula/opencl/*.cl, writes missing thumbnail
configs and images, formulaData.csv, parameterNames.txt and
all_fractal_definitions.h, and with checkCl test-compiles the OpenCL
formulas. Python 3.6+ standard library only; highlight, clang-format,
mandelbulber2, ImageMagick and clang can be overridden through
environment variables.

Against the PHP on identical input it writes the same bytes to every
file and prints the same report in dry, nondry, verbose, warning and
checkCl runs.

The generated .cl headers now name the new script; only that line
changes in them. README.md points to the new script.
die('could not read index for formula : ' + file + ' --> ' + print_r(definition_part_lines_raw))
f = {}
for definition_part_line in definition_part_lines:
match_line = preg_match(r'([a-zA-Z]+)\s*=\s*"?([\da-zA-Z\.: -_]*?)"?;', definition_part_line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants