emf2svg 1.4.1-arm64-darwin → 1.4.3-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c6c58b40697685f89140289dddac8f2df3f0fb2b28575258e14f8f602f23683
4
- data.tar.gz: 2d5f992001d058b8be5a2d6b1f61aa12c5550c5e88101035c34d0ea134d290eb
3
+ metadata.gz: e06e05ff566d383a64aea3c3e43ec7b5bc711d6f1eccf6260994b689c9e4add7
4
+ data.tar.gz: 9a78dcd98ecb56c1f37dae5116d41ea7ffc974b78e98f1877e64931457ea7e26
5
5
  SHA512:
6
- metadata.gz: 5b48ba4c9c21091ffbd5fb1658460a1fbd9e1c199ceaa73f3a9b353f0462291640e1c00630dc6e1fb05ecb151719768a6a37bbd955c9ce9d561ba5cfa9b1e360
7
- data.tar.gz: e8bbeefb40f31ae03472dce442ac01eb12f785b53d94da23606e63c0bea25ad7183ab1eb4682b541a776713ed57a841b87e8e22fac72f274506f4beee4735f3a
6
+ metadata.gz: f794102e36d8dec2256500e0f90d11c13105f0ce14acf9aee7d871ff4dde41cc7c9b111dda1b7d0357a98a52f48c2291a2feb7c354eb3d29521ee87d36edbc97
7
+ data.tar.gz: 8cf0193837a2b2e23ffa1d8fea743b8f0cc3f03f878752ab57b37c158270037e58f05574d520d7207cb03b68a4a78f379e04b8ffc5485586a4fb28bf04eb4e0f
@@ -8,21 +8,23 @@ on:
8
8
  pull_request:
9
9
  workflow_dispatch:
10
10
 
11
+ concurrency:
12
+ group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
13
+ cancel-in-progress: true
14
+
11
15
  jobs:
12
16
  test:
13
17
  runs-on: ${{ matrix.os }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
- os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
18
- ruby-version: [ '2.7' ]
19
- include:
20
- - os: windows-latest
21
- ruby-version: '3.1'
21
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
22
+ ruby-version: [ '2.7', '3.0', '3.1' ]
23
+
22
24
  steps:
23
25
  - uses: actions/checkout@v3
24
26
 
25
- - uses: ruby/setup-ruby@v1
27
+ - uses: ruby/setup-ruby@master
26
28
  with:
27
29
  bundler-cache: true
28
30
  ruby-version: ${{ matrix.ruby-version }}
@@ -44,30 +46,26 @@ jobs:
44
46
  fail-fast: false
45
47
  matrix:
46
48
  include:
47
- - os: ubuntu-18.04
49
+ - os: ubuntu-latest
48
50
  platform: any
49
51
  ruby-version: '2.7'
50
- file: 'skip'
51
- - os: ubuntu-18.04
52
+ - os: ubuntu-latest
52
53
  platform: x86_64-linux
53
54
  ruby-version: '2.7'
54
- file: 'ELF 64-bit LSB shared object, x86-64'
55
55
  - os: windows-latest
56
56
  platform: x64-mingw32
57
57
  ruby-version: '2.7'
58
- file: 'skip'
59
58
  - os: windows-latest
60
59
  platform: x64-mingw-ucrt
61
60
  ruby-version: '3.1'
62
- file: 'skip'
63
61
  - os: macos-latest
64
62
  platform: x86_64-darwin
65
63
  ruby-version: '2.7'
66
- file: 'Mach-O 64-bit dynamically linked shared library x86_64'
67
64
  steps:
68
65
  - uses: actions/checkout@v3
69
66
 
70
- - uses: ruby/setup-ruby@v1
67
+ - name: Setup Ruby
68
+ uses: ruby/setup-ruby@master
71
69
  with:
72
70
  ruby-version: ${{ matrix.ruby-version }}
73
71
  bundler-cache: true
@@ -80,122 +78,105 @@ jobs:
80
78
 
81
79
  - run: bundle exec rake gem:native:${{ matrix.platform }}
82
80
 
83
- - uses: actions/upload-artifact@v2
81
+ - uses: actions/upload-artifact@v3
84
82
  with:
85
83
  name: pkg
86
84
  path: pkg/*.gem
87
85
 
88
- - name: Install gem
89
- run: gem install -b pkg/emf2svg-*.gem
90
-
91
- - name: Test conversion
92
- run: |
93
- ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
94
-
95
- - name: Check file format
96
- if: matrix.file != 'skip'
97
- run: file $(ls pkg/*/lib/emf2svg/libemf2svg.*) | grep "${{ matrix.file }}"
98
-
99
- test-build:
100
- needs: build
86
+ cross-build:
87
+ name: build ${{ matrix.os }}, ${{ matrix.ruby-version }}, ${{ matrix.platform }}
101
88
  runs-on: ${{ matrix.os }}
