diff --git a/.github/workflows/main.yml b/.github/workflows/build.yml similarity index 95% rename from .github/workflows/main.yml rename to .github/workflows/build.yml index 243d7c12..7c2e1b40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,10 @@ -name: main +name: build on: push: branches: [ main ] + paths-ignore: + - '*.adoc' pull_request: workflow_dispatch: @@ -57,15 +59,13 @@ jobs: platform: x86_64-darwin ruby-version: '2.7' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true -# https://github.com/microsoft/vcpkg/issues/15931 -# no good solution :( - name: Workaround for vcpkg if: startsWith(matrix.os, 'ubuntu') run: | @@ -130,8 +130,6 @@ jobs: name: pkg path: pkg -# https://github.com/microsoft/vcpkg/issues/15931 -# no good solution :( - name: Workaround for vcpkg if: startsWith(matrix.os, 'ubuntu') run: | @@ -162,7 +160,7 @@ jobs: platform: arm64-darwin ruby-version: '2.7' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bff2b19c..dd5e665e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: platform: x86_64-darwin ruby-version: '2.7' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: @@ -46,7 +46,7 @@ jobs: - run: bundle exec rake gem:native:${{ matrix.platform }} - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: pkg path: pkg/*.gem diff --git a/.rubocop.yml b/.rubocop.yml index 9d7845fb..680e3e92 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ inherit_from: - 'https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml' AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 SuggestExtensions: false Gemspec/RequireMFA: diff --git a/README.adoc b/README.adoc index b510aa71..e2a52924 100644 --- a/README.adoc +++ b/README.adoc @@ -1,13 +1,18 @@ -= emf2svg +image:https://github.com/metanorma/emf2svg-ruby/actions/workflows/build.yml/badge.svg["Build", link="https://github.com/metanorma/emf2svg-ruby/actions/workflows/build.yml"] +image:https://badge.fury.io/rb/emf2svg.svg["Gem Version", link="https://badge.fury.io/rb/emf2svg"] + -== Purpose += emf2svg -Provides Ruby access to https://github.com/kakwa/libemf2svg (temporarily using +== Overview +emf2svg-ruby provides Ruby front-end to emf to svg converter https://github.com/kakwa/libemf2svg (temporarily using the https://github.com/metanorma/libemf2svg[Metanorma fork] until upstreaming is complete). -== Installation +== Requirements: +Ruby >= 2.6 +== Installation Install the gem directly: [source,sh] @@ -22,19 +27,28 @@ Or add it to your `Gemfile`: gem 'emf2svg' ---- -=== Dependencies +=== Packaging +We distribute pre-compiled libraries for a set of machine architecture. On supported platforms, this removes the need +for compiling the C extension and installation of system dependencies. This results in much faster and more reliable installation. + +==== Native extensions +* x86_64-linux (GNU and musl flavors) +* aarch64-linux (GNU and musl flavors) +* x86_64-darwin +* arm64-darwin +* x64-mingw32 +* x64-mingw-ucrt -* libiconv -* libpng -* libfontconfig -* libfreetype +=== Building GEM from source +emf2svg build script maintaince and installs all required libraries and other dependencies using vcpkg package manager +You still need to install appropriate build system (like gcc, clang or Visual Studio) and cmake +On Debian systems there is vcpkg bug [https://github.com/microsoft/vcpkg/issues/15931] that needs to be addressed by installing gperf package: ==== Windows On Windows all necessary libraries are precompiled but you'll need Visual Studio 2019 with C++ Build Tools, which can be downloaded -https://visualstudio.microsoft.com/downloads/[here], or installed with -Chocolatey: +https://visualstudio.microsoft.com/downloads/[here], or installed with Chocolatey: [source,sh] ---- @@ -55,22 +69,16 @@ brew install cmake [source,sh] ---- # compiler -apt-get install gcc g++ +apt-get install gcc g++ gperf cmake pkg-config # or -apt-get install clang - -# build deps -apt-get install cmake pkg-config - -# library deps with their headers -apt-get install libpng-dev libc6-dev libfontconfig1-dev libfreetype6-dev zlib1g-dev +apt-get install clang gperf cmake pkg-config ---- ===== Fedora [source,sh] ---- -yum install cmake libpng-devel freetype-devel fontconfig-devel gcc-c++ gcc +yum install cmake gcc-c++ gcc ---- == Usage diff --git a/emf2svg.gemspec b/emf2svg.gemspec index adb68b0f..91a1529b 100644 --- a/emf2svg.gemspec +++ b/emf2svg.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.summary = "Ruby interface to libemf2svg." spec.homepage = "https://github.com/metanorma/emf2svg-ruby" spec.license = "BSD-2-Clause" - spec.required_ruby_version = ">= 2.5.0" + spec.required_ruby_version = ">= 2.6.0" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://github.com/metanorma/emf2svg-ruby" diff --git a/lib/emf2svg/recipe.rb b/lib/emf2svg/recipe.rb index 98b82501..6bee328e 100644 --- a/lib/emf2svg/recipe.rb +++ b/lib/emf2svg/recipe.rb @@ -35,14 +35,10 @@ def host_platform case @host when /\Ax86_64.*mingw32/ "x64-mingw32" - when /\Ai[3-6]86.*mingw32/ - "x86-mingw32" when /\Ax86_64.*linux/ "x86_64-linux" when /\A(arm64|aarch64).*linux/ "arm64-linux" - when /\Ai[3-6]86.*linux/ - "x86-linux" when /\Ax86_64.*(darwin|macos|osx)/ "x86_64-darwin" when /\A(arm64|aarch64).*(darwin|macos|osx)/ @@ -79,13 +75,19 @@ def target_triplet "x64-linux" when /\Ax64-mingw(32|-ucrt)/ "x64-mingw-static" - else - nil end end # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/MethodLength + def windows_native? + MiniPortile.windows? && target_triplet.eql?("x64-mingw-static") + end + + def drop_target_triplet? + windows_native? || host_platform.eql?(target_platform) + end + def checkpoint File.join(@target, "#{name}-#{version}-#{target_platform}.installed") end @@ -96,7 +98,7 @@ def configure_defaults opts << "-DCMAKE_BUILD_TYPE=Release" opts << "-DLONLY=ON" - unless target_triplet.nil? "unknown" or host_platform.eql? target_platform + unless target_triplet.nil? || drop_target_triplet? opts << " -DVCPKG_TARGET_TRIPLET=#{target_triplet}" end