libui 0.2.2-aarch64-linux → 0.2.3-aarch64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2927d1a6eeaf7cbb4faf2d51c21074eba361efa584302b37f29c0f2b96913295
4
- data.tar.gz: 891ddc5d4e02a6a5bde3d3d8c2366e991596cb60053da188d182c08ac4f14b9c
3
+ metadata.gz: b4a00e59b8214cf875852734d5b74c5716c38a1c4ba8354d8036a6ca6ec40599
4
+ data.tar.gz: b4d535e83d07883fe6561ab5fa8ff3620225dc29274f3c5ecdb6fa78ad27d115
5
5
  SHA512:
6
- metadata.gz: 4e3d19047534cb2ae54b91c6b43e849e8c862b9a6f60f573a58bbe1ba96dcafd878ed9611aee52d6ebc06706317d7ea8e37f410c212eccf159ad314ada1d6af2
7
- data.tar.gz: e7ec44c8f0b877965efbeb35e9ef0c2db3db0afadeb3b33446d514058bd8da4cfb5f6bcb31899f053cb0b5f6d44d1932a12361260df03385ff7efa79c495e3e2
6
+ metadata.gz: b93bb829808ac504a2bbf4bed51f742ca266d4e7cf10aa9840677b089f309f4fc7d05c3c204491c239b775a5c023252770ac9125c44e0b56dcc9e55c842be4a3
7
+ data.tar.gz: b5cdf29edc3f92aae2a42431ce426d5d69ae7709905535e9d188749a990ef2c23ef81869cdeb7b2d407ae109c77cbe00886442358c2488216d997b22e8f7258d
data/README.md CHANGED
@@ -2,17 +2,12 @@
2
2
 
