Skip to content

Commit

Permalink
(#3791) Adding package with lib tree-sitter, version 0.17.3
Browse files Browse the repository at this point in the history
* add main config

* add version folder

* add test package

* add version configs

* fix build errors with hooks

* fix automatic build system errors

* fix automatic build system errors 2

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* simplifu test app

* Improve ReSIProcate recipe

Signed-off-by: Uilian Ries <[email protected]>

* fix build

* fix build 2

* simplify pathes

* Dummy commit to rerun build

* add prefix to autotool

* add prefix to autotool

* fix errors in test app

* remove fpic for mac and windows

* fix msys

* fix msys

* fix msys

* change msysy2 condition

* try to fix vs 15 build

* try to fix vs buld

* try to fix vs buld

* fix build

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Chris Mc <[email protected]>

* Update recipes/resiprocate/all/test_package/CMakeLists.txt

Co-authored-by: Uilian Ries <[email protected]>

* Update recipes/resiprocate/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* fix build

* add tree-sitter lib

* simplify package

* add msys2

* fix win build

* disable windows and mac build

* return missed import

* dummy, to init build

* dummy commit, to init build

* add fpic and share options

* fix comments

* fix comments2

* fix comments3

* fix comments4

* fix build

* apply suggest

* optimization

* run build

* Update recipes/tree-sitter/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

Co-authored-by: Chris Mc <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2020
1 parent b6075ce commit 40b28fa
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/tree-sitter/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.17.3":
url: https://github.com/tree-sitter/tree-sitter/archive/0.17.3.tar.gz
sha256: a897e5c9a7ccb74271d9b20d59121d2d2e9de8b896c4d1cfaac0f8104c1ef9f8
65 changes: 65 additions & 0 deletions recipes/tree-sitter/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import os
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import shutil

required_conan_version = ">=1.29.1"

class TreeSitterConan(ConanFile):
name = "tree-sitter"
description = "Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited."
topics = ("parser", "incremental", "rust")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://tree-sitter.github.io/tree-sitter"
license = "MIT"
settings = "os", "compiler", "build_type", "arch"
options = {"fPIC": [True, False],
"shared": [True, False]}
default_options = {"fPIC": True,
"shared": False}
_autotools = None


@property
def _source_subfolder(self):
return "source_subfolder"

def configure(self):
if self.settings.os == "Windows":
raise ConanInvalidConfiguration("tree-sitter is not support on {}.".format(self.settings.os))

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)

def _configure_autotools(self):
if not self._autotools:
self._autotools = AutoToolsBuildEnvironment(self)

return self._autotools

def build(self):
autotools = self._configure_autotools()

with tools.chdir(self._source_subfolder):
autotools.make()

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")

autotools = self._configure_autotools()
with tools.chdir(self._source_subfolder):
autotools.install(args=["PREFIX={}".format(self.package_folder)])

if self.options.shared:
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a")
else:
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so*")
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dylib*")

tools.rmdir(os.path.join(self.package_folder, os.path.join("lib", "pkgconfig")))


def package_info(self):
self.cpp_info.names["pkg_config"] = "tree-sitter"
self.cpp_info.libs = ["tree-sitter"]
8 changes: 8 additions & 0 deletions recipes/tree-sitter/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/tree-sitter/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
11 changes: 11 additions & 0 deletions recipes/tree-sitter/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <tree_sitter/api.h>
#include <stdio.h>

//More datailed example search at https://tree-sitter.github.io/tree-sitter/using-parsers#getting-started
int main() {
TSParser *parser = ts_parser_new();
ts_parser_delete(parser);
printf( "Test package\n" );
return 0;
}

3 changes: 3 additions & 0 deletions recipes/tree-sitter/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.17.3":
folder: all

0 comments on commit 40b28fa

Please sign in to comment.