Skip to content

Commit

Permalink
Update to Conan 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Jan 27, 2025
1 parent 454707b commit 6befc48
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
6.0.x
8.0.x
- name: Add msbuild to PATH
uses: microsoft/[email protected]
Expand Down
12 changes: 5 additions & 7 deletions build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ Param(
[Parameter(ParameterSetName="WithoutProfile", Mandatory)]
[string]$build_type,
[Parameter(Mandatory=$false)]
[bool]$build_nfc,
[Parameter(Mandatory=$false)]
[bool]$build_unittest
[bool]$build_nfc
)

Write-Host $arch $build_type $build_nfc
Set-Location installer
if($with_profile) {
.\conan-imports.ps1 -with_profile -build_nfc $build_nfc -build_unittest $build_unittest
.\conan-imports.ps1 -with_profile -build_nfc $build_nfc
} else {
.\conan-imports.ps1 -arch $arch -build_type $build_type -build_nfc $build_nfc -build_unittest $build_unittest
.\conan-imports.ps1 -arch $arch -build_type $build_type -build_nfc $build_nfc
}
Set-Location ../sources/scripts
pip install -r requirements.txt
Expand All @@ -25,9 +23,9 @@ Set-Location ../../
.\sources/scripts/generate-swig.ps1
Set-Location sources/LibLogicalAccessNet.native
if($with_profile) {
.\conan-build.ps1 -with_profile -build_nfc $build_nfc -build_unittest $build_unittest
.\conan-build.ps1 -with_profile -build_nfc $build_nfc
} else {
./conan-build.ps1 -arch $arch -build_type $build_type -build_nfc $build_nfc -build_unittest $build_unittest
./conan-build.ps1 -arch $arch -build_type $build_type -build_nfc $build_nfc
}
Set-Location ..

Expand Down
14 changes: 6 additions & 8 deletions installer/conan-imports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ Param(
[Parameter(ParameterSetName="WithoutProfile", Mandatory)]
[string]$build_type,
[Parameter(Mandatory=$false)]
[bool]$build_nfc,
[Parameter(Mandatory=$false)]
[bool]$build_unittest
[bool]$build_nfc
)

if($with_profile) {
conan install -pr compilers/x64_msvc_debug -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest -u .
conan install -pr compilers/x64_msvc_release -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest -u .
conan install -pr compilers/x86_msvc_debug -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest -u .
conan install -pr compilers/x86_msvc_release -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest -u .
conan install -pr compilers/x64_msvc_debug -u -o LLA_BUILD_NFC=$build_nfc .
conan install -pr compilers/x64_msvc_release -u -o LLA_BUILD_NFC=$build_nfc .
conan install -pr compilers/x86_msvc_debug -u -o LLA_BUILD_NFC=$build_nfc .
conan install -pr compilers/x86_msvc_release -u -o LLA_BUILD_NFC=$build_nfc .
} else {
conan install -s arch=$arch -s build_type=$build_type -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest --build=missing -u .
conan install -s arch=$arch -s build_type=$build_type -u -o LLA_BUILD_NFC=$build_nfc --build=missing .
}
36 changes: 16 additions & 20 deletions installer/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
from conans import ConanFile, tools
from conans.errors import ConanException
from conan import ConanFile
from conan.errors import ConanException
from conan.tools.files import copy
import os

class LogicalAccessSwigConan(ConanFile):
name = "LogicalAccessSwig"
name = "logicalaccess-swig"
version = "3.2.0"
settings = "build_type", "arch", "os"
options = { 'LLA_BUILD_NFC': [True, False],
'LLA_BUILD_UNITTEST': [True, False]}
default_options = 'LogicalAccess:LLA_BUILD_PKCS=True', 'LLA_BUILD_NFC=False', 'LLA_BUILD_UNITTEST=False'
options = { 'LLA_BUILD_NFC': [True, False] }
default_options = { 'logicalaccess/*:LLA_BUILD_PKCS': True, 'LLA_BUILD_NFC': False }
revision_mode = "scm"

def configure(self):
self.options['LogicalAccess'].LLA_BUILD_UNITTEST = self.options.LLA_BUILD_UNITTEST

def requirements(self):
if self.options.LLA_BUILD_NFC:
self.requires('LogicalAccessNFC/' + self.version)
self.requires('logicalaccess-nfc/' + self.version)
else:
self.requires('LogicalAccess/' + self.version)
self.requires('logicalaccess/' + self.version)

def imports(self):
self.copy("bin/*.dll", keep_path=False, dst="./packages/dll/" + str(self.settings.arch) + "/" + str(self.settings.build_type))
self.copy("bin/*.exe", keep_path=False, dst="./packages/dll/" + str(self.settings.arch) + "/" + str(self.settings.build_type))
self.copy("lib/*.lib", keep_path=False, dst="./packages/lib/" + str(self.settings.arch) + "/" + str(self.settings.build_type))

