Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion renderer/desktop/c/smoke_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ static void build_label_update(const char *label) {
* density and the type scale it is drawn with, and the node is measured by the
* renderer's own layout.
*/
#define MEASURE_RECORD 72
/* The length of one measure request record, MEASURE_RECORD_LEN in compose-rust/src/measure.rs.
* The records here are zeroed first, so a field added at the end (the font features at 72)
* reads as absent. scripts/tests/smoke-host-measure-record.test.sh holds the two lengths equal. */
#define MEASURE_RECORD 80
#define MEASURE_WIDTH 1000.0f
#define HTML_NODE 6
#define HTML_TEXT "Measured as CSS text"
Expand Down
16 changes: 16 additions & 0 deletions renderer/scripts/fork-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,27 @@ sub served_targets {
return grep { has_artifact($group, "$artifact-$_") } @targets;
}

# A multiplatform root points each target at a publication of its own ("available-at"). A
# module built for one platform alone (skiko-awt of the fork, a JVM jar the desktop modules name
# since 1.11.1-ext.4) has no such publications, and its root is all there is to publish.
sub is_single_platform {
my ($group, $artifact) = @_;
my $file = files_of($group, $artifact) . ".module";
return 1 unless -s $file;
open my $in, "<", $file or return 0;
local $/;
my $metadata = eval { JSON::PP->new->decode(<$in>) };
close $in;
return 0 unless $metadata;
return !grep { exists $_->{"available-at"} } @{ $metadata->{variants} || [] };
}

sub is_published {
my ($group, $artifact, $served) = @_;
return 0 unless has_artifact($group, $artifact);
my ($base, $target) = split_target($artifact);
return 1 if defined $target;
return 1 if is_single_platform($group, $artifact);
for my $served_target (@$served) {
return 0 unless has_artifact($group, "$artifact-$served_target");
}
Expand Down
32 changes: 32 additions & 0 deletions scripts/tests/fork-dependencies.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# published, names it and the command that publishes it, and accepts the complete one
# a constraint (an atomic group naming every module in it) is not a missing sibling, and
# neither is a dependency of a root's variant for a target that was not built
# a published module built for one platform alone (skiko-awt) is not a missing sibling, and a
# multiplatform root without the target's publication is
set -euo pipefail

repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
Expand Down Expand Up @@ -186,4 +188,34 @@ else
fail "require-fork-artifacts.sh reported ui-uikit, which only the root's iOS and shared metadata variants name"
fi

# A desktop publication naming a module built for one platform alone, as the fork's desktop
# modules name its skiko-awt since 1.11.1-ext.4: that module's root is all there is, and it is
# published. A multiplatform root (one whose variants point at target publications) without
# its desktop publication is still not.
# single <home> <dependency> <with available-at: 0 or 1>: writes ui-desktop naming the dependency.
single() {
local m2="$1/.m2/repository/org/thisisthepy/compose" dependency="$2" multiplatform="$3"
mkdir -p "$m2/ui/ui-desktop/$fork_as" "$m2/skiko/$dependency/$fork_as"
printf '{"formatVersion":"1.1","variants":[{"name":"desktopApiElements-published","dependencies":[{"group":"org.thisisthepy.compose.skiko","module":"%s","version":{"requires":"%s"}}]}]}\n' \
"$dependency" "$fork_as" > "$m2/ui/ui-desktop/$fork_as/ui-desktop-$fork_as.module"
if [[ "$multiplatform" == 1 ]]; then
printf '{"formatVersion":"1.1","variants":[{"name":"desktopApiElements-published","available-at":{"url":"../../%s-desktop/%s/%s-desktop-%s.module","group":"org.thisisthepy.compose.skiko","module":"%s-desktop","version":"%s"}}]}\n' \
"$dependency" "$fork_as" "$dependency" "$fork_as" "$dependency" "$fork_as"
else
printf '{"formatVersion":"1.1","variants":[{"name":"apiElements","files":[]}]}\n'
fi > "$m2/skiko/$dependency/$fork_as/$dependency-$fork_as.module"
}
home="$work/home-single"
single "$home" skiko-awt 0
HOME="$home" bash "$tree/renderer/scripts/fork-dependencies.sh" check "$fork_as" desktop > "$work/out" 2>&1 ||
fail "fork-dependencies.sh refused a single-platform module that is published: $(head -1 "$work/out")"
home="$work/home-multi"
single "$home" skiko 1
if HOME="$home" bash "$tree/renderer/scripts/fork-dependencies.sh" check "$fork_as" desktop > "$work/out" 2>&1; then
fail "fork-dependencies.sh accepted a multiplatform root whose desktop publication nobody published"
else
grep -q "org.thisisthepy.compose.skiko:skiko:$fork_as" "$work/out" ||
fail "fork-dependencies.sh refused without naming skiko $fork_as: $(head -1 "$work/out")"
fi

if [[ "$failures" -eq 0 ]]; then echo " ok"; else exit 1; fi
17 changes: 17 additions & 0 deletions scripts/tests/smoke-host-measure-record.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# The smoke host writes its measure requests by hand, in C, so nothing generated keeps its
# record length in step with the Rust one. When the record grew from 72 to 80 bytes for the
# font features and the C stayed at 72, the renderer read every request after the first at
# the wrong place, and the smoke test failed on every platform with "the measure round trip
# did not agree". This holds the two lengths equal.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
rust="$(sed -nE 's/^pub const MEASURE_RECORD_LEN: usize = ([0-9]+);$/\1/p' "$root/compose-rust/src/measure.rs")"
c="$(sed -nE 's/^#define MEASURE_RECORD ([0-9]+)$/\1/p' "$root/renderer/desktop/c/smoke_host.c")"
[[ -n "$rust" ]] || { echo "FAIL MEASURE_RECORD_LEN not found in compose-rust/src/measure.rs" >&2; exit 1; }
[[ -n "$c" ]] || { echo "FAIL MEASURE_RECORD not found in renderer/desktop/c/smoke_host.c" >&2; exit 1; }
if [[ "$rust" != "$c" ]]; then
echo "FAIL the smoke host writes $c byte measure records, the Host and the renderer use $rust" >&2
exit 1
fi
echo "ok the smoke host's measure record is $c bytes, the same as MEASURE_RECORD_LEN"