102
89
  strategy:
103
90
  fail-fast: false
104
91
  matrix:
105
92
  include:
106
93
  - os: ubuntu-latest
107
- platform: any
108
- ruby-version: '2.7'
109
- - os: windows-latest
110
- platform: any
111
- ruby-version: '2.7'
112
- - os: macos-latest
113
- platform: any
114
- ruby-version: '2.7'
115
- - os: ubuntu-18.04
116
- platform: x86_64-linux
117
- ruby-version: '2.7'
118
- - os: ubuntu-latest
119
- platform: x86_64-linux
120
- ruby-version: '2.7'
121
- - os: windows-latest
122
- platform: x64-mingw32
94
+ platform: aarch64-linux
123
95
  ruby-version: '2.7'
124
- - os: windows-latest
125
- platform: x64-mingw-ucrt
126
- ruby-version: '3.1'
127
96
  - os: macos-latest
128
- platform: x86_64-darwin
97
+ platform: arm64-darwin
129
98
  ruby-version: '2.7'
130
-
131
99
  steps:
132
- - uses: actions/checkout@v2
100
+ - uses: actions/checkout@v3
101
+
102
+ - name: Install Ubuntu packages
103
+ if: startsWith(matrix.os, 'ubuntu')
104
+ run: |
105
+ sudo apt-get update
106
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
133
107
 
134
- - uses: ruby/setup-ruby@v1
108
+ - name: Install Ruby
109
+ uses: ruby/setup-ruby@master
135
110
  with:
136
111
  ruby-version: ${{ matrix.ruby-version }}
112
+ bundler-cache: true
113
+
114
+ - name: Build native extension
115
+ run: bundle exec rake gem:native:${{ matrix.platform }}
137
116
 
138
- - uses: actions/download-artifact@v2
117
+ - uses: actions/upload-artifact@v3
139
118
  with:
140
119
  name: pkg
