commit
0f503fabde
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018-2021 Max Brunsfeld
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -0,0 +1,110 @@
|
|||||||
|
From 801d1f702ff46ee7f0219d9c9ac427f22e1a9a9a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aleksei Bavshin <alebastr89@gmail.com>
|
||||||
|
Date: Sun, 5 Dec 2021 16:08:59 -0800
|
||||||
|
Subject: [PATCH] binding_rust: generate bindings during build
|
||||||
|
|
||||||
|
Bindgen output is platform- and architecture-dependent. Pre-generated
|
||||||
|
bindings may cause issues on the machines different from the one used
|
||||||
|
for generating the code.
|
||||||
|
|
||||||
|
The recommended way[1] to use bindgen is to invoke it from `build.rs`.
|
||||||
|
|
||||||
|
[1]: https://rust-lang.github.io/rust-bindgen/library-usage.html
|
||||||
|
---
|
||||||
|
lib/Cargo.toml | 1 +
|
||||||
|
lib/binding_rust/build.rs | 24 ++++++++++++++++++++++++
|
||||||
|
lib/binding_rust/ffi.rs | 2 +-
|
||||||
|
lib/binding_rust/lib.rs | 5 +++--
|
||||||
|
4 files changed, 29 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/Cargo.toml b/Cargo.toml
|
||||||
|
index d096efdc..c318cd34 100644
|
||||||
|
--- a/Cargo.toml
|
||||||
|
+++ b/Cargo.toml
|
||||||
|
@@ -46,5 +46,8 @@
|
||||||
|
[dependencies.regex]
|
||||||
|
version = "1"
|
||||||
|
|
||||||
|
+[build-dependencies.bindgen]
|
||||||
|
+version = "0.59.1"
|
||||||
|
+
|
||||||
|
[build-dependencies.cc]
|
||||||
|
version = "^1.0.58"
|
||||||
|
diff --git a/binding_rust/build.rs b/binding_rust/build.rs
|
||||||
|
index 5798cde3..34736b53 100644
|
||||||
|
--- a/binding_rust/build.rs
|
||||||
|
+++ b/binding_rust/build.rs
|
||||||
|
@@ -1,6 +1,28 @@
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::{env, fs};
|
||||||
|
|
||||||
|
+fn generate_bindings() {
|
||||||
|
+ const HEADER_FILE: &'static str = "include/tree_sitter/api.h";
|
||||||
|
+
|
||||||
|
+ println!("cargo:rerun-if-changed={}", HEADER_FILE);
|
||||||
|
+ let bindings = bindgen::Builder::default()
|
||||||
|
+ .header(HEADER_FILE)
|
||||||
|
+ .layout_tests(false)
|
||||||
|
+ .allowlist_type("^TS.*")
|
||||||
|
+ .allowlist_function("^ts_.*")
|
||||||
|
+ .allowlist_var("^TREE_SITTER.*")
|
||||||
|
+ .blocklist_function("ts_tree_print_dot_graph")
|
||||||
|
+ .opaque_type("FILE")
|
||||||
|
+ .size_t_is_usize(true)
|
||||||
|
+ .generate()
|
||||||
|
+ .expect("Unable to generate bindings");
|
||||||
|
+
|
||||||
|
+ let output = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
+ bindings
|
||||||
|
+ .write_to_file(output.join("bindings.rs"))
|
||||||
|
+ .expect("Unable to write bindings");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=TREE_SITTER_STATIC_ANALYSIS");
|
||||||
|
if env::var("TREE_SITTER_STATIC_ANALYSIS").is_ok() {
|
||||||
|
@@ -17,6 +39,8 @@ fn main() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ generate_bindings();
|
||||||
|
+
|
||||||
|
let src_path = Path::new("src");
|
||||||
|
for entry in fs::read_dir(&src_path).unwrap() {
|
||||||
|
let entry = entry.unwrap();
|
||||||
|
diff --git a/binding_rust/ffi.rs b/binding_rust/ffi.rs
|
||||||
|
index 685ed765..5cf93180 100644
|
||||||
|
--- a/binding_rust/ffi.rs
|
||||||
|
+++ b/binding_rust/ffi.rs
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
#![allow(non_upper_case_globals)]
|
||||||
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
|
-include!("./bindings.rs");
|
||||||
|
+include!(concat!(env!("OUT_DIR"),"/bindings.rs"));
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
pub(crate) fn dup(fd: std::os::raw::c_int) -> std::os::raw::c_int;
|
||||||
|
diff --git a/binding_rust/lib.rs b/binding_rust/lib.rs
|
||||||
|
index 934915fe..44417c77 100644
|
||||||
|
--- a/binding_rust/lib.rs
|
||||||
|
+++ b/binding_rust/lib.rs
|
||||||
|
@@ -26,12 +26,13 @@ use std::{
|
||||||
|
/// The Tree-sitter library is generally backwards-compatible with languages
|
||||||
|
/// generated using older CLI versions, but is not forwards-compatible.
|
||||||
|
#[doc(alias = "TREE_SITTER_LANGUAGE_VERSION")]
|
||||||
|
-pub const LANGUAGE_VERSION: usize = ffi::TREE_SITTER_LANGUAGE_VERSION;
|
||||||
|
+pub const LANGUAGE_VERSION: usize = ffi::TREE_SITTER_LANGUAGE_VERSION as usize;
|
||||||
|
|
||||||
|
/// The earliest ABI version that is supported by the current version of the
|
||||||
|
/// library.
|
||||||
|
#[doc(alias = "TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION")]
|
||||||
|
-pub const MIN_COMPATIBLE_LANGUAGE_VERSION: usize = ffi::TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION;
|
||||||
|
+pub const MIN_COMPATIBLE_LANGUAGE_VERSION: usize =
|
||||||
|
+ ffi::TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION as usize;
|
||||||
|
|
||||||
|
pub const PARSER_HEADER: &'static str = include_str!("../include/tree_sitter/parser.h");
|
||||||
|
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
Binary file not shown.
@ -0,0 +1,123 @@
|
|||||||
|
## START: Set by rpmautospec
|
||||||
|
## (rpmautospec version 0.3.0)
|
||||||
|
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
|
||||||
|
release_number = 1;
|
||||||
|
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
|
||||||
|
print(release_number + base_release_number - 1);
|
||||||
|
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
|
||||||
|
## END: Set by rpmautospec
|
||||||
|
|
||||||
|
# Generated by rust2rpm 22
|
||||||
|
%bcond_without check
|
||||||
|
%global debug_package %{nil}
|
||||||
|
|
||||||
|
%global crate tree-sitter
|
||||||
|
# The bindings version does not match the C library version.
|
||||||
|
%global ts_ver 0.20.7
|
||||||
|
|
||||||
|
Name: rust-tree-sitter
|
||||||
|
Version: 0.20.9
|
||||||
|
Release: %autorelease
|
||||||
|
Summary: Rust bindings to the Tree-sitter parsing library
|
||||||
|
|
||||||
|
# Upstream license specification: MIT
|
||||||
|
# Bundled ICU sources: Unicode
|
||||||
|
License: MIT and Unicode
|
||||||
|
URL: https://crates.io/crates/tree-sitter
|
||||||
|
Source: %{crates_source}
|
||||||
|
# Upstream license file - tree-sitter/tree-sitter#1520
|
||||||
|
Source1: https://github.com/tree-sitter/tree-sitter/raw/v%{ts_ver}/LICENSE#/LICENSE.upstream
|
||||||
|
# tree-sitter/tree-sitter#1524 modified to apply to the crate source
|
||||||
|
Patch0: binding_rust-regenerate-bindings-during-build.patch
|
||||||
|
|
||||||
|
ExclusiveArch: %{rust_arches}
|
||||||
|
|
||||||
|
BuildRequires: rust-packaging >= 21
|
||||||
|
|
||||||
|
%global _description %{expand:
|
||||||
|
Rust bindings to the Tree-sitter parsing library.}
|
||||||
|
|
||||||
|
%description %{_description}
|
||||||
|
|
||||||
|
%package devel
|
||||||
|
Summary: %{summary}
|
||||||
|
BuildArch: noarch
|
||||||
|
# The create contains a bundled copy of the tree-sitter C library.
|
||||||
|
Provides: bundled(tree-sitter) = %{ts_ver}
|
||||||
|
# The tree-sitter C library contains a small subset of files from the ICU library
|
||||||
|
Provides: bundled(icu) = 65.1
|
||||||
|
|
||||||
|
%description devel %{_description}
|
||||||
|
|
||||||
|
This package contains library source intended for building other packages which
|
||||||
|
use the "%{crate}" crate.
|
||||||
|
|
||||||
|
%files devel
|
||||||
|
%license %{crate_instdir}/LICENSE
|
||||||
|
%license %{crate_instdir}/src/unicode/LICENSE
|
||||||
|
%{crate_instdir}/
|
||||||
|
|
||||||
|
%package -n %{name}+default-devel
|
||||||
|
Summary: %{summary}
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description -n %{name}+default-devel %{_description}
|
||||||
|
|
||||||
|
This package contains library source intended for building other packages which
|
||||||
|
use the "default" feature of the "%{crate}" crate.
|
||||||
|
|
||||||
|
%files -n %{name}+default-devel
|
||||||
|
%ghost %{crate_instdir}/Cargo.toml
|
||||||
|
|
||||||
|
%package -n %{name}+lazy_static-devel
|
||||||
|
Summary: %{summary}
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description -n %{name}+lazy_static-devel %{_description}
|
||||||
|
|
||||||
|
This package contains library source intended for building other packages which
|
||||||
|
use the "lazy_static" feature of the "%{crate}" crate.
|
||||||
|
|
||||||
|
%files -n %{name}+lazy_static-devel
|
||||||
|
%ghost %{crate_instdir}/Cargo.toml
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%autosetup -n %{crate}-%{version_no_tilde} -p1
|
||||||
|
%cargo_prep
|
||||||
|
# drop pre-generated bindings; we don't want to accidentally use these
|
||||||
|
rm -f binding_rust/bindings.rs
|
||||||
|
|
||||||
|
%generate_buildrequires
|
||||||
|
%cargo_generate_buildrequires
|
||||||
|
|
||||||
|
%build
|
||||||
|
%cargo_build
|
||||||
|
|
||||||
|
%install
|
||||||
|
%cargo_install
|
||||||
|
# prepare upstream license file for %%license
|
||||||
|
install -D -m 0644 -pv %{SOURCE1} %{buildroot}%{crate_instdir}/LICENSE
|
||||||
|
|
||||||
|
%if %{with check}
|
||||||
|
%check
|
||||||
|
%cargo_test
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Jan 15 2024 Arkady L. Shane <tigro@msvsphere-os.ru> - 0.20.9-1
|
||||||
|
- Rebuilt for MSVSphere 9.3
|
||||||
|
|
||||||
|
* Mon Sep 05 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.9-1
|
||||||
|
- Update to 0.20.9 (#2100278)
|
||||||
|
|
||||||
|
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> 0.20.6-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Apr 01 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.6-1
|
||||||
|
- Update to 0.20.6
|
||||||
|
|
||||||
|
* Wed Mar 23 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.2-2
|
||||||
|
- Add patch to address test failures on s390x
|
||||||
|
|
||||||
|
* Fri Feb 25 2022 Aleksei Bavshin <alebastr@fedoraproject.org> 0.20.2-1
|
||||||
|
- Initial import (#2028895)
|
Loading…
Reference in new issue