from conans import ConanFile, CMake, tools from conans import tools import shutil class GenerallibConan(ConanFile): source_folder = "pkgsrc" name = "generallib" version = "1.0" license = "GPL" author = "caiyuzheng" url = "https://gitee.com/290198252/generallib" description = "a simple cpp basic library" generators = "cmake_find_package" def source(self): tools.rmdir("pkgsrc") git = tools.Git(folder=self.source_folder + "/pkgsrc", verify_ssl=False) git.clone("https://gitee.com/290198252/generallib.git") def package(self): self.copy(pattern = "*.a",src ="pkgsrc\\obj\\",dst = "lib",keep_path=True) shutil.copytree(self.build_folder + '\\pkgsrc\\obj\\inc', self.package_folder + "\\include\\generallib") def build(self): cmake = CMake(self) print("path " + self.source_folder + " is where the package built") print("build env is ",tools.get_env("BUILD_ENV")) tools.rmdir(tools.unix_path(self.package_folder)+"/build") tools.mkdir(tools.unix_path(self.package_folder)+"/build") if tools.os_info.is_windows: print("current os windows") if tools.os_info.is_cygwin: print("cygwin build") if tools.get_env("BUILD_ENV")=="msys": print("msys build") tools.run_in_windows_bash(self, subsystem="msys", cwd="pkgsrc", bashcmd="cmake build -DCMAKE_MODULE_PATH=" + tools.unix_path(self.source_folder) + " -G\"MinGW Makefiles\" " + tools.unix_path(self.source_folder) + "//pkgsrc") tools.run_in_windows_bash( self, subsystem="msys", cwd="pkgsrc", bashcmd="cmake --build .") def requirements(self): self.requires("libevent/2.1.2")