141
- path: pkg
120
+ path: pkg/*.gem
142
121
 
143
- - name: Workaround for vcpkg
144
- if: startsWith(matrix.os, 'ubuntu')
145
- run: |
146
- sudo apt-get update
147
- sudo apt-get install gperf
122
+ test-build:
123
+ needs: [ build, cross-build ]
124
+ runs-on: ${{ matrix.os }}
125
+ strategy:
126
+ fail-fast: false
127
+ matrix:
128
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
129
+ ruby-version: [ '2.7', '3.0', '3.1' ]
148
130
 
149
- - name: Install native gem
150
- if: matrix.platform == 'any'
151
- run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
131
+ steps:
132
+ - uses: actions/checkout@v3
152
133
 
153
- - name: Install binary gem
154
- if: matrix.platform != 'any'
155
- run: gem install -b pkg/emf2svg-*-${{ matrix.platform }}.gem
134
+ - uses: ruby/setup-ruby@master
135
+ with:
136
+ ruby-version: ${{ matrix.ruby-version }}
137
+
138
+ - uses: actions/download-artifact@v3
139
+ with:
140
+ name: pkg
141
+ path: pkg
156
142
 
143
+ - name: Install binary gem
144
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION")-$(ruby -e "puts RUBY_PLATFORM.sub(/darwin\d{2}$/, 'darwin')").gem
145
+ # MacOS with have something like arm64-darwin19, others just aarch64-linux
157
146
  - name: Test conversion
158
147
  run: |
159
148
  ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
160
149
 
161
- cross:
162
- name: build ${{ matrix.os }}, ${{ matrix.ruby-version }}, ${{ matrix.platform }}
150
+ test-build-any:
151
+ needs: [ build, cross-build ]
163
152
  runs-on: ${{ matrix.os }}
164
153
  strategy:
165
154
  fail-fast: false
166
155
  matrix:
167
- include:
168
- - os: ubuntu-latest
169
- platform: aarch64-linux
170
- ruby-version: '2.7'
171
- file: 'ELF 64-bit LSB shared object, ARM aarch64'
172
- - os: macos-latest
173
- platform: arm64-darwin
174
- ruby-version: '2.7'
175
- file: 'Mach-O 64-bit dynamically linked shared library arm64'
156
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
157
+ ruby-version: [ '2.7', '3.0', '3.1' ]
158
+
176
159
  steps:
177
160
  - uses: actions/checkout@v3
178
161
 
179
- - name: Install packages
180
- if: matrix.os == 'ubuntu-latest'
181
- run: |
182
- sudo apt-get update
183
- sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
184
-
185
- - uses: ruby/setup-ruby@v1
162
+ - uses: ruby/setup-ruby@master
186
163
  with:
187
164
  ruby-version: ${{ matrix.ruby-version }}
188
- bundler-cache: true
189
165
 
190
- - run: bundle exec rake gem:native:${{ matrix.platform }}
191
-
192
- - uses: actions/upload-artifact@v2
166
+ - uses: actions/download-artifact@v3
193
167
  with:
194
168
  name: pkg
195
- path: pkg/*.gem
169
+ path: pkg
170
+
171
+ - name: Workaround for vcpkg
172
+ if: startsWith(matrix.os, 'ubuntu')
173
+ run: |
174
+ sudo apt-get update
175
+ sudo apt-get install gperf
196
176
 
197
- - name: Install gem
198
- run: gem install -b pkg/emf2svg-*.gem
177
+ - name: Install native gem
178
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
199
179
 
200
- - name: Check file format
201
- run: file $(ls pkg/*/lib/emf2svg/libemf2svg.*) | grep "${{ matrix.file }}"
180
+ - name: Test conversion
181
+ run: |
182
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
@@ -12,10 +12,10 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  include:
15
- - os: ubuntu-18.04
15
+ - os: ubuntu-latest
16
16
  platform: any
17
17
  ruby-version: '2.7'
18
- - os: ubuntu-18.04
18
+ - os: ubuntu-latest
19
19
  platform: x86_64-linux
20
20
  ruby-version: '2.7'
21
21
  - os: windows-latest
@@ -30,7 +30,7 @@ jobs:
30
30
  steps:
31
31
  - uses: actions/checkout@v3
32
32
 
33
- - uses: ruby/setup-ruby@v1
33
+ - uses: ruby/setup-ruby@master
34
34
  with:
35
35
  ruby-version: ${{ matrix.ruby-version }}
36
36
  bundler-cache: true
@@ -70,7 +70,7 @@ jobs:
70
70
  platform: arm64-darwin
71
71
  ruby-version: '2.7'
72
72
  steps:
73
- - uses: actions/checkout@v2
73
+ - uses: actions/checkout@v3
74
74
 
75
75
  - name: Install packages
76
76
  if: matrix.os == 'ubuntu-latest'
@@ -78,14 +78,14 @@ jobs:
78
78
  sudo apt-get update
79
79
  sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
80
80
 
81
- - uses: ruby/setup-ruby@v1
81
+ - uses: ruby/setup-ruby@master
82
82
  with:
83
83
  ruby-version: ${{ matrix.ruby-version }}
84
84
  bundler-cache: true
85
85
 
86
86
  - run: bundle exec rake gem:native:${{ matrix.platform }}
87
87
 
88
- - uses: actions/upload-artifact@v2
88
+ - uses: actions/upload-artifact@v3
89
89
  with:
90
90
  name: pkg
