Repository: conan-io/conan-center-index

Issue:
Add libid3tag/0.15.1b
Specify library name and version:  **libid3tag/0.15.1b**

- [x] I've read the [guidelines](https://github.com/conan-io/conan-center-index/wiki#how-to-submit-a-pull-request) for contributing.
- [x] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes.
- [x] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version.
- [x] I've tried at least one configuration locally with the
      [conan-center hook](https://github.com/conan-io/hooks.git) activated.




Discussion:

Resolving patch:
diff --git a/recipes/libid3tag/all/conanfile.py b/recipes/libid3tag/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/libid3tag/all/conanfile.py
@@ -0,0 +1,106 @@
+from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild
+from conans.errors import ConanInvalidConfiguration
+import os
+
+
+class LibId3TagConan(ConanFile):
+    name = "libid3tag"
+    description = "ID3 tag manipulation library."
+    topics = ("conan", "mad", "id3", "MPEG", "audio", "decoder")
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://www.underbit.com/products/mad/"
+    license = "GPL-2.0-or-later"
+    settings = "os", "arch", "compiler", "build_type"
+    options = {"shared": [True, False], "fPIC": [True, False]}
+    default_options = {"shared": False, "fPIC": True}
+    generator = "pkg_config", "visual_studio"
+
+    _autotools = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def configure(self):
+        del self.settings.compiler.libcxx
+        del self.settings.compiler.cppstd
+        if self._is_msvc and self.options.shared:
+            raise ConanInvalidConfiguration("libid3tag does not support shared library for MSVC")
+
+    def requirements(self):
+        self.requires("zlib/1.2.11")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        extracted_dir = self.name + "-" + self.version
+        os.rename(extracted_dir, self._source_subfolder)
+
+    @property
+    def _is_msvc(self):
+        return self.settings.compiler == "Visual Studio" or (
+            self.settings.compiler == "clang" and self.settings.os == "Windows"
+        )
+
+    def build(self):
+        if self._is_msvc:
+            self._build_msvc()
+        else:
+            self._build_autotools()
+
+    def _build_msvc(self):
+        kwargs = {}
+        with tools.chdir(os.path.join(self._source_subfolder, "msvc++")):
+            # cl : Command line error D8016: '/ZI' and '/Gy-' command-line options are incompatible
+            tools.replace_in_file("libid3tag.dsp", "/ZI ", "")
+            if self.settings.compiler == "clang":
+                tools.replace_in_file("libid3tag.dsp", "CPP=cl.exe", "CPP=clang-cl.exe")
+                tools.replace_in_file("libid3tag.dsp", "RSC=rc.exe", "RSC=llvm-rc.exe")
+                kwargs["toolset"] = "ClangCl"
+            if self.settings.arch == "x86_64":
+                tools.replace_in_file("libid3tag.dsp", "Win32", "x64")
+            with tools.vcvars(self.settings):
+                self.run("devenv /Upgrade libid3tag.dsp")
+            msbuild = MSBuild(self)
+            msbuild.build(project_file="libid3tag.vcxproj", **kwargs)
+
+    def _configure_autotools(self):
+        if not self._autotools:
+            if self.options.shared:
+                args = ["--disable-static", "--enable-shared"]
+            else:
+                args = ["--disable-shared", "--enable-static"]
+            self._autotools = AutoToolsBuildEnvironment(self)
+            self._autotools.configure(args=args, configure_dir=self._source_subfolder)
+        return self._autotools
+
+    def _build_autotools(self):
+        autotools = self._configure_autotools()
+        autotools.make()
+
+    def _install_autotools(self):
+        autotools = self._configure_autotools()
+        autotools.install()
+        la = os.path.join(self.package_folder, "lib", "libid3tag.la")
+        if os.path.isfile(la):
+            os.unlink(la)
+
+    def package(self):
+        self.copy("COPYRIGHT", dst="licenses", src=self._source_subfolder)
+        self.copy("COPYING", dst="licenses", src=self._source_subfolder)
+        self.copy("CREDITS", dst="licenses", src=self._source_subfolder)
+        if self._is_msvc:
+            self.copy(pattern="*.lib", dst="lib", src=self._source_subfolder, keep_path=False)
+            self.copy(pattern="id3tag.h", dst="include", src=self._source_subfolder)
+        else:
+            self._install_autotools()
+
+    def package_info(self):
+        self.cpp_info.libs = ["libid3tag" if self._is_msvc else "id3tag"]


Test patch:
diff --git a/recipes/libid3tag/all/test_package/CMakeLists.txt b/recipes/libid3tag/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/libid3tag/all/test_package/CMakeLists.txt
@@ -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.cpp)
+target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
diff --git a/recipes/libid3tag/all/test_package/conanfile.py b/recipes/libid3tag/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/libid3tag/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+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)
diff --git a/recipes/libid3tag/all/test_package/test_package.cpp b/recipes/libid3tag/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/libid3tag/all/test_package/test_package.cpp
@@ -0,0 +1,15 @@
+#include <iostream>
+#include <id3tag.h>
+
+int main()
+{
+    std::cout << "id3tag version: " << id3_version << std::endl;
+    std::cout << "id3tag copyright: " << id3_copyright << std::endl;
+    std::cout << "id3tag author: " << id3_author << std::endl;
+    std::cout << "id3tag build: " << id3_build << std::endl;
+
+    id3_tag tag;
+    id3_tag_version(&tag);
+
+    return 0;
+}