Skip to content

Commit

Permalink
Add libfido2 and libcbor
Browse files Browse the repository at this point in the history
Adding the libfido2 project and the libcbor project, as it is a dependency.
Currently supported to build static libraries.
  • Loading branch information
bobomb authored and pbor committed Aug 22, 2023
1 parent 53d0d68 commit 58b7254
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From c3c7343d3a18de2f00f288db4969ec07cb1fae09 Mon Sep 17 00:00:00 2001
From: Mofidul Jamal <mofidulj@amazon.com>
Date: Fri, 18 Aug 2023 14:11:21 -0400
Subject: [PATCH] libfido2: update cmake script to have /sdl flag before -W4
and warning disabled flags

---
CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6fa341a..e97976c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,9 +209,9 @@ if(MSVC)
string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
${MSVC_DISABLED_WARNINGS_LIST})
string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Z7 /guard:cf /sdl /RTCcsu")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /guard:cf /sdl")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /sdl -MP -W4 -WX ${MSVC_DISABLED_WARNINGS_STR}")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Z7 /guard:cf /RTCcsu")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /guard:cf")
if(USE_WINHELLO)
add_definitions(-DUSE_WINHELLO)
endif()
--
2.37.1.windows.1

2 changes: 2 additions & 0 deletions gvsbuild/projects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
from gvsbuild.projects.lgi import Lgi
from gvsbuild.projects.libadwaita import Libadwaita
from gvsbuild.projects.libarchive import Libarchive
from gvsbuild.projects.libcbor import Libcbor
from gvsbuild.projects.libcroco import Libcroco
from gvsbuild.projects.libcurl import Libcurl
from gvsbuild.projects.libepoxy import Libepoxy
from gvsbuild.projects.libfido2 import Libfido2
from gvsbuild.projects.libffi import Libffi
from gvsbuild.projects.libgxps import Libgxps
from gvsbuild.projects.libjpeg_turbo import LibjpegTurbo
Expand Down
43 changes: 43 additions & 0 deletions gvsbuild/projects/libcbor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2016 - Yevgen Muntyan
# Copyright (C) 2016 - Ignacio Casal Quinteiro
# Copyright (C) 2016 - Arnavion
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

from gvsbuild.utils.base_builders import CmakeProject
from gvsbuild.utils.base_expanders import Tarball
from gvsbuild.utils.base_project import Project, project_add


@project_add
class Libcbor(Tarball, CmakeProject):
def __init__(self):
Project.__init__(
self,
"libcbor",
version="0.10.2",
archive_url="https://github.com/PJK/libcbor/archive/refs/tags/v{version}.tar.gz",
hash="e75f712215d7b7e5c89ef322a09b701f7159f028b8b48978865725f00f79875b",
archive_filename="libcbor-{version}.tar.gz",
dependencies=["cmake", "ninja"],
)

def build(self):
# If do_install is True, the build fails
CmakeProject.build(self, use_ninja=True, do_install=False)
self.install(r"_gvsbuild-cmake\src\cbor.lib lib")
self.install(r"_gvsbuild-cmake\src\cbor\*.h include\cbor")
self.install(r"_gvsbuild-cmake\cbor\*.h include\cbor")
self.install(r"src\cbor.h include")
self.install(r"src\cbor\*.h include\cbor")
58 changes: 58 additions & 0 deletions gvsbuild/projects/libfido2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2016 - Yevgen Muntyan
# Copyright (C) 2016 - Ignacio Casal Quinteiro
# Copyright (C) 2016 - Arnavion
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

import os

from gvsbuild.utils.base_builders import CmakeProject
from gvsbuild.utils.base_expanders import Tarball
from gvsbuild.utils.base_project import Project, project_add


@project_add
class Libfido2(Tarball, CmakeProject):
def __init__(self):
Project.__init__(
self,
"libfido2",
version="1.13.0",
archive_url="https://developers.yubico.com/libfido2/Releases/libfido2-{version}.tar.gz",
hash="51d43727e2a1c4544c7fd0ee47786f443e39f1388ada735a509ad4af0a2459ca",
dependencies=[
"cmake",
"ninja",
"zlib",
"openssl",
"libcbor",
],
patches=["0001-libfido2-update-cmake-script-to-have-sdl-flag-before.patch"],
)

def build(self):
if self.builder.x86:
arch = "x86"
else:
arch = "x64"

include_dirs = os.path.join(self.builder.gtk_dir, "inc")
lib_dirs = os.path.join(self.builder.gtk_dir, "lib")
bin_dirs = lib_dirs = os.path.join(self.builder.gtk_dir, "bin")
# Build static libs only for libfido2
build_params = '-DBUILD_EXAMPLES=OFF -DBUILD_MANPAGES=OFF -DBUILD_TESTS=OFF -DBUILD_TOOLS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS_DEBUG="/MTd /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE" -DCMAKE_C_FLAGS_RELEASE="/MT /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE"'
cmake_params = f"-DWITH_ZLIB=ON -DCBOR_INCLUDE_DIRS={include_dirs} -DCRYPTO_INCLUDE_DIRS={include_dirs} -DZLIB_INCLUDE_DIRS={include_dirs} -DCBOR_LIBRARY_DIRS={lib_dirs} -DCRYPTO_LIBRARY_DIRS={lib_dirs} -DZLIB_LIBRARY_DIRS={lib_dirs} -DCBOR_BIN_DIRS={bin_dirs} -DCRYPTO_BIN_DIRS={bin_dirs} -DZLIB_BIN_DIRS={bin_dirs} {build_params}"

CmakeProject.build(self, cmake_params=cmake_params, use_ninja=True)
self.install(r"output\%s\static\* ." % (arch))

0 comments on commit 58b7254

Please sign in to comment.