91
91
  path: pkg/*.gem
@@ -97,14 +97,14 @@ jobs:
97
97
  needs: [ build, cross ]
98
98
  runs-on: ubuntu-latest
99
99
  steps:
100
- - uses: actions/checkout@v2
100
+ - uses: actions/checkout@v3
101
101
 
102
- - uses: ruby/setup-ruby@v1
102
+ - uses: ruby/setup-ruby@master
103
103
  with:
104
104
  ruby-version: '2.7'
105
105
  bundler-cache: true
106
106
 
107
- - uses: actions/download-artifact@v2
107
+ - uses: actions/download-artifact@v3
108
108
  with:
109
109
  name: pkg
110
110
  path: pkg
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.vscode
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
data/.rubocop.yml CHANGED
@@ -2,8 +2,13 @@ inherit_from:
2
2
  - 'https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml'
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 2.7
6
6
  SuggestExtensions: false
7
+ Exclude:
8
+ - 'tmp/**/*'
9
+ - 'pkg/**/*'
10
+ - 'ports/**/*'
11
+ - 'vendor/**/*'
7
12
 
8
13
  Gemspec/RequireMFA:
9
14
  Enabled: false
data/README.adoc CHANGED
@@ -54,9 +54,13 @@ There are two ways to provide EMF data to `emf2svg`.
54
54
  ----
55
55
  require "emf2svg"
56
56
 
57
- data = Emf2svg.from_file("example.emf")
57
+ data = Emf2svg.from_file("example.emf", 800, 600)
58
58
  File.write("output.svg", data, mode: "wb")
59
59
  ----
60
+ 800, 600 - optional width and height of the bounding rectangle for svg file
61
+ The image will be scaled to fit into this rectangle
62
+ These parameters are optional. If skipped or set to 0 SVG image will have the
63
+ same size as EMF (in pixels)
60
64
  ====
61
65
 
62
66
  === Loading binary data
@@ -71,9 +75,13 @@ File.write("output.svg", data, mode: "wb")
71
75
  require "emf2svg"
72
76
 
73
77
  emf_content = File.read("example.emf", mode: "rb")
74
- svg_data = Emf2svg.from_binary_string(emf_content)
78
+ svg_data = Emf2svg.from_binary_string(emf_content, 800, 600)
75
79
  File.write("output.svg", svg_data, mode: "wb")
76
80
  ----
81
+ 800, 600 - optional width and height of the bounding rectangle for svg file
82
+ The image will be scaled to fit into this rectangle
83
+ These parameters are optional. If skipped or set to 0 SVG image will have the
84
+ same size as EMF (in pixels)
77
85
  ====
78
86
 
79
87
 
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ task default: %i[spec rubocop]
14
14
  task :compile do
15
15
  require_relative "ext/extconf"
16
16
  end
17
+
17
18
  task spec: :compile
18
19
 
19
20
  desc "Build install-compilation gem"
data/bin/emf2svg CHANGED
@@ -1,8 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
4
  require "emf2svg"
6
5
 
7
- svg = Emf2svg.from_file(ARGV[0])
8
- File.write(ARGV[1], svg, mode: "wb")
6
+ def print_usage
7
+ usage = %{Usage: emf2svg <input> <output> [<width>] [<height>]
8
+ <input> -- emf file to convert
9
+ <output> -- svg file to save
10
+ <width> -- svg image width, defaults to source width in px if not set or 0
11
+ <height> -- svg image height, defaults to source height in px if not set or 0
12
+ Note: width and height specify bounding rectangle, the image will be scaled
13
+ propotionally to fit into it.
14
+ }
15
+ puts usage
16
+ end
17
+
18
+ def tint(pos)
19
+ ARGV.size > pos ? Integer(ARGV[pos]) : 0
20
+ rescue ArgumentError, TypeError => e
21
+ puts "ERROR: Failed to convert #{ARGV[pos]} to integer: #{e.message}"
22
+ print_usage
23
+ exit 1
24
+ end
25
+
26
+ if ARGV.size < 2 || ARGV.size > 4 || ARGV[0].casecmp("help").zero?
27
+ print_usage
28
+ exit 0
29
+ end
30
+
31
+ begin
32
+ svg = Emf2svg.from_file(ARGV[0], tint(2), tint(3))
33
+ File.write(ARGV[1], svg, mode: "wb")
34
+ rescue StandardError => e
35
+ puts "ERROR: Failed to process #{ARGV[0]}: #{e.message}"
36
+ print_usage
37
+ exit 1
38
+ end
data/emf2svg.gemspec CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Ribose"]
9
9
  spec.email = ["open.source@ribose.com"]
