Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
rustler precompiled
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Feb 5, 2025
1 parent a44a852 commit 0b36b96
Show file tree
Hide file tree
Showing 11 changed files with 691 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
otp: 27.2
lint: lint

env:
MAKEUP_SYNTECT_BUILD: 1

steps:
- uses: actions/checkout@v4
- name: Set up Elixir
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
# Build job
build:
runs-on: ubuntu-latest

env:
MAKEUP_SYNTECT_BUILD: 1

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/precompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build precompiled NIFs

on:
push:
branches:
# Always run on main branch.
- main
tags:
- '*'
workflow_dispatch:


jobs:
build_release:
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
nif: ["2.15"]
job:
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-apple-darwin , os: macos-15 }
- { target: riscv64gc-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
- { target: x86_64-apple-darwin , os: macos-15 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
- { target: x86_64-pc-windows-gnu , os: windows-2022 }
- { target: x86_64-pc-windows-msvc , os: windows-2022 }

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Extract project version
shell: bash
run: |
# Get the project version from mix.exs
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.job.target }}

- name: Build the project
id: build-crate
uses: philss/[email protected]
with:
project-name: makeup_syntect
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.job.target }}
nif-version: ${{ matrix.nif }}
use-cross: ${{ matrix.job.use-cross }}
project-dir: "native/makeup_syntect"

- name: Artifact upload
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}

- name: Publish archives and packages
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.build-crate.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/')
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml

This file was deleted.

10 changes: 9 additions & 1 deletion lib/makeup_syntect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ defmodule MakeupSyntect do
For a list of supported langugages, see: `MakeupSyntect.Syntaxes`.
"""

use Rustler, otp_app: :makeup_syntect, crate: "makeup_syntect"
version = Mix.Project.config()[:version]

use RustlerPrecompiled,
otp_app: :makeup_syntect,
crate: "makeup_syntect",
base_url:
"https://github.com/SteffenDE/makeup_syntect/releases/download/v#{version}",
force_build: System.get_env("MAKEUP_SYNTECT_BUILD") in ["1", "true"],
version: version

@syntax_set_key :makeup_syntect_syntax_set

Expand Down
29 changes: 27 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ defmodule MakeupSyntect.MixProject do
main: "readme",
extras: Path.wildcard("examples/*.md") ++ ["README.md"],
source_url: "https://github.com/SteffenDE/makeup_syntect"
]
],
package: package(),
description: description(),
source_url: "https://github.com/SteffenDE/makeup_syntect"
]
end

Expand All @@ -31,9 +34,31 @@ defmodule MakeupSyntect.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:rustler, "~> 0.36.1", runtime: false},
{:rustler_precompiled, "~> 0.8.2"},
{:rustler, "~> 0.36.1", runtime: false, optional: true},
{:makeup, "~> 1.2"},
{:ex_doc, "~> 0.34", only: :docs, runtime: false}
]
end

defp description() do
"Language lexers for Makeup using the syntect Rust library"
end

defp package() do
[
files: [
"lib",
"priv/extra_syntaxes",
"README.md",
"LICENSE",
"native/makeup_syntect/src",
"native/makeup_syntect/*.toml",
"checksum-*.exs",
"mix.exs"
],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/SteffenDE/makeup_syntect"}
]
end
end
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%{
"castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"},
"earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"},
"ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
Expand All @@ -7,5 +8,6 @@
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"rustler": {:hex, :rustler, "0.36.1", "2d4b1ff57ea2789a44756a40dbb5fbb73c6ee0a13d031dcba96d0a5542598a6a", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.7", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "f3fba4ad272970e0d1bc62972fc4a99809651e54a125c5242de9bad4574b2d02"},
"rustler_precompiled": {:hex, :rustler_precompiled, "0.8.2", "5f25cbe220a8fac3e7ad62e6f950fcdca5a5a5f8501835d2823e8c74bf4268d5", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "63d1bd5f8e23096d1ff851839923162096364bac8656a4a3c00d1fff8e83ee0a"},
"toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"},
}
Loading

0 comments on commit 0b36b96

Please sign in to comment.