libpng 1.6.58.4-aarch64-linux-ohos
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +211 -0
- data/.github/workflows/release.yml +299 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.rubocop.yml +39 -0
- data/CHANGELOG.md +127 -0
- data/CLAUDE.md +110 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +27 -0
- data/README.adoc +238 -0
- data/Rakefile +74 -0
- data/bin/console +5 -0
- data/bin/setup +5 -0
- data/ext/extconf.rb +19 -0
- data/lib/libpng/binding.rb +57 -0
- data/lib/libpng/bytes_per_pixel.rb +43 -0
- data/lib/libpng/chunk_walker.rb +271 -0
- data/lib/libpng/decoded_image.rb +22 -0
- data/lib/libpng/error.rb +8 -0
- data/lib/libpng/libpng16.so +0 -0
- data/lib/libpng/recipe.rb +247 -0
- data/lib/libpng/simplified_decoder.rb +107 -0
- data/lib/libpng/simplified_encoder.rb +98 -0
- data/lib/libpng/standard_encoder.rb +219 -0
- data/lib/libpng/version.rb +16 -0
- data/lib/libpng.rb +188 -0
- data/libpng.gemspec +38 -0
- metadata +90 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2801781739404a274da76f14128b6193d1b404ad40811fba83e4547a345f85ee
|
|
4
|
+
data.tar.gz: 7a8d425c8ecb899cd59d56bd6575f6ab7b2cd70a3ffa4460b809d38eff631ae3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7e7b6abe58eb8c8519e13e3327b3ddfae171d362e13092964fcd0484bcc084d34f2fc4ebabc418199d49a5ebed8d4365ba83e4e731e0d144efbad244e4387417
|
|
7
|
+
data.tar.gz: 1952b473d5278a63d67128acade0453682cc389bd5e7cc5f3f804550a3ed3055e81261be3be41cb7dbda78aa15f0d9f14eb2a42e4a1599f10eecef5bae830045
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
paths-ignore:
|
|
7
|
+
- '*.adoc'
|
|
8
|
+
pull_request:
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
prepare:
|
|
17
|
+
uses: metanorma/ci/.github/workflows/prepare-rake.yml@main
|
|
18
|
+
|
|
19
|
+
test:
|
|
20
|
+
name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}
|
|
21
|
+
runs-on: ${{ matrix.os }}
|
|
22
|
+
|
|
23
|
+
needs: prepare
|
|
24
|
+
if: needs.prepare.outputs.push-for-tag != 'true'
|
|
25
|
+
|
|
26
|
+
continue-on-error: ${{ matrix.ruby.experimental }}
|
|
27
|
+
strategy:
|
|
28
|
+
fail-fast: false
|
|
29
|
+
max-parallel: 5
|
|
30
|
+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- uses: ruby/setup-ruby@master
|
|
36
|
+
with:
|
|
37
|
+
bundler-cache: true
|
|
38
|
+
ruby-version: ${{ matrix.ruby.version }}
|
|
39
|
+
rubygems: ${{ matrix.ruby.rubygems }}
|
|
40
|
+
|
|
41
|
+
# libpng's CMake needs cmake >= 3.10 and a working zlib. Both are
|
|
42
|
+
# pre-installed on GitHub Actions runners; this is just a sanity check.
|
|
43
|
+
- name: Install build tools
|
|
44
|
+
if: startsWith(matrix.os, 'ubuntu')
|
|
45
|
+
run: |
|
|
46
|
+
sudo apt-get update
|
|
47
|
+
sudo apt-get install -y cmake ninja-build zlib1g-dev
|
|
48
|
+
|
|
49
|
+
- name: Install build tools (macOS)
|
|
50
|
+
if: startsWith(matrix.os, 'macos')
|
|
51
|
+
run: |
|
|
52
|
+
brew install cmake ninja
|
|
53
|
+
|
|
54
|
+
- name: Install build tools (Windows)
|
|
55
|
+
if: startsWith(matrix.os, 'windows')
|
|
56
|
+
uses: step-security/msvc-dev-cmd@v1
|
|
57
|
+
|
|
58
|
+
- run: bundle exec rake
|
|
59
|
+
|
|
60
|
+
build:
|
|
61
|
+
name: build ${{ matrix.os }}, ${{ matrix.ruby-version }}, ${{ matrix.platform }}
|
|
62
|
+
runs-on: ${{ matrix.os }}
|
|
63
|
+
needs: prepare
|
|
64
|
+
strategy:
|
|
65
|
+
fail-fast: false
|
|
66
|
+
matrix:
|
|
67
|
+
include:
|
|
68
|
+
- os: ubuntu-latest
|
|
69
|
+
platform: any
|
|
70
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
71
|
+
- os: ubuntu-latest
|
|
72
|
+
platform: x86_64-linux
|
|
73
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
74
|
+
- os: ubuntu-24.04-arm
|
|
75
|
+
platform: aarch64-linux
|
|
76
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
77
|
+
- os: windows-latest
|
|
78
|
+
platform: x64-mingw32
|
|
79
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
80
|
+
- os: windows-latest
|
|
81
|
+
platform: x64-mingw-ucrt
|
|
82
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
83
|
+
- os: windows-11-arm
|
|
84
|
+
platform: aarch64-mingw-ucrt
|
|
85
|
+
ruby-version: '3.4'
|
|
86
|
+
- os: macos-15-intel
|
|
87
|
+
platform: x86_64-darwin
|
|
88
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
89
|
+
- os: macos-latest
|
|
90
|
+
platform: arm64-darwin
|
|
91
|
+
ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
92
|
+
|
|
93
|
+
steps:
|
|
94
|
+
- uses: actions/checkout@v4
|
|
95
|
+
|
|
96
|
+
- name: Setup Ruby
|
|
97
|
+
uses: ruby/setup-ruby@master
|
|
98
|
+
with:
|
|
99
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
100
|
+
bundler-cache: true
|
|
101
|
+
|
|
102
|
+
- name: Install build tools (Linux)
|
|
103
|
+
if: startsWith(matrix.os, 'ubuntu')
|
|
104
|
+
run: |
|
|
105
|
+
sudo apt-get update
|
|
106
|
+
sudo apt-get install -y cmake ninja-build zlib1g-dev
|
|
107
|
+
|
|
108
|
+
- name: Install build tools (macOS)
|
|
109
|
+
if: startsWith(matrix.os, 'macos')
|
|
110
|
+
run: |
|
|
111
|
+
brew install cmake ninja
|
|
112
|
+
|
|
113
|
+
- name: Install build tools (Windows)
|
|
114
|
+
if: startsWith(matrix.os, 'windows')
|
|
115
|
+
uses: step-security/msvc-dev-cmd@v1
|
|
116
|
+
with:
|
|
117
|
+
arch: ${{ matrix.platform == 'aarch64-mingw-ucrt' && 'arm64' || 'x64' }}
|
|
118
|
+
|
|
119
|
+
- run: bundle exec rake gem:native:${{ matrix.platform }}
|
|
120
|
+
|
|
121
|
+
- uses: actions/upload-artifact@v4
|
|
122
|
+
with:
|
|
123
|
+
name: pkg-${{ matrix.platform }}
|
|
124
|
+
path: pkg/*.gem
|
|
125
|
+
|
|
126
|
+
- name: Install gem
|
|
127
|
+
run: gem install -b pkg/libpng-*.gem
|
|
128
|
+
|
|
129
|
+
- name: Test conversion
|
|
130
|
+
shell: bash
|
|
131
|
+
run: |
|
|
132
|
+
ruby -rlibpng -e 'png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); File.binwrite("test.png", png); puts Libpng.decode(png, pixel_format: "RGBA").inspect'
|
|
133
|
+
|
|
134
|
+
build_musl:
|
|
135
|
+
name: build ${{ matrix.platform }} (Alpine)
|
|
136
|
+
runs-on: ${{ matrix.os }}
|
|
137
|
+
needs: prepare
|
|
138
|
+
strategy:
|
|
139
|
+
fail-fast: false
|
|
140
|
+
matrix:
|
|
141
|
+
include:
|
|
142
|
+
- os: ubuntu-latest
|
|
143
|
+
platform: x86_64-linux-musl
|
|
144
|
+
- os: ubuntu-24.04-arm
|
|
145
|
+
platform: aarch64-linux-musl
|
|
146
|
+
# OHOS (OpenHarmony / Huawei HarmonyOS PC) is musl-based arm64.
|
|
147
|
+
# Built inside the same Alpine container as aarch64-linux-musl;
|
|
148
|
+
# the resulting binary is byte-compatible. Only the gem's
|
|
149
|
+
# platform label differs so RubyGems on OHOS selects it.
|
|
150
|
+
- os: ubuntu-24.04-arm
|
|
151
|
+
platform: aarch64-linux-ohos
|
|
152
|
+
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/checkout@v4
|
|
155
|
+
|
|
156
|
+
# Run the entire build inside an Alpine container via `docker run` rather
|
|
157
|
+
# than the workflow `container:` field. The latter only works on x64
|
|
158
|
+
# runners (Actions' JS runtime has no arm64-musl build), but arm64 Ubuntu
|
|
159
|
+
# runners can run arm64 Alpine images natively via Docker.
|
|
160
|
+
- name: Build in Alpine container
|
|
161
|
+
shell: bash
|
|
162
|
+
env:
|
|
163
|
+
PLATFORM: ${{ matrix.platform }}
|
|
164
|
+
RUBY_VERSION: ${{ needs.prepare.outputs.default-ruby-version }}
|
|
165
|
+
run: |
|
|
166
|
+
cat > /tmp/alpine-build.sh <<'BUILD_EOF'
|
|
167
|
+
#!/bin/sh
|
|
168
|
+
set -e
|
|
169
|
+
apk add --no-cache build-base cmake ninja git file zlib-dev
|
|
170
|
+
# The mounted /work volume is owned by the host runner user; git in
|
|
171
|
+
# the container (running as root) refuses to operate on it without
|
|
172
|
+
# this. Without it, `git ls-files` in the gemspec returns empty and
|
|
173
|
+
# the built gem is missing lib/libpng.rb.
|
|
174
|
+
git config --global --add safe.directory /work
|
|
175
|
+
bundle install --jobs 4
|
|
176
|
+
bundle exec rake "gem:native:${PLATFORM}"
|
|
177
|
+
case "${PLATFORM}" in
|
|
178
|
+
*-ohos)
|
|
179
|
+
# OHOS gem is labeled aarch64-linux-ohos so RubyGems on OHOS
|
|
180
|
+
# selects it, but Alpine Ruby reports *-linux-musl -- a
|
|
181
|
+
# platform mismatch. The .so inside is musl-compatible, so
|
|
182
|
+
# unpack the gem and load it via -Ilib directly to verify
|
|
183
|
+
# the binary works without going through RubyGems install.
|
|
184
|
+
mkdir -p /tmp/ohos-smoke
|
|
185
|
+
gem unpack pkg/libpng-*.gem --target /tmp/ohos-smoke
|
|
186
|
+
(cd /tmp/ohos-smoke/libpng-* && \
|
|
187
|
+
ruby -Ilib -e 'require "libpng"; png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); puts Libpng.decode(png, pixel_format: "RGBA").inspect')
|
|
188
|
+
;;
|
|
189
|
+
*)
|
|
190
|
+
gem install -b pkg/libpng-*.gem
|
|
191
|
+
# Smoke test from /tmp so bundler's source-tree LOAD_PATH doesn't
|
|
192
|
+
# shadow the installed gem. Activate via `gem` so RubyGems resolves
|
|
193
|
+
# the platform-specific binary gem (Alpine Ruby's platform string
|
|
194
|
+
# is *-linux-musl, which must match the gem's platform suffix).
|
|
195
|
+
(cd /tmp && ruby -e 'gem "libpng"; require "libpng"; png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); File.binwrite("test.png", png); puts Libpng.decode(png, pixel_format: "RGBA").inspect')
|
|
196
|
+
;;
|
|
197
|
+
esac
|
|
198
|
+
BUILD_EOF
|
|
199
|
+
chmod +x /tmp/alpine-build.sh
|
|
200
|
+
docker run --rm \
|
|
201
|
+
-v "$PWD:/work" \
|
|
202
|
+
-v /tmp/alpine-build.sh:/alpine-build.sh \
|
|
203
|
+
-w /work \
|
|
204
|
+
-e PLATFORM \
|
|
205
|
+
ruby:${RUBY_VERSION}-alpine \
|
|
206
|
+
/alpine-build.sh
|
|
207
|
+
|
|
208
|
+
- uses: actions/upload-artifact@v4
|
|
209
|
+
with:
|
|
210
|
+
name: pkg-${{ matrix.platform }}
|
|
211
|
+
path: pkg/*.gem
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
bump-type:
|
|
10
|
+
description: 'What to bump before tagging'
|
|
11
|
+
type: choice
|
|
12
|
+
options:
|
|
13
|
+
- current
|
|
14
|
+
- iteration
|
|
15
|
+
- libpng
|
|
16
|
+
default: iteration
|
|
17
|
+
libpng-version:
|
|
18
|
+
description: 'New libpng version (required when bump-type=libpng, e.g. 1.6.49)'
|
|
19
|
+
type: string
|
|
20
|
+
required: false
|
|
21
|
+
|
|
22
|
+
# contents: write is needed for workflow_dispatch to push the bump commit + tag.
|
|
23
|
+
# id-token: write is required for RubyGems.org Trusted Publishing (OIDC).
|
|
24
|
+
permissions:
|
|
25
|
+
contents: write
|
|
26
|
+
id-token: write
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
bump:
|
|
30
|
+
if: github.event_name == 'workflow_dispatch'
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
outputs:
|
|
33
|
+
sha: ${{ steps.sha.outputs.sha }}
|
|
34
|
+
new-version: ${{ steps.bump.outputs.new-version }}
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- uses: ruby/setup-ruby@master
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: '3.3'
|
|
41
|
+
|
|
42
|
+
- name: Bump version.rb
|
|
43
|
+
id: bump
|
|
44
|
+
shell: bash
|
|
45
|
+
env:
|
|
46
|
+
BUMP_TYPE: ${{ inputs.bump-type }}
|
|
47
|
+
LIBPNG_VERSION_INPUT: ${{ inputs.libpng-version }}
|
|
48
|
+
run: |
|
|
49
|
+
set -euo pipefail
|
|
50
|
+
|
|
51
|
+
if [[ "$BUMP_TYPE" == "current" ]]; then
|
|
52
|
+
NEW_VERSION=$(ruby -Ilib -rlibpng/version -e 'puts Libpng::VERSION')
|
|
53
|
+
echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
|
|
54
|
+
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
|
|
55
|
+
echo "Releasing current VERSION (${NEW_VERSION}) -- no bump."
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
ruby <<'RUBY'
|
|
60
|
+
bump_type = ENV.fetch("BUMP_TYPE")
|
|
61
|
+
path = "lib/libpng/version.rb"
|
|
62
|
+
content = File.read(path)
|
|
63
|
+
|
|
64
|
+
case bump_type
|
|
65
|
+
when "iteration"
|
|
66
|
+
m = %r{LIBPNG_RUBY_ITERATION = (\d+)}.match(content) or
|
|
67
|
+
raise "Could not find LIBPNG_RUBY_ITERATION in #{path}"
|
|
68
|
+
content.sub!(%r{LIBPNG_RUBY_ITERATION = \d+},
|
|
69
|
+
"LIBPNG_RUBY_ITERATION = #{m[1].to_i + 1}") or
|
|
70
|
+
raise "Failed to substitute iteration"
|
|
71
|
+
when "libpng"
|
|
72
|
+
new_v = ENV.fetch("LIBPNG_VERSION_INPUT", "")
|
|
73
|
+
raise "libpng-version input is required when bump-type=libpng" if new_v.empty?
|
|
74
|
+
raise "Invalid version format: #{new_v} (expected X.Y.Z)" unless new_v.match?(/\A\d+\.\d+\.\d+\z/)
|
|
75
|
+
content.sub!(%r{LIBPNG_VERSION = "[^"]+"},
|
|
76
|
+
"LIBPNG_VERSION = \"#{new_v}\"") or
|
|
77
|
+
raise "Failed to substitute libpng version"
|
|
78
|
+
content.sub!(%r{LIBPNG_RUBY_ITERATION = \d+},
|
|
79
|
+
"LIBPNG_RUBY_ITERATION = 0") or
|
|
80
|
+
raise "Failed to reset iteration"
|
|
81
|
+
else
|
|
82
|
+
raise "Unknown bump-type: #{bump_type}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
File.write(path, content)
|
|
86
|
+
load File.expand_path(path)
|
|
87
|
+
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
|
|
88
|
+
f.puts "new-version=#{Libpng::VERSION}"
|
|
89
|
+
end
|
|
90
|
+
warn "Bumped to #{Libpng::VERSION}"
|
|
91
|
+
RUBY
|
|
92
|
+
|
|
93
|
+
NEW_VERSION=$(ruby -Ilib -rlibpng/version -e 'puts Libpng::VERSION')
|
|
94
|
+
echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
|
|
95
|
+
|
|
96
|
+
git config user.name "github-actions[bot]"
|
|
97
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
98
|
+
git add lib/libpng/version.rb
|
|
99
|
+
git commit -m "Release v${NEW_VERSION}"
|
|
100
|
+
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
101
|
+
|
|
102
|
+
- name: Show what's being released
|
|
103
|
+
run: |
|
|
104
|
+
echo "Releasing version: ${{ steps.bump.outputs.new-version }}"
|
|
105
|
+
git --no-pager log --oneline -1 "${{ steps.bump.outputs.sha }}"
|
|
106
|
+
|
|
107
|
+
- name: Push bump commit + tag
|
|
108
|
+
env:
|
|
109
|
+
NEW_VERSION: ${{ steps.bump.outputs.new-version }}
|
|
110
|
+
SHA: ${{ steps.bump.outputs.sha }}
|
|
111
|
+
run: |
|
|
112
|
+
if [[ -n "${SHA}" && "${SHA}" != "${{ github.sha }}" ]]; then
|
|
113
|
+
git push origin "HEAD:${{ github.event.repository.default_branch }}"
|
|
114
|
+
fi
|
|
115
|
+
git tag "v${NEW_VERSION}" "${SHA}"
|
|
116
|
+
git push origin "v${NEW_VERSION}"
|
|
117
|
+
|
|
118
|
+
build:
|
|
119
|
+
needs: bump
|
|
120
|
+
if: always() && !cancelled() && !failure() && (needs.bump.result == 'success' || needs.bump.result == 'skipped')
|
|
121
|
+
runs-on: ${{ matrix.os }}
|
|
122
|
+
strategy:
|
|
123
|
+
fail-fast: false
|
|
124
|
+
matrix:
|
|
125
|
+
include:
|
|
126
|
+
- os: ubuntu-latest
|
|
127
|
+
platform: any
|
|
128
|
+
ruby-version: '3.3'
|
|
129
|
+
- os: ubuntu-latest
|
|
130
|
+
platform: x86_64-linux
|
|
131
|
+
ruby-version: '3.3'
|
|
132
|
+
- os: ubuntu-24.04-arm
|
|
133
|
+
platform: aarch64-linux
|
|
134
|
+
ruby-version: '3.3'
|
|
135
|
+
- os: windows-latest
|
|
136
|
+
platform: x64-mingw32
|
|
137
|
+
ruby-version: '3.3'
|
|
138
|
+
- os: windows-latest
|
|
139
|
+
platform: x64-mingw-ucrt
|
|
140
|
+
ruby-version: '3.3'
|
|
141
|
+
- os: windows-11-arm
|
|
142
|
+
platform: aarch64-mingw-ucrt
|
|
143
|
+
ruby-version: '3.4'
|
|
144
|
+
- os: macos-15-intel
|
|
145
|
+
platform: x86_64-darwin
|
|
146
|
+
ruby-version: '3.3'
|
|
147
|
+
- os: macos-latest
|
|
148
|
+
platform: arm64-darwin
|
|
149
|
+
ruby-version: '3.3'
|
|
150
|
+
steps:
|
|
151
|
+
- uses: actions/checkout@v4
|
|
152
|
+
with:
|
|
153
|
+
ref: ${{ needs.bump.outputs.sha || github.ref }}
|
|
154
|
+
|
|
155
|
+
- uses: ruby/setup-ruby@master
|
|
156
|
+
with:
|
|
157
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
158
|
+
bundler-cache: true
|
|
159
|
+
|
|
160
|
+
- name: Install build tools (Linux)
|
|
161
|
+
if: startsWith(matrix.os, 'ubuntu')
|
|
162
|
+
run: |
|
|
163
|
+
sudo apt-get update
|
|
164
|
+
sudo apt-get install -y cmake ninja-build zlib1g-dev
|
|
165
|
+
|
|
166
|
+
- name: Install build tools (macOS)
|
|
167
|
+
if: startsWith(matrix.os, 'macos')
|
|
168
|
+
run: |
|
|
169
|
+
brew install cmake ninja
|
|
170
|
+
|
|
171
|
+
- name: Install build tools (Windows)
|
|
172
|
+
if: startsWith(matrix.os, 'windows')
|
|
173
|
+
uses: step-security/msvc-dev-cmd@v1
|
|
174
|
+
with:
|
|
175
|
+
arch: ${{ matrix.platform == 'aarch64-mingw-ucrt' && 'arm64' || 'x64' }}
|
|
176
|
+
|
|
177
|
+
- run: bundle exec rake gem:native:${{ matrix.platform }}
|
|
178
|
+
|
|
179
|
+
- uses: actions/upload-artifact@v4
|
|
180
|
+
with:
|
|
181
|
+
name: pkg-${{ matrix.platform }}
|
|
182
|
+
path: pkg/*.gem
|
|
183
|
+
|
|
184
|
+
- name: Install gem
|
|
185
|
+
run: gem install -b pkg/libpng-*.gem
|
|
186
|
+
|
|
187
|
+
- name: Test conversion
|
|
188
|
+
shell: bash
|
|
189
|
+
run: |
|
|
190
|
+
ruby -rlibpng -e 'png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); puts Libpng.decode(png, pixel_format: "RGBA").inspect'
|
|
191
|
+
|
|
192
|
+
build_musl:
|
|
193
|
+
needs: bump
|
|
194
|
+
if: always() && !cancelled() && !failure() && (needs.bump.result == 'success' || needs.bump.result == 'skipped')
|
|
195
|
+
runs-on: ${{ matrix.os }}
|
|
196
|
+
strategy:
|
|
197
|
+
fail-fast: false
|
|
198
|
+
matrix:
|
|
199
|
+
include:
|
|
200
|
+
- os: ubuntu-latest
|
|
201
|
+
platform: x86_64-linux-musl
|
|
202
|
+
- os: ubuntu-24.04-arm
|
|
203
|
+
platform: aarch64-linux-musl
|
|
204
|
+
# OHOS: same Alpine-built musl arm64 binary as aarch64-linux-musl,
|
|
205
|
+
# packaged under a distinct platform label.
|
|
206
|
+
- os: ubuntu-24.04-arm
|
|
207
|
+
platform: aarch64-linux-ohos
|
|
208
|
+
steps:
|
|
209
|
+
- uses: actions/checkout@v4
|
|
210
|
+
with:
|
|
211
|
+
ref: ${{ needs.bump.outputs.sha || github.ref }}
|
|
212
|
+
|
|
213
|
+
- name: Build in Alpine container
|
|
214
|
+
shell: bash
|
|
215
|
+
env:
|
|
216
|
+
PLATFORM: ${{ matrix.platform }}
|
|
217
|
+
run: |
|
|
218
|
+
cat > /tmp/alpine-build.sh <<'BUILD_EOF'
|
|
219
|
+
#!/bin/sh
|
|
220
|
+
set -e
|
|
221
|
+
apk add --no-cache build-base cmake ninja git file zlib-dev
|
|
222
|
+
git config --global --add safe.directory /work
|
|
223
|
+
bundle install --jobs 4
|
|
224
|
+
bundle exec rake "gem:native:${PLATFORM}"
|
|
225
|
+
case "${PLATFORM}" in
|
|
226
|
+
*-ohos)
|
|
227
|
+
# OHOS gem is labeled aarch64-linux-ohos so RubyGems on OHOS
|
|
228
|
+
# selects it, but Alpine Ruby reports *-linux-musl. The .so
|
|
229
|
+
# inside is musl-compatible -- unpack and load via -Ilib to
|
|
230
|
+
# verify the binary without going through RubyGems install.
|
|
231
|
+
mkdir -p /tmp/ohos-smoke
|
|
232
|
+
gem unpack pkg/libpng-*.gem --target /tmp/ohos-smoke
|
|
233
|
+
(cd /tmp/ohos-smoke/libpng-* && \
|
|
234
|
+
ruby -Ilib -e 'require "libpng"; png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); puts Libpng.decode(png, pixel_format: "RGBA").inspect')
|
|
235
|
+
;;
|
|
236
|
+
*)
|
|
237
|
+
gem install -b pkg/libpng-*.gem
|
|
238
|
+
(cd /tmp && ruby -e 'gem "libpng"; require "libpng"; png = Libpng.encode(2, 2, "\xff" * 16, pixel_format: "RGBA"); puts Libpng.decode(png, pixel_format: "RGBA").inspect')
|
|
239
|
+
;;
|
|
240
|
+
esac
|
|
241
|
+
BUILD_EOF
|
|
242
|
+
chmod +x /tmp/alpine-build.sh
|
|
243
|
+
docker run --rm \
|
|
244
|
+
-v "$PWD:/work" \
|
|
245
|
+
-v /tmp/alpine-build.sh:/alpine-build.sh \
|
|
246
|
+
-w /work \
|
|
247
|
+
-e PLATFORM \
|
|
248
|
+
ruby:3.3-alpine \
|
|
249
|
+
/alpine-build.sh
|
|
250
|
+
|
|
251
|
+
- uses: actions/upload-artifact@v4
|
|
252
|
+
with:
|
|
253
|
+
name: pkg-${{ matrix.platform }}
|
|
254
|
+
path: pkg/*.gem
|
|
255
|
+
|
|
256
|
+
publish:
|
|
257
|
+
needs: [ bump, build, build_musl ]
|
|
258
|
+
if: always() && !cancelled() && !failure()
|
|
259
|
+
runs-on: ubuntu-latest
|
|
260
|
+
steps:
|
|
261
|
+
- uses: actions/checkout@v4
|
|
262
|
+
with:
|
|
263
|
+
ref: ${{ needs.bump.outputs.sha || github.ref }}
|
|
264
|
+
|
|
265
|
+
- uses: ruby/setup-ruby@master
|
|
266
|
+
with:
|
|
267
|
+
ruby-version: '3.3'
|
|
268
|
+
bundler-cache: true
|
|
269
|
+
|
|
270
|
+
- uses: actions/download-artifact@v4
|
|
271
|
+
with:
|
|
272
|
+
pattern: pkg-*
|
|
273
|
+
path: pkg
|
|
274
|
+
merge-multiple: true
|
|
275
|
+
|
|
276
|
+
- name: Configure RubyGems credentials (Trusted Publishing / OIDC)
|
|
277
|
+
uses: rubygems/configure-rubygems-credentials@main
|
|
278
|
+
|
|
279
|
+
- name: Publish to rubygems.org
|
|
280
|
+
shell: bash
|
|
281
|
+
run: |
|
|
282
|
+
set +e
|
|
283
|
+
for gem in pkg/*.gem; do
|
|
284
|
+
output=$(gem push -V "$gem" 2>&1)
|
|
285
|
+
rc=$?
|
|
286
|
+
if [ $rc -eq 0 ]; then
|
|
287
|
+
echo "$output"
|
|
288
|
+
continue
|
|
289
|
+
fi
|
|
290
|
+
# RubyGems rejects re-pushing the same version with 422, even for
|
|
291
|
+
# identical content. Tolerate that so we can publish newly-added
|
|
292
|
+
# platform variants at a version whose source gem already exists.
|
|
293
|
+
if echo "$output" | grep -qE "already (exists|pushed)|Conflict|Repushing"; then
|
|
294
|
+
echo "Skip $(basename "$gem") (already published)"
|
|
295
|
+
continue
|
|
296
|
+
fi
|
|
297
|
+
echo "$output" >&2
|
|
298
|
+
exit 1
|
|
299
|
+
done
|
data/.gitignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
|
10
|
+
/ports/
|
|
11
|
+
/lib/libpng/*.so
|
|
12
|
+
/lib/libpng/*.so.*
|
|
13
|
+
/lib/libpng/*.dylib
|
|
14
|
+
/lib/libpng/*.dll
|
|
15
|
+
/Makefile
|
|
16
|
+
/lib/libpng/Makefile
|
|
17
|
+
/.idea/
|
|
18
|
+
/.vscode/
|
|
19
|
+
*.gem
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
TargetRubyVersion: 2.7
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Gemspec/DevelopmentDependencies:
|
|
7
|
+
Enabled: false
|
|
8
|
+
|
|
9
|
+
# The wrapper is by nature a single file with FFI declarations + several
|
|
10
|
+
# methods that walk libpng's chunked API; splitting would obscure the
|
|
11
|
+
# 1-to-1 mapping with the C API.
|
|
12
|
+
Metrics/AbcSize:
|
|
13
|
+
Max: 70
|
|
14
|
+
Metrics/ClassLength:
|
|
15
|
+
Max: 200
|
|
16
|
+
Metrics/CyclomaticComplexity:
|
|
17
|
+
Max: 20
|
|
18
|
+
Metrics/MethodLength:
|
|
19
|
+
Max: 70
|
|
20
|
+
Metrics/ModuleLength:
|
|
21
|
+
Max: 350
|
|
22
|
+
Metrics/PerceivedComplexity:
|
|
23
|
+
Max: 20
|
|
24
|
+
Metrics/ParameterLists:
|
|
25
|
+
Max: 9
|
|
26
|
+
|
|
27
|
+
Metrics/BlockLength:
|
|
28
|
+
Exclude:
|
|
29
|
+
- spec/**/*.rb
|
|
30
|
+
- Rakefile
|
|
31
|
+
- libpng.gemspec
|
|
32
|
+
|
|
33
|
+
Style/SpecialGlobalVars:
|
|
34
|
+
Exclude:
|
|
35
|
+
- ext/extconf.rb
|
|
36
|
+
Style/FrozenStringLiteralComment:
|
|
37
|
+
Exclude:
|
|
38
|
+
- ext/extconf.rb
|
|
39
|
+
- lib/libpng/recipe.rb
|