10
10
 
11
- spec.summary = "Ruby interface to libemf2svg."
11
+ spec.summary = "EMF to SVG conversion in Ruby."
12
12
  spec.homepage = "https://github.com/metanorma/emf2svg-ruby"
13
13
  spec.license = "BSD-2-Clause"
14
- spec.required_ruby_version = ">= 2.6.0"
14
+ spec.required_ruby_version = ">= 2.7.0"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/metanorma/emf2svg-ruby"
data/exe/emf2svg CHANGED
@@ -3,5 +3,36 @@
3
3
 
4
4
  require "emf2svg"
5
5
 
6
- svg = Emf2svg.from_file(ARGV[0])
7
- File.write(ARGV[1], svg, mode: "wb")
6
+ def print_usage
7
+ usage = %{Usage: emf2svg <input> <output> [<width>] [<height>]
8
+ <input> -- emf file to convert
9
+ <output> -- svg file to save
10
+ <width> -- svg image width, defaults to source width in px if not set or 0
11
+ <height> -- svg image height, defaults to source height in px if not set or 0
12
+ Note: width and height specify bounding rectangle, the image will be scaled
13
+ propotionally to fit into it.
14
+ }
15
+ puts usage
16
+ end
17
+
18
+ def tint(pos)
19
+ ARGV.size > pos ? Integer(ARGV[pos]) : 0
20
+ rescue ArgumentError, TypeError => e
21
+ puts "ERROR: Failed to convert #{ARGV[pos]} to integer: #{e.message}"
22
+ print_usage
23
+ exit 1
24
+ end
25
+
26
+ if ARGV.size < 2 || ARGV.size > 4 || ARGV[0].casecmp("help").zero?
27
+ print_usage
28
+ exit 0
29
+ end
30
+
31
+ begin
32
+ svg = Emf2svg.from_file(ARGV[0], tint(2), tint(3))
33
+ File.write(ARGV[1], svg, mode: "wb")
34
+ rescue StandardError => e
35
+ puts "ERROR: Failed to process #{ARGV[0]}: #{e.message}"
36
+ print_usage
37
+ exit 1
38
+ end
Binary file
@@ -2,17 +2,19 @@ require "rbconfig"
2
2
  require "mini_portile2"
3
3
  require "pathname"
4
4
  require "tmpdir"
5
+ require "open3"
6
+ require_relative "version"
5
7
 
6
8
  module Emf2svg
7
9
  class Recipe < MiniPortileCMake
8
10
  ROOT = Pathname.new(File.expand_path("../..", __dir__))
9
11
 
10
12
  def initialize
11
- super("libemf2svg", "1.7.0")
13
+ super("libemf2svg", LIBEMF2SVG_VERSION)
12
14
 
13
15
  @files << {
14
- url: "https://github.com/metanorma/libemf2svg/releases/download/v1.7.0/libemf2svg.tar.gz",
15
- sha256: "a87a02510f87ed4510a3426fa8636b340e26d96f25edf63c3ba465e7e9d7e2eb", # rubocop:disable Layout/LineLength
16
+ url: "https://github.com/metanorma/libemf2svg/releases/download/v#{LIBEMF2SVG_VERSION}/libemf2svg.tar.gz",
17
+ sha256: "c65f25040a351d18beb5172609a55d034245f85a1152d7f294780c6cc155d876", # rubocop:disable Layout/LineLength
16
18
  }
17
19
 
18
20
  @target = ROOT.join(@target).to_s
@@ -28,58 +30,6 @@ module Emf2svg
28
30
  FileUtils.touch(checkpoint)
29
31
  end
30
32
 