self.copy("lib/*.so*", keep_path=False, dst="./packages/dll/")

if not os.path.exists("./packages/include"):
self.copy("include/*.*", dst="./packages")
def generate(self):
for dep in self.dependencies.values():
copy(self, "*.dll", dep.cpp_info.bindirs[0], "./packages/dll/" + str(self.settings.arch) + "/" + str(self.settings.build_type))
copy(self, "*.exe", dep.cpp_info.bindirs[0], "./packages/dll/" + str(self.settings.arch) + "/" + str(self.settings.build_type))
copy(self, "*.lib", dep.cpp_info.libdirs[0], "./packages/lib/" + str(self.settings.arch) + "/" + str(self.settings.build_type))
copy(self, "*.so", dep.cpp_info.bindirs[0], "./packages/dll/")
if not os.path.exists("./packages/include"):
copy(self, "*.*", dep.cpp_info.includedirs[0], "./packages/include")
12 changes: 8 additions & 4 deletions sources/LibLogicalAccessNet.native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ project(LibLogicalAccessNetNative)

set(CMAKE_SUPPRESS_REGENERATION true)
MESSAGE(STATUS "DIR: ${CMAKE_BINARY_DIR}")
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

if(LLA_BUILD_NFC)
find_package(logicalaccess-nfc)
endif()
find_package(logicalaccess)
find_package(nlohmann_json)