3
3
  [![test](https://github.com/kojix2/LibUI/actions/workflows/test.yml/badge.svg)](https://github.com/kojix2/LibUI/actions/workflows/test.yml)
4
4
  [![Gem Version](https://img.shields.io/badge/dynamic/json?label=gem%20version&query=%24%5B0%5D.number&url=https%3A%2F%2Frubygems.org%2Fapi%2Fv1%2Fversions%2Flibui.json&color=brightgreen)](https://rubygems.org/gems/libui/versions)
5
- <a href="https://github.com/AndyObtiva/glimmer-dsl-libui"><img alt="glimmer-dsl-libui" src="https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-logo-hi-res.svg" width="50" height="50" align="right"></a>
6
- [![Pre-build](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml/badge.svg?branch=pre-build)](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml)
7
5
  [![Lines of Code](https://img.shields.io/endpoint?url=https%3A%2F%2Ftokei.kojix2.net%2Fbadge%2Fgithub%2Fkojix2%2FLibUI%2Flines)](https://tokei.kojix2.net/github/kojix2/LibUI)
6
+ <a href="https://github.com/AndyObtiva/glimmer-dsl-libui"><img alt="glimmer-dsl-libui" src="https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-logo-hi-res.svg" width="50" height="50" align="right"></a>
8
7
 
9
8
  LibUI is a Ruby wrapper for libui family.
10
9
 
11
- :rocket: [libui-ng](https://github.com/libui-ng/libui-ng) - A cross-platform portable GUI library
12
-
13
- :wrench: [libui-dev](https://github.com/petabyt/libui-dev) - Native UI library for C - with some extras
14
-
15
- :radio_button: [libui](https://github.com/andlabs/libui) - Original version by andlabs.
10
+ :rocket: [libui-ng](https://github.com/kojix2/libui-ng) - A cross-platform portable GUI library
16
11
 
17
12
  ## Installation
18
13
 
@@ -190,6 +185,18 @@ bundle exec rake vendor:auto
190
185
  bundle exec rake test
191
186
  ```
192
187
 
188
+ JRuby on macOS needs Java and AppKit must start on the first thread:
189
+
190
+ ```sh
191
+ export JAVA_HOME=/path/to/openjdk
192
+ export JRUBY_OPTS=-J-XstartOnFirstThread
193
+ jruby -Ilib examples/basic_button.rb
194
+ jruby -S rake test
195
+ ```
196
+
197
+ Take note that, as the above code shows, LibUI works via jruby as well, so you have an additional
198
+ GUI library (aside from jruby-swing by default) to test simple User Interfaces too.
199
+
193
200
  ### Pre-built shared libraries for libui-ng
194
201
 
195
202
  Download pre-built libui-ng shared libraries (per your current platform):
@@ -0,0 +1,164 @@
1
+ require 'rbconfig'
2
+
3
+ module LibUI
4
+ module Platform
5
+ CONFIG = {
6
+ 'arm64-darwin' => {
7
+ vendor: 'vendor/libui.arm64.dylib',
8
+ lib_names: ['libui.arm64.dylib', 'libui.dylib'],
9
+ release_zip: 'macOS-arm64-shared-release.zip',
10
+ release_src: 'builddir/meson-out/libui.dylib'
11
+ },
12
+ 'x86_64-darwin' => {
13
+ vendor: 'vendor/libui.x86_64.dylib',
14
+ lib_names: ['libui.x86_64.dylib', 'libui.dylib'],
15
+ release_zip: 'macOS-x64-shared-release.zip',
16
+ release_src: 'builddir/meson-out/libui.dylib'
17
+ },
18
+ 'x86_64-linux' => {
19
+ vendor: 'vendor/libui.x86_64.so',
20
+ lib_names: ['libui.x86_64.so', 'libui.so'],
21
+ release_zip: 'Ubuntu-x64-shared-release.zip',
22
+ release_src: 'builddir/meson-out/libui.so'
23
+ },
24
+ 'aarch64-linux' => {
25
+ vendor: 'vendor/libui.aarch64.so',
26
+ lib_names: ['libui.aarch64.so', 'libui.so'],
27
+ release_zip: 'Ubuntu-arm64-shared-release.zip',
28
+ release_src: 'builddir/meson-out/libui.so'
29
+ },
30
+ 'x64-mingw32' => {
31
+ vendor: 'vendor/libui.x64.dll',
32
+ lib_names: ['libui.x64.dll', 'libui.dll'],
33
+ release_zip: 'Windows-x64-msvc-shared-release.zip',
34
+ release_src: 'builddir/meson-out/libui.dll'
35
+ },
36
+ 'x86-mingw32' => {
37
+ vendor: 'vendor/libui.x86.dll',
38
+ lib_names: ['libui.x86.dll', 'libui.dll'],
39
+ release_zip: 'Windows-x86-msvc-shared-release.zip',
40
+ release_src: 'builddir/meson-out/libui.dll'
41
+ }
42
+ }.freeze
43
+
44
+ class << self
45
+ def config_keys
46
+ CONFIG.keys
47
+ end
48
+
49
+ def config_for(platform_key)
50
+ CONFIG[normalize_platform_key(platform_key)]
51
+ end
52
+
53
+ def current_config
54
+ config_for(detect_platform_key)
55
+ end
56
+
57
+ def detect_platform_key
58
+ native_platform_key || rubygems_platform_key
59
+ end
60
+
61
+ def native_platform_key
62
+ platform_key = case host_os
63
+ when /darwin/
64
+ "#{normalized_cpu}-darwin"
65
+ when /linux/
66
+ # libc variants (glibc vs musl) are not supported as
67
+ # separate prebuilt targets yet; the shipped Linux
68
+ # binaries are built on Ubuntu. Supporting musl would
69
+ # require adding explicit *-linux-musl entries.
70
+ "#{normalized_cpu}-linux"
71
+ when /mingw|mswin/
72
+ windows_platform_key
73
+ end
74
+
75
+ CONFIG.key?(platform_key) ? platform_key : nil
76
+ end
77
+
78
+ def rubygems_platform_key
79
+ current_platform = Gem::Platform.local
80
+ platform_key = normalize_platform_key(current_platform.to_s)
81
+ return platform_key if CONFIG.key?(platform_key)
82
+
83
+ CONFIG.keys.find do |config_key|
84
+ config_platform = Gem::Platform.new(config_key)
85
+
86
+ # NOTE: match_platforms? is a private RubyGems API. It is used to
87
+ # reuse RubyGems' own platform matching (including the libc wildcard
88
+ # behaviour), but it may change or disappear across RubyGems versions.
89
+ if Gem::Platform.send(:match_platforms?, current_platform, [config_platform])
90
+ true
91
+ elsif config_key == 'x64-mingw32' &&
92
+ current_platform.os.start_with?('mingw') &&
93
+ %w[x64 x86_64 amd64].include?(current_platform.cpu)
94
+ true
95
+ elsif config_key == 'x86-mingw32' &&
96
+ current_platform.os.start_with?('mingw') &&
97
+ %w[x86 i386 i686].include?(current_platform.cpu)
98
+ true
99
+ else
100
+ false
101
+ end
102
+ end
103
+ end
104
+
105
+ # Canonicalizes alternate platform spellings to the keys used in CONFIG.
106
+ # Linux libc suffixes (-gnu / -musl) are intentionally not stripped here;
107
+ # adding libc-specific artifacts should be an explicit CONFIG change.
108
+ def normalize_platform_key(platform_key)
109
+ platform_key.to_s
110
+ .sub(/\Aarm64-linux\z/, 'aarch64-linux')
111
+ .sub(/\Ax64-linux\z/, 'x86_64-linux')
112
+ .sub(/-mingw-ucrt\z/, '-mingw32')
113
+ end
114
+
115
+ def vendor_file_for(platform_key)
116
+ config = config_for(platform_key)
117
+ config && config[:vendor]
118
+ end
119
+
120
+ def current_lib_names
121
+ # host_lib_name and the bare "libui.<soext>" are fallbacks for locally
122
+ # built or manually placed libraries (e.g. via LIBUIDIR or a source
123
+ # checkout) whose file names may not match the CONFIG lib_names.
124
+ host_lib_name = "libui.#{host_cpu}.#{RbConfig::CONFIG['SOEXT']}"
125
+ names = current_config ? current_config[:lib_names] : []
126
+ ([host_lib_name] + names + ["libui.#{RbConfig::CONFIG['SOEXT']}"]).uniq
127
+ end
128
+
129
+ private
130
+
131
+ def host_cpu
132
+ RbConfig::CONFIG['host_cpu']
133
+ end
134
+
135
+ def host_os
136
+ RbConfig::CONFIG['host_os']
137
+ end
138
+
139
+ def normalized_cpu
140
+ case host_cpu
141
+ when /i\d86/
142
+ 'x86'
143
+ when 'amd64', 'x64'
144
+ 'x86_64'
145
+ when 'aarch64'
146
+ host_os =~ /darwin/ ? 'arm64' : host_cpu
147
+ when 'arm64'
148
+ host_os =~ /linux/ ? 'aarch64' : host_cpu
149
+ else
150
+ host_cpu
151
+ end
152
+ end
153
+
154
+ def windows_platform_key
155
+ case normalized_cpu
156
+ when 'x86_64'
157
+ 'x64-mingw32'
158
+ when 'x86'
159
+ 'x86-mingw32'
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
data/lib/libui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LibUI
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
data/lib/libui.rb CHANGED
@@ -1,36 +1,20 @@
1
1
  require_relative 'libui/version'
2
2
  require_relative 'libui/utils'
3
3
  require_relative 'libui/error'
4
- require 'rbconfig'
4
+ require_relative 'libui/platform'
5
5
 
6
6
  module LibUI
7
7
  class << self
8
8
  attr_accessor :ffi_lib
9
9
  end
10
10
 
11
- host_cpu = case RbConfig::CONFIG['host_cpu']
12
- when /i\d86/
13
- 'x86'
14
- else
15
- RbConfig::CONFIG['host_cpu']
16
- end
17
-
18
- lib_name = [
19
- # For libui-ng shared libraries compiled with (rake vendor:build)
20
- "libui.#{RbConfig::CONFIG['host_cpu']}.#{RbConfig::CONFIG['SOEXT']}",
21
- # For libui-ng shared library downloaded from RubyGems.org
22
- "libui.#{host_cpu}.#{RbConfig::CONFIG['SOEXT']}",
23
- # For backward compatibility or manual compilation of libui-ng
24
- "libui.#{RbConfig::CONFIG['SOEXT']}"
25
- ]
26
-
27
11
  self.ffi_lib = \
28
12
  if ENV['LIBUIDIR'] && !ENV['LIBUIDIR'].empty?
29
- lib_name.lazy
13
+ Platform.current_lib_names.lazy
30
14
  .map { |name| File.expand_path(name, ENV['LIBUIDIR']) }
31
15
  .find { |path| File.exist?(path) }
32
16
  else
33
- lib_name.lazy
17
+ Platform.current_lib_names.lazy
34
18
  .map { |name| File.expand_path("../vendor/#{name}", __dir__) }
35
19
  .find { |path| File.exist?(path) }
36
20
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - kojix2
@@ -36,6 +36,7 @@ files:
36
36
  - lib/libui/ffi.rb
37
37
  - lib/libui/fiddle_patch.rb
38
38
  - lib/libui/libui_base.rb
39
+ - lib/libui/platform.rb
39
40
  - lib/libui/utils.rb
40
41
  - lib/libui/version.rb
41
42
  - vendor/LICENSE.md