Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tssmsr/cci.20201117 #4552

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions recipes/tssmsr/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"cci.20201117":
url: "https://github.com/microsoft/TSS.MSR/archive/04eba4ac647c5fc2436adbeea49fc3372418de7b.tar.gz"
sha256: cfbc77dad59d3bf01e6d18c43946100541690240bed524b13d361073e529b62e
patches:
"cci.20201117":
- patch_file: "patches/0001-Add-conan-openssl-dependency-to-Makefile.patch"
base_path: "source_subfolder"
87 changes: 87 additions & 0 deletions recipes/tssmsr/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import os
from conans import ConanFile, AutoToolsBuildEnvironment, MSBuild, tools
from conans.errors import ConanInvalidConfiguration
from glob import glob


class TssMsrConan(ConanFile):
name = "tssmsr"
description = "TPM Software Stack (TSS) implementations from Microsoft"
topics = ("tpm", "tss", "crypto", "microsoft")
homepage = "https://github.com/microsoft/TSS.MSR"
url = "https://github.com/conan-io/conan-center-index"
license = "MIT"
settings = "os", "compiler", "arch", "build_type"
generators = "make"
exports_sources = "patches/*"

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return os.path.join(self._source_subfolder, "TSS.CPP")

@property
def _minimum_cpp_standard(self):
return 11

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "14",
"gcc": "5",
"clang": "3.9",
"apple-clang": "8",
}

def configure(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warn("{} recipe lacks information about the {} compiler support.".format(
self.name, self.settings.compiler))
else:
if tools.Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format(
self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version))

def requirements(self):
# VC builds link against openssl included in the sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's different about the inline one? Typically we use a small patch to make sure it uses the Conan one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks like an old one, you should be able to remove it and include the msbuild props generated from conan 🤞

if not self.settings.compiler == "Visual Studio":
self.requires("openssl/1.1.1g")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.requires("openssl/1.1.1g")
self.requires("openssl/1.1.1i")


def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob("TSS.MSR-*")[0]
os.rename(extracted_dir, self._source_subfolder)

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
if self.settings.compiler == "Visual Studio":
msbuild = MSBuild(self)
msbuild.build(os.path.join(self._build_subfolder, "TSS.CPP.sln"), targets=["TSS_CPP"])
else:
autotools = AutoToolsBuildEnvironment(self)
autotools.make(
args=[f"CONFIG={str(self.settings.build_type).lower()}", "-C", self._build_subfolder])

def package(self):
self.copy(pattern="LICENSE", dst="licenses",
src=self._source_subfolder)
self.copy("*.h", dst="include",
src=os.path.join(self._build_subfolder, "include"))
self.copy("**/libtss*.a", dst="lib", keep_path=False)
self.copy("**/libtss*.so", dst="lib", keep_path=False)
self.copy("**/TSS.CPP.dll", dst="bin", keep_path=False)
self.copy("**/TSS.CPP.lib", dst="lib", keep_path=False)

def package_info(self):
if tools.os_info.is_windows:
self.cpp_info.libs = ["tss.cpp"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/microsoft/TSS.MSR/blob/04eba4ac647c5fc2436adbeea49fc3372418de7b/TSS.CPP/TSS.CPP.vcxproj#L112

Suggested change
self.cpp_info.libs = ["tss.cpp"]
self.cpp_info.libs = ["tss.cpp"]
self.cpp_info.system_libs = ["ws2_32", "tbs.lib"]

else:
self.cpp_info.libs = [
"tss" + ("d" if self.settings.build_type == "Debug" else "")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 73fc74859e3f91a02062311c36cdf85abb2ba13e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Salim?= <remy.salim@echosens.com>
Date: Fri, 18 Sep 2020 10:33:07 +0200
Subject: [PATCH 1/1] Add conan openssl dependency to Makefile

---
TSS.CPP/Makefile | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/TSS.CPP/Makefile b/TSS.CPP/Makefile
index b6d9c83..608b06e 100644
--- a/TSS.CPP/Makefile
+++ b/TSS.CPP/Makefile
@@ -3,7 +3,9 @@ CC = g++
CFLAGS_DBG = -g -DDEBUG -D_DEBUG
CFLAGS_REL = -O2 -DNDEBUG

-_CFLAGS = -Wall -std=c++11 -Iinclude
+-include ../../conanbuildinfo.mak
+
+_CFLAGS = -Wall -std=c++11 -Iinclude -I$(CONAN_INCLUDE_DIRS_OPENSSL) -DOPENSSL_NO_SM3
CFLAGS_SRC = $(_CFLAGS) -fPIC -D_TPMCPPLIB
CFLAGS_SMPL = $(_CFLAGS)

@@ -11,8 +13,8 @@ SRCDIR = Src
SMPLDIR = Samples
BINDIR = bin

-TSS_A = $(BINDIR)/tss$(SUFF).a
-TSS_SO = $(BINDIR)/tss$(SUFF).so
+TSS_A = $(BINDIR)/libtss$(SUFF).a
+TSS_SO = $(BINDIR)/libtss$(SUFF).so
SAMPLES = $(BINDIR)/samples

OBJDIR = $(BINDIR)/obj
@@ -87,7 +89,8 @@ $(DEPFILES_SMPL):


$(SAMPLES): $(SMPL_OBJS) $(TSS_A)
- $(CC) -o $@ $(SMPL_OBJS) $(TSS_A) $(CFLAGS_SMPL) -L/usr/lib -lcrypto -ldl
+ $(CC) -o $@ $(SMPL_OBJS) $(TSS_A) $(CFLAGS_SMPL) -L/usr/lib -lcrypto -ldl \
+ -L$(CONAN_LIB_DIRS_OPENSSL) $(addprefix -l,$(CONAN_LIBS_OPENSSL)) $(addprefix -l,$(CONAN_SYSTEM_LIBS_OPENSSL))

samples: $(SAMPLES)

--
2.25.1

9 changes: 9 additions & 0 deletions recipes/tssmsr/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.10)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS} ${CMAKE_DL_LIBS})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
17 changes: 17 additions & 0 deletions recipes/tssmsr/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions recipes/tssmsr/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <Tpm2.h>

using namespace std;
using namespace TpmCpp;

int main() {
TpmTbsDevice device;
Tpm2 tpm(device);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/tssmsr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20201117":
folder: all