set(LLA_SWIG_SOURCES liblogicalaccess_reader_wrap.cxx
liblogicalaccess_card_wrap.cxx
Expand All @@ -30,9 +34,9 @@ endif()
set(LLA_LINK)
if(LLA_BUILD_NFC)
add_compile_definitions(BUILD_NFC)
list(APPEND LLA_LINK CONAN_PKG::LogicalAccessNFC)
list(APPEND LLA_LINK logicalaccess-nfc::logicalaccess-nfc)
else()
list(APPEND LLA_LINK CONAN_PKG::LogicalAccess)
list(APPEND LLA_LINK logicalaccess::logicalaccess)
endif()

target_link_libraries(${TARGET_NAME} PUBLIC
Expand Down
8 changes: 3 additions & 5 deletions sources/LibLogicalAccessNet.native/conan-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Param(
[string]$build_type,
[Parameter(Mandatory=$false)]
[bool]$build_nfc,
[Parameter(Mandatory=$false)]
[bool]$build_unittest,
[Parameter(Mandatory=$false)]
[switch]$publish
)
Expand All @@ -35,7 +33,7 @@ if($with_profile) {

Set-Location build

$PackageName = "LogicalAccessSwig/3.2.0@lla/master"
$PackageName = "logicalaccess-swig/3.2.0@lla/master"
$Profiles = @(("compilers/x64_msvc_release", "Release", "x86_64"),
("compilers/x86_msvc_release", "Release", "x86"),
("compilers/x86_msvc_debug", "Debug", "x86"),
Expand All @@ -45,7 +43,7 @@ $env:ASSEMBLYAPPENDER = 'CE'

if($with_profile) {
foreach ($Profile in $Profiles) {
ExecExternal { conan install -pr $Profile[0] -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest --build=missing .. }
ExecExternal { conan install -pr $Profile[0] -o LLA_BUILD_NFC=$build_nfc --build=missing .. }
ExecExternal { conan build .. }
$config = $Profile[1]
$arch = $Profile[2]
Expand All @@ -57,7 +55,7 @@ if($with_profile) {
Remove-Item * -Recurse -Force
}
} else {
ExecExternal { conan install -s arch=$arch -s build_type=$build_type -o LLA_BUILD_NFC=$build_nfc -o LLA_BUILD_UNITTEST=$build_unittest --build=missing .. }
ExecExternal { conan install -s arch=$arch -s build_type=$build_type -o LLA_BUILD_NFC=$build_nfc --build=missing .. }
ExecExternal { conan build .. }
Copy-Item bin/LibLogicalAccessNet.native.* ../bin/$arch/$build_type/
if ($publish) {
Expand Down
54 changes: 30 additions & 24 deletions sources/LibLogicalAccessNet.native/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,54 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanException
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.errors import ConanException
from conan.tools.files import copy
import os

class LLASwig(ConanFile):
name = "LogicalAccessSwig"
name = "logicalaccess-swig"
version = "3.2.0"
license = "LGPL"
url = "https://github.com/liblogicalaccess/liblogicalaccess-swig"
description = "SWIG wrapper for LibLogicalAccess"
settings = "os", "compiler", "build_type", "arch"
options = { 'LLA_BUILD_NFC': [True, False],
'LLA_BUILD_UNITTEST': [True, False]}
default_options = 'LogicalAccess:LLA_BUILD_PKCS=True', 'LLA_BUILD_NFC=False', 'LLA_BUILD_UNITTEST=False'
generators = "cmake"
options = { 'LLA_BUILD_NFC': [True, False] }
default_options = { 'logicalaccess/*:LLA_BUILD_PKCS': True, 'LLA_BUILD_NFC': False }
revision_mode = "scm"

def requirements(self):
if self.options.LLA_BUILD_NFC:
self.requires('LogicalAccessNFC/' + self.version)
self.requires('logicalaccess-nfc/' + self.version)
else:
self.requires('LogicalAccess/'+ self.version)

def configure(self):
self.options['LogicalAccess'].LLA_BUILD_UNITTEST = self.options.LLA_BUILD_UNITTEST

def configure_cmake(self):
cmake = CMake(self, build_type=self.settings.build_type)
self.requires('logicalaccess/'+ self.version)
self.requires('nlohmann_json/3.11.3') # shoulnd't be required

def layout(self):
cmake_layout(self)

def generate(self):
for dep in self.dependencies.values():
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.so", dep.cpp_info.bindirs[0], "lib")

tc = CMakeToolchain(self)
if self.options.LLA_BUILD_NFC:
cmake.definitions['LLA_BUILD_NFC'] = True
tc.variables['LLA_BUILD_NFC'] = True
else:
cmake.definitions['LLA_BUILD_NFC'] = False
cmake.configure()
return cmake
tc.variables['LLA_BUILD_NFC'] = False

tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = self.configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = self.configure_cmake()
cmake = CMake(self)
cmake.install()

def imports(self):
self.copy("*.so*", "lib", "lib")

def package_info(self):
pass
6 changes: 2 additions & 4 deletions sources/LibLogicalAccessNet.native/liblogicalaccess_card.i
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
#include <logicalaccess/plugins/readers/iso7816/commands/samav1iso7816commands.hpp>
#include <logicalaccess/plugins/cards/samav/samav2commands.hpp>
#include <logicalaccess/plugins/readers/iso7816/commands/samav2iso7816commands.hpp>
#include <logicalaccess/plugins/cards/samav/samav3commands.hpp>
#include <logicalaccess/plugins/readers/iso7816/commands/samav3iso7816commands.hpp>
#include <logicalaccess/plugins/cards/desfire/desfireev2crypto.hpp>
#include <logicalaccess/plugins/cards/desfire/desfireev3commands.hpp>
#include <logicalaccess/plugins/cards/desfire/desfireev3chip.hpp>
Expand Down Expand Up @@ -161,6 +159,7 @@
#include <logicalaccess/plugins/cards/samav/samav1chip.hpp>
#include <logicalaccess/plugins/cards/samav/samav2chip.hpp>
#include <logicalaccess/plugins/cards/samav/samav3chip.hpp>
#include <logicalaccess/plugins/cards/samav/samav3commands.hpp>
#include <logicalaccess/plugins/cards/seos/lla_cards_seos_api.hpp>
#include <logicalaccess/plugins/cards/seos/seoscommands.hpp>
#include <logicalaccess/plugins/cards/seos/seoschip.hpp>
Expand Down Expand Up @@ -349,8 +348,6 @@ using LibLogicalAccess.Reader;
%import <logicalaccess/plugins/readers/iso7816/commands/samav1iso7816commands.hpp>
%include <logicalaccess/plugins/cards/samav/samav2commands.hpp>
%import <logicalaccess/plugins/readers/iso7816/commands/samav2iso7816commands.hpp>
%include <logicalaccess/plugins/cards/samav/samav3commands.hpp>
%import <logicalaccess/plugins/readers/iso7816/commands/samav3iso7816commands.hpp>
%include <logicalaccess/plugins/cards/desfire/desfireev2crypto.hpp>
%include <logicalaccess/plugins/cards/desfire/desfireev3commands.hpp>
%include <logicalaccess/plugins/cards/desfire/desfireev3chip.hpp>
Expand Down Expand Up @@ -446,6 +443,7 @@ using LibLogicalAccess.Reader;
%include <logicalaccess/plugins/cards/samav/samav1chip.hpp>
%include <logicalaccess/plugins/cards/samav/samav2chip.hpp>
%include <logicalaccess/plugins/cards/samav/samav3chip.hpp>
%include <logicalaccess/plugins/cards/samav/samav3commands.hpp>
%include <logicalaccess/plugins/cards/seos/lla_cards_seos_api.hpp>
%include <logicalaccess/plugins/cards/seos/seoscommands.hpp>
%include <logicalaccess/plugins/cards/seos/seoschip.hpp>
Expand Down
2 changes: 1 addition & 1 deletion sources/LibLogicalAccessNet/LibLogicalAccessNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>LibLogicalAccess</RootNamespace>
<Description>LibLogicalAccess RFID library layer for C#</Description>
<Copyright>Copyright (C) LibLogicalAccess 2025</Copyright>
<Version>3.2.0-3</Version>
<Version>3.2.0-6</Version>
<AssemblyVersion>3.2.0.0</AssemblyVersion>
<FileVersion>3.2.0.0</FileVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down

0 comments on commit 6befc48

Please sign in to comment.