Skip to content

Commit

Permalink
clean build
Browse files Browse the repository at this point in the history
  • Loading branch information
shun2wang committed Nov 26, 2024
1 parent cd5a1c4 commit 0774bd0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
24 changes: 10 additions & 14 deletions recipes/librdata/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

from conan import ConanFile
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, rm, rmdir
from conan.tools.files import copy, rm, rmdir, get
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Git
from conan.tools.layout import basic_layout

required_conan_version = ">=2.0.0"

class Libreadstat(ConanFile):
name = "librdata"
version = "0.1"
description = "librdata is a library for read and write R data frames from C"
license = "CDDL-1.0", "LGPL-2.1-only"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/WizardMac/librdata"
topics = ("r", "rdata", "rds", "data-frames")
Expand All @@ -40,7 +40,7 @@ def configure(self):
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="src")
basic_layout(self, src_folder="src")

def requirements(self):
if self.options.with_zip:
Expand All @@ -49,18 +49,16 @@ def requirements(self):
self.requires("xz_utils/5.6.3")

def source(self):
git = Git(self)
git.clone(url="https://github.com/WizardMac/librdata.git", target=".")
# git = Git(self)
# git.clone(url="https://github.com/WizardMac/librdata.git", target=".")
get(self, **self.conan_data["sources"][self.version], strip_root=True)


def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()
tc = AutotoolsDeps(self)
if self.options.with_zip:
tc.variables["with_zip"] = True
tc.generate()
dep = AutotoolsDeps(self)
dep.generate()

def build(self):
autotools = Autotools(self)
Expand All @@ -73,7 +71,6 @@ def package(self):
copy(self, "rdata.h", src=os.path.join(self.source_folder, "headers"), dst=os.path.join(self.package_folder, "include"))
copy(self, "*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, "*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, "*.lib", src=self.source_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, "*.dll", src=self.source_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
else:
autotools = Autotools(self)
Expand All @@ -84,7 +81,6 @@ def package(self):
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.set_property("pkg_config_name", "readstat")
suffix = "_i" if is_msvc(self) and self.options.shared else ""
self.cpp_info.libs = [f"librdata{suffix}"]
if self.settings.os in ("FreeBSD", "Linux"):
Expand Down
3 changes: 1 addition & 2 deletions recipes/librdata/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)
Expand Down
15 changes: 12 additions & 3 deletions recipes/librdata/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#include "rdata.h"

static int handle_table(const char *name, void *ctx) {
printf("Read table: %s\n", name);

int main(int argc, char const *argv[])
{
rdata_parser_t *parser = rdata_parser_init();
if (parser == NULL) {
fprintf(stderr, "Failed to initialize rdata_parser.\n");
return 1;
}

rdata_parser_free(parser);
printf("librdata is successfully included, linked, and used.\n");

return 0;
}
}

0 comments on commit 0774bd0

Please sign in to comment.