Skip to content

Commit 885cc36

Browse files
authored
Merge pull request #889 from bincrafters/libmodplug
Add libmodplug/0.8.9.0
2 parents 51519bd + 08fe3bd commit 885cc36

File tree

7 files changed

+136
-0
lines changed

7 files changed

+136
-0
lines changed

recipes/libmodplug/all/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_definitions("-DHAVE_STDINT_H")
8+
add_definitions("-DHAVE_SINF")
9+
10+
add_subdirectory("source_subfolder")

recipes/libmodplug/all/conandata.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"0.8.9.0":
3+
url: "https://github.com/Konstanty/libmodplug/archive/5a39f5913d07ba3e61d8d5afdba00b70165da81d.zip"
4+
sha256: "12d12362428ebcefd473e56ff94faa6ee5c066b777e153d2bbca15c1e379d1bc"

recipes/libmodplug/all/conanfile.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class LibmodplugConan(ConanFile):
6+
name = "libmodplug"
7+
description = "libmodplug - the library which was part of the Modplug-xmms project"
8+
topics = ("conan", "libmodplug", "auduo", "multimedia", "sound", "music", "mod", "mod music",
9+
"tracket music")
10+
url = "https://github.com/conan-io/conan-center-index"
11+
homepage = "http://modplug-xmms.sourceforge.net"
12+
license = "Unlicense" # public domain
13+
exports_sources = ["CMakeLists.txt"]
14+
generators = "cmake"
15+
16+
settings = "os", "arch", "compiler", "build_type"
17+
options = {"shared": [True, False], "fPIC": [True, False]}
18+
default_options = {"shared": False, "fPIC": True}
19+
20+
_source_subfolder = "source_subfolder"
21+
_build_subfolder = "build_subfolder"
22+
23+
def config_options(self):
24+
if self.settings.os == "Windows":
25+
del self.options.fPIC
26+
27+
def source(self):
28+
commit = os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))[0]
29+
tools.get(**self.conan_data["sources"][self.version])
30+
extracted_dir = self.name + "-" + commit
31+
os.rename(extracted_dir, self._source_subfolder)
32+
33+
def _configure_cmake(self):
34+
cmake = CMake(self)
35+
cmake.configure(build_folder=self._build_subfolder)
36+
return cmake
37+
38+
def build(self):
39+
cmake = self._configure_cmake()
40+
cmake.build()
41+
42+
def package(self):
43+
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
44+
cmake = self._configure_cmake()
45+
cmake.install()
46+
47+
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
48+
49+
def package_info(self):
50+
self.cpp_info.libs = ["modplug"]
51+
self.cpp_info.bindirs = ["lib"]
52+
self.cpp_info.includedirs.append(os.path.join("include", "libmodplug"))
53+
if not self.options.shared:
54+
self.cpp_info.defines.append("MODPLUG_STATIC")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
project(test_package)
3+
4+
set(CMAKE_VERBOSE_MAKEFILE TRUE)
5+
6+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7+
conan_basic_setup()
8+
9+
add_executable(${PROJECT_NAME} test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "compiler", "build_type", "arch"
7+
generators = "cmake"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not tools.cross_building(self.settings):
16+
# Download a public domain xm file; https://modarchive.org/module.php?178293
17+
tools.download(
18+
"https://api.modarchive.org/downloads.php?moduleid=178293#burbs.xm",
19+
filename="burbs.xm",
20+
sha256="ced080401a2635cddc6d13b9095efa217f260ce7b3a482a29b454f72317b0c4d",
21+
)
22+
bin_path = os.path.join("bin", "test_package")
23+
self.run("%s %s" % (bin_path, "burbs.xm"), run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
#include <vector>
4+
#include <libmodplug/modplug.h>
5+
6+
int main(int argc, char * const argv[])
7+
{
8+
if (argc < 2)
9+
return -1;
10+
FILE * f = fopen(argv[1], "rb");
11+
if (!f)
12+
return -2;
13+
14+
fseek(f, 0, SEEK_END);
15+
long fsize = ftell(f);
16+
fseek(f, 0, SEEK_SET);
17+
18+
std::vector<unsigned char> b(fsize);
19+
fread(&b[0], fsize, 1, f);
20+
21+
fclose(f);
22+
23+
ModPlugFile * m = ModPlug_Load(&b[0], fsize);
24+
if (!m)
25+
return -3;
26+
27+
std::cout << "name: " << ModPlug_GetName(m) << std::endl;
28+
std::cout << "length: " << ModPlug_GetLength(m) << " ms" << std::endl;
29+
30+
ModPlug_Unload(m);
31+
return 0;
32+
}

recipes/libmodplug/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"0.8.9.0":
3+
folder: all

0 commit comments

Comments
 (0)