31
- # rubocop:disable Metrics/MethodLength
32
- # rubocop:disable Metrics/CyclomaticComplexity
33
- def host_platform
34
- @host_platform ||=
35
- case @host
36
- when /\Ax86_64.*mingw32/
37
- "x64-mingw32"
38
- when /\Ax86_64.*linux/
39
- "x86_64-linux"
40
- when /\A(arm64|aarch64).*linux/
41
- "arm64-linux"
42
- when /\Ax86_64.*(darwin|macos|osx)/
43
- "x86_64-darwin"
44
- when /\A(arm64|aarch64).*(darwin|macos|osx)/
45
- "arm64-darwin"
46
- else
47
- @host
48
- end
49
- end
50
-
51
- def target_platform
52
- @target_platform ||=
53
- case ENV["target_platform"]
54
- when /\A(arm64|aarch64).*(darwin|macos|osx)/
55
- "arm64-darwin"
56
- when /\Ax86_64.*(darwin|macos|osx)/
57
- "x86_64-darwin"
58
- when /\A(arm64|aarch64).*linux/
59
- "aarch64-linux"
60
- else
61
- ENV["target_platform"] || host_platform
62
- end
63
- end
64
-
65
- def target_triplet
66
- @target_triplet ||=
67
- case target_platform
68
- when "arm64-darwin"
69
- "arm64-osx"
70
- when "x86_64-darwin"
71
- "x64-osx"
72
- when "aarch64-linux"
73
- "arm64-linux"
74
- when "x86_64-linux"
75
- "x64-linux"
76
- when /\Ax64-mingw(32|-ucrt)/
77
- "x64-mingw-static"
78
- end
79
- end
80
- # rubocop:enable Metrics/CyclomaticComplexity
81
- # rubocop:enable Metrics/MethodLength
82
-
83
33
  def windows_native?
84
34
  MiniPortile.windows? && target_triplet.eql?("x64-mingw-static")
85
35
  end
@@ -115,20 +65,42 @@ module Emf2svg
115
65
  "cmake --build #{File.expand_path(work_path)} --config Release"
116
66
  end
117
67
 
68
+ def lb_to_verify
69
+ pt = if MiniPortile.windows?
70
+ "emf2svg.dll"
71
+ else
72
+ "libemf2svg.{so,dylib}"
73
+ end
74
+ @lb_to_verify ||= Dir.glob(ROOT.join("lib", "emf2svg", pt))
75
+ end
76
+
77
+ def verify_libs
78
+ lb_to_verify.each do |l|
79
+ out, st = Open3.capture2("file #{l}")
80
+ raise "Failed to query file #{l}: #{out}" unless st.exitstatus.zero?
81
+
82
+ if out.include?(target_format)
83
+ message("Verifying #{l} ... OK\n")
84
+ else
85
+ raise "Invalid file format '#{out}', '#{@target_format}' expected"
86
+ end
87
+ end
88
+ end
89
+
118
90
  def install
119
- message("Called install\n")
120
91
  libs = if MiniPortile.windows?
121
92
  Dir.glob(File.join(work_path, "Release", "*.dll"))
122
93
  else
123
94
  Dir.glob(File.join(work_path, "libemf2svg.{so,dylib}"))
124
95
  .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib)$/)
125
96
  end
126
-
127
97
  FileUtils.cp_r(libs, ROOT.join("lib", "emf2svg"), verbose: true)
98
+
99
+ verify_libs unless target_format.eql?("skip")
128
100
  end
129
101
 
130
102
  def execute(action, command, command_opts = {})
131
- super(action, command, command_opts.merge(debug: true))
103
+ super(action, command, command_opts.merge(debug: false))
132
104
  end
133
105
 
134
106
  def message(text)
@@ -151,5 +123,75 @@ module Emf2svg
151
123
  def port_path
152
124
  "port"
153
125
  end
