@@ -6,11 +6,24 @@ set -euo pipefail
66cd " $( dirname " $0 " ) "
77
88# Maps C config type to JSON schema type.
9- PHP_CODE=$( cat << 'ENDPHP '
9+ PHP_CODE_FILE=$( mktemp " ${TMPDIR:-/ tmp} /ddtrace-supported-configurations.XXXXXX.php" )
10+ trap ' rm -f "$PHP_CODE_FILE"' EXIT
11+
12+ cat > " $PHP_CODE_FILE " << 'ENDPHP '
13+ <?php
1014function map_type($raw) {
1115 $raw = trim($raw);
1216 if (preg_match('/^CUSTOM\((.+)\)$/', $raw, $m)) {
13- $raw = trim($m[1]);
17+ $inner = trim($m[1]);
18+ // CUSTOM() types don't always map 1:1 to JSON schema types.
19+ // In particular, CUSTOM(INT) values are exposed as strings at the config boundary.
20+ if ($inner === 'INT') {
21+ return 'string';
22+ }
23+ if ($inner === 'MAP') {
24+ return 'map';
25+ }
26+ $raw = $inner;
1427 }
1528 $map = [
1629 'BOOL' => 'boolean', 'STRING' => 'string', 'INT' => 'int', 'DOUBLE' => 'decimal',
@@ -172,7 +185,6 @@ $json = preg_replace_callback('/^ +/m', function ($m) {
172185file_put_contents($outputPath, $json . "\n");
173186echo "Wrote supported configurations to $outputPath\n";
174187ENDPHP
175- )
176188
177189cat << EOT >../ext/version.h
178190#ifndef PHP_DDTRACE_VERSION
@@ -181,7 +193,7 @@ cat <<EOT >../ext/version.h
181193EOT
182194
183195PHP_VERSION_ID=${PHP_VERSION_ID:- 0}
184- gcc $( php-config --includes) -I.. -I../ext -I../zend_abstract_interface -I../src/dogstatsd -I../components-rs -x c -E - << CODE | grep -A9999 -m1 -F ' JSON_CONFIGURATION_MARKER' | tail -n+2 | php -r " $PHP_CODE "
196+ gcc $( php-config --includes) -I.. -I../ext -I../zend_abstract_interface -I../src/dogstatsd -I../components-rs -x c -E - << CODE | grep -A9999 -m1 -F " JSON_CONFIGURATION_MARKER" | tail -n+2 | php " $PHP_CODE_FILE "
185197#include "../ext/configuration.h"
186198
187199#undef PHP_VERSION_ID
@@ -196,8 +208,10 @@ gcc $(php-config --includes) -I.. -I../ext -I../zend_abstract_interface -I../src
196208#define ALTCALIASES(...) ,##__VA_ARGS__
197209#define EXPAND(x) x
198210#define CUSTOM(id) id
199- #define CONFIG(type, name, default_value, ...) CALIAS(type, name, default_value,)
200- #define CALIAS(type, name, default_value, aliases, ...) #type, #name, default_value EXPAND(ALT##aliases) |NEXT_CONFIG|
211+ // Preserve the literal config type tokens (e.g. CUSTOM(INT)) so the generator can
212+ // map them to the correct JSON schema type.
213+ #define CONFIG(type, name, default_value, ...) CALIAS(#type, name, default_value,)
214+ #define CALIAS(type, name, default_value, aliases, ...) type, #name, default_value EXPAND(ALT##aliases) |NEXT_CONFIG|
201215
202216JSON_CONFIGURATION_MARKER
203217DD_CONFIGURATION
0 commit comments