<commit_before>"""Conan receipt package for USB Library 1.0.21
"""
import shutil
import tempfile
import os
from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools


class LibUSBConan(ConanFile):
    """Download libusb source, build and create package
    """
    name = "libusb"
    version = "1.0.21"
    release_name = "%s-%s" % (name, version)
    generators = "cmake", "txt"
    settings = "os", "arch", "compiler", "build_type"
    options = {"shared": [True, False] }
    default_options = "shared=True"
    url = "http://github.com/uilianries/conan-libusb"
    author = "<NAME> <<EMAIL>>"
    license = "https://github.com/libusb/libusb/blob/master/COPYING"
    description = "A cross-platform library to access USB devices"
    exports = ["CMakeLists.txt", "FindLIBUSB.cmake"]
    install_dir = tempfile.mkdtemp(suffix=name)

    def source(self):
        tar_name = "%s-%s.tar.gz" % (self.name, self.version)
        tools.download("https://github.com/libusb/libusb/releases/download/v%s/%s.tar.bz2" % (self.version, self.release_name), tar_name)
        tools.check_md5(tar_name, "1da9ea3c27b3858fa85c5f4466003e44")
        tools.unzip(tar_name)
        os.unlink(tar_name)
        shutil.copyfile("CMakeLists.txt", os.path.join(self.release_name, "CMakeLists.txt"))

    def system_requirements(self):
        if self.settings.os == "Linux":
            package_tool = tools.SystemPackageTool()
            arch = "i386" if self.settings.arch == "x86" else "amd64"
            package_tool.install(packages="libudev-dev:%s" % arch, update=True)

    def _run_cmd(self, command):
        if self.settings.os == "Windows":
            tools.run_in_windows_bash(self, tools.unix_path(command))
        else:
            self.run(command)

    def build(self):
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            cmake = CMake(self)
            cmake.definitions["WITH_STATIC"] = not self.options.shared or self.settings.compiler == "Visual Studio"
            cmake.definitions["WITH_SHARED"] = self.options.shared
            cmake.definitions["CMAKE_INSTALL_PREFIX"] = self.install_dir
            cmake.configure(source_dir=self.release_name)
            cmake.build()
            cmake.install()
        else:
            env_build = AutoToolsBuildEnvironment(self)
            env_build.fpic = True
            with tools.environment_append(env_build.vars):
                with tools.chdir(self.release_name):
                    configure_args = ['--prefix=%s' % self.install_dir]
                    configure_args.append('--enable-shared' if self.options.shared else '--disable-shared')
                    configure_args.append('--enable-static' if not self.options.shared else '--disable-static')
                    self._run_cmd("./configure %s" % ' '.join(configure_args))
                    if self.settings.os == "Windows" and self.settings.compiler = "gcc":
                        new_build_folder = tools.unix_path(self.build_folder)
                        tools.replace_in_file(os.path.join(self.build_folder, release_name, "Makefile"), self.build_folder, new_build_folder)
                    self._run_cmd("make")
                    self._run_cmd("make install")<commit_msg>#9 fix if condition<commit_after>"""Conan receipt package for USB Library 1.0.21
"""
import shutil
import tempfile
import os
from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools


class LibUSBConan(ConanFile):
    """Download libusb source, build and create package
    """
    name = "libusb"
    version = "1.0.21"
    release_name = "%s-%s" % (name, version)
    generators = "cmake", "txt"
    settings = "os", "arch", "compiler", "build_type"
    options = {"shared": [True, False] }
    default_options = "shared=True"
    url = "http://github.com/uilianries/conan-libusb"
    author = "<NAME> <<EMAIL>>"
    license = "https://github.com/libusb/libusb/blob/master/COPYING"
    description = "A cross-platform library to access USB devices"
    exports = ["CMakeLists.txt", "FindLIBUSB.cmake"]
    install_dir = tempfile.mkdtemp(suffix=name)

    def source(self):
        tar_name = "%s-%s.tar.gz" % (self.name, self.version)
        tools.download("https://github.com/libusb/libusb/releases/download/v%s/%s.tar.bz2" % (self.version, self.release_name), tar_name)
        tools.check_md5(tar_name, "1da9ea3c27b3858fa85c5f4466003e44")
        tools.unzip(tar_name)
        os.unlink(tar_name)
        shutil.copyfile("CMakeLists.txt", os.path.join(self.release_name, "CMakeLists.txt"))

    def system_requirements(self):
        if self.settings.os == "Linux":
            package_tool = tools.SystemPackageTool()
            arch = "i386" if self.settings.arch == "x86" else "amd64"
            package_tool.install(packages="libudev-dev:%s" % arch, update=True)

    def _run_cmd(self, command):
        if self.settings.os == "Windows":
            tools.run_in_windows_bash(self, tools.unix_path(command))
        else:
            self.run(command)

    def build(self):
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            cmake = CMake(self)
            cmake.definitions["WITH_STATIC"] = not self.options.shared or self.settings.compiler == "Visual Studio"
            cmake.definitions["WITH_SHARED"] = self.options.shared
            cmake.definitions["CMAKE_INSTALL_PREFIX"] = self.install_dir
            cmake.configure(source_dir=self.release_name)
            cmake.build()
            cmake.install()
        else:
            env_build = AutoToolsBuildEnvironment(self)
            env_build.fpic = True
            with tools.environment_append(env_build.vars):
                with tools.chdir(self.release_name):
                    configure_args = ['--prefix=%s' % self.install_dir]
                    configure_args.append('--enable-shared' if self.options.shared else '--disable-shared')
                    configure_args.append('--enable-static' if not self.options.shared else '--disable-static')
                    self._run_cmd("./configure %s" % ' '.join(configure_args))
                    if self.settings.os == "Windows" and self.settings.compiler == "gcc":
                        new_build_folder = tools.unix_path(self.build_folder)
                        tools.replace_in_file(os.path.join(self.build_folder, release_name, "Makefile"), self.build_folder, new_build_folder)
                    self._run_cmd("make")
                    self._run_cmd("make install")
{'fraction_non_alphanumeric': 0.13017570664629488, 'fraction_numerical': 0.011764705882352941, 'mean_word_length': 2.6245847176079735, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1397370', 'n_tokens_mistral': 2075, 'n_tokens_neox': 1980, 'n_words': 366}