126
+
127
+ # rubocop:disable Metrics/MethodLength
128
+ # rubocop:disable Metrics/CyclomaticComplexity
129
+ def host_platform
130
+ @host_platform ||=
131
+ case @host
132
+ when /\Ax86_64.*mingw32/
133
+ "x64-mingw32"
134
+ when /\Ax86_64.*linux/
135
+ "x86_64-linux"
136
+ when /\A(arm64|aarch64).*linux/
137
+ "arm64-linux"
138
+ when /\Ax86_64.*(darwin|macos|osx)/
139
+ "x86_64-darwin"
140
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
141
+ "arm64-darwin"
142
+ else
143
+ @host
144
+ end
145
+ end
146
+
147
+ def target_platform
148
+ @target_platform ||=
149
+ case ENV.fetch("target_platform", nil)
150
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
151
+ "arm64-darwin"
152
+ when /\Ax86_64.*(darwin|macos|osx)/
153
+ "x86_64-darwin"
154
+ when /\A(arm64|aarch64).*linux/
155
+ "aarch64-linux"
156
+ else
157
+ ENV.fetch("target_platform", host_platform)
158
+ end
159
+ end
160
+
161
+ def target_triplet
162
+ @target_triplet ||=
163
+ case target_platform
164
+ when "arm64-darwin"
165
+ "arm64-osx"
166
+ when "x86_64-darwin"
167
+ "x64-osx"
168
+ when "aarch64-linux"
169
+ "arm64-linux"
170
+ when "x86_64-linux"
171
+ "x64-linux"
172
+ when /\Ax64-mingw(32|-ucrt)/
173
+ "x64-mingw-static"
174
+ end
175
+ end
176
+
177
+ def target_format
178
+ @target_format ||=
179
+ case target_platform
180
+ when "arm64-darwin"
181
+ "Mach-O 64-bit dynamically linked shared library arm64"
182
+ when "x86_64-darwin"
183
+ "Mach-O 64-bit dynamically linked shared library x86_64"
184
+ when "aarch64-linux"
185
+ "ELF 64-bit LSB shared object, ARM aarch64"
186
+ when "x86_64-linux"
187
+ "ELF 64-bit LSB shared object, x86-64"
188
+ when /\Ax64-mingw(32|-ucrt)/
189
+ "PE32+ executable (DLL) (console) x86-64, for MS Windows"
190
+ else
191
+ "skip"
192
+ end
193
+ end
194
+ # rubocop:enable Metrics/CyclomaticComplexity
195
+ # rubocop:enable Metrics/MethodLength
154
196
  end
155
197
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emf2svg
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.3"
5
+ LIBEMF2SVG_VERSION = "1.7.1"
5
6
  end
data/lib/emf2svg.rb CHANGED
@@ -39,17 +39,18 @@ module Emf2svg
39
39
  :int
40
40
 
41
41
  class << self
42
- def from_file(path)
42
+ def from_file(path, width = 0, height = 0)
43
43
  content = File.read(path, mode: "rb")
44
- from_binary_string(content)
44
+ from_binary_string(content, width, height)
45
45
  end
46
46
 
47
- def from_binary_string(content)
47
+ def from_binary_string(content, width = 0, height = 0)
48
48
  svg_out = FFI::MemoryPointer.new(:pointer)
49
49
  svg_out_len = FFI::MemoryPointer.new(:pointer)
50
50
  content_ptr = FFI::MemoryPointer.from_string(content)
51
51
 
52
- ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, options)
52
+ opt = options(width, height)
53
+ ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, opt)
53
54
  raise Error, "emf2svg failed with error code: #{ret}" unless ret == 1
54
55
 
55
56
  svg_out.read_pointer.read_bytes(svg_out_len.read_int)
@@ -57,13 +58,13 @@ module Emf2svg
57
58
 
58
59
  private
59
60
 
60
- def options
61
+ def options(width, height)
61
62
  GeneratorOptions.new.tap do |opts|
62
63
  opts[:verbose] = false
63
64
  opts[:emfplus] = true
64
65
  opts[:svgDelimiter] = true
65
- opts[:imgHeight] = 0
66
- opts[:imgWidth] = 0
66
+ opts[:imgHeight] = height
67
+ opts[:imgWidth] = width
67
68
  end
68
69
  end
69
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emf2svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-13 00:00:00.000000000 Z
11
+ date: 2022-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 2.6.0
112
+ version: 2.7.0
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -119,5 +119,5 @@ requirements: []
119
119
  rubygems_version: 3.1.6
120
120
  signing_key:
121
121
  specification_version: 4
122
- summary: Ruby interface to libemf2svg.
122
+ summary: EMF to SVG conversion in Ruby.
123
123
  test_files: []