dev-libs/libtypec: split libtypec and libtypec-utils

And incorporate patches and feedback from Matt Turner [1].

We move the build to use meson as well as add 3 patches
to fix the upstream meson build [2]. I am in the process
of upstreaming these patches.

[1] https://github.com/gentoo/gentoo/pull/36736
[2] https://github.com/libtypec/libtypec/pull/1

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
This commit is contained in:
Adrian Ratiu
2024-05-21 14:47:05 +03:00
parent f0ef2dc821
commit 87377ad7c8
12 changed files with 555 additions and 28 deletions

View File

@@ -0,0 +1 @@
DIST libtypec-0.5.1.tar.gz 35289 BLAKE2B c6d9fd060e999568b3f348d68cc49665c38d0d0adcf5761e236e14b0ae095ddb06b65226a98495e804ee0bf41dc42526c78e00c1b9e8fdf2dc65a56818a10253 SHA512 9acdb2e0963d85b8f6868b0ad18f644466aa8b0bb868bafd823ac3a8179370a68f1a69c8357705c70733a1cf0a750e484c1f4aa1816a1dc887a52024f9dffcce

View File

@@ -0,0 +1,76 @@
From 36a5bd5a1aeccba392d9a764be0f7651d08d33ce Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Mon, 20 May 2024 17:37:19 +0300
Subject: [PATCH 1/3] meson: fix build based on Gentoo testing
While releasing v0.5.1 upstream forgot to also bump the
meson build version. :) The meson project version was
also not set.
There are also two discrepancies between meson and cmake:
1. meson installs libtypec.so.1 whereas cmake installs
libtypec.so.0.5.1.
2. meson uses soversion = 0 for the ABI version while
cmake uses 5.
We fix these discrepancies so that mesan installs the
same files as cmake.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 13 +++++++++++--
utils/meson.build | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index a581926..5512f77 100644
--- a/meson.build
+++ b/meson.build
@@ -1,14 +1,23 @@
project('libtypec','c',
license: 'MIT',
+version: '0.5.1',
default_options : [
'warning_level=0'])
conf_data = configuration_data()
conf_data.set('libtypec_VERSION_MAJOR', '0')
conf_data.set('libtypec_VERSION_MINOR', '5')
-conf_data.set('libtypec_VERSION_PATCH', '0')
+conf_data.set('libtypec_VERSION_PATCH', '1')
+libudev_dep = dependency('libudev', required: true)
configure_file(input : 'libtypec_config.h.in', output : 'libtypec_config.h', configuration : conf_data)
-both_libraries('typec', 'libtypec.c', 'libtypec_sysfs_ops.c', 'libtypec_dbgfs_ops.c', soversion : '1')
\ No newline at end of file
+library('typec',
+ 'libtypec.c',
+ 'libtypec_sysfs_ops.c',
+ 'libtypec_dbgfs_ops.c',
+ version : '0.5.1',
+ soversion : '5',
+ dependencies: libudev_dep,
+)
\ No newline at end of file
diff --git a/utils/meson.build b/utils/meson.build
index d901167..8519541 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -6,7 +6,7 @@ default_options : [
conf_data = configuration_data()
conf_data.set('libtypec_utils_VERSION_MAJOR', '0')
conf_data.set('libtypec_utils_VERSION_MINOR', '5')
-conf_data.set('libtypec_utils_VERSION_PATCH', '0')
+conf_data.set('libtypec_utils_VERSION_PATCH', '1')
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
--
2.44.1

View File

@@ -0,0 +1,74 @@
From b59c48ce61eeca56742a4164f42139997cf84363 Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Tue, 21 May 2024 11:52:05 +0300
Subject: [PATCH 3/3] meson.build: install lib and headers
This ensures lib and headers are properly installed in
meson build, without having to hardcode for eg the builddir.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 7 +++++++
utils/meson.build | 25 +++++++++++++++++++++----
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index 7a7c28a..903c506 100644
--- a/meson.build
+++ b/meson.build
@@ -21,4 +21,11 @@ library('typec',
version : meson.project_version(),
soversion : '5',
dependencies: libudev_dep,
+ install: true,
+)
+
+install_headers(
+ 'libtypec.h',
+ meson.current_build_dir() + '/libtypec_config.h',
+ install_dir: 'include'
)
diff --git a/utils/meson.build b/utils/meson.build
index 9bd2245..7796d0a 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -12,13 +12,30 @@ conf_data.set('libtypec_utils_VERSION_PATCH', split[2])
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
+# Include current build dir for the above generated file
+inc_dir = include_directories('.')
+
cc = meson.get_compiler('c')
dep = declare_dependency(
- dependencies : cc.find_library('typec', dirs : [meson.current_source_dir()]),
- include_directories : include_directories('../../builddir/'),
+ dependencies : cc.find_library('typec')
)
+
udev_dep = meson.get_compiler('c').find_library('udev')
-executable('lstypec', 'lstypec.c', 'names.c' ,dependencies : [dep,udev_dep])
-executable('typecstatus', 'typecstatus.c', 'names.c',dependencies : [dep,udev_dep])
+executable(
+ 'lstypec',
+ 'lstypec.c', 'names.c',
+ dependencies: [dep, udev_dep],
+ include_directories: inc_dir,
+ install: true,
+ install_dir: get_option('bindir')
+)
+executable(
+ 'typecstatus',
+ 'typecstatus.c', 'names.c',
+ dependencies: [dep, udev_dep],
+ include_directories: inc_dir,
+ install: true,
+ install_dir: get_option('bindir')
+)
--
2.44.1

View File

@@ -0,0 +1,73 @@
From 56f5af15bc4796cf903ef5e9f82ed8514190e6bf Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Tue, 21 May 2024 10:38:37 +0300
Subject: [PATCH 2/3] meson.build: reduce version duplication
Gentoo dev Matt Turner asked us to reduce version duplication
in the meson.build files, to decrease the risks of getting
the version wrong like in the past by forgetting to bump the
minor version everywhere the version number is hardcoded.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 11 ++++++-----
utils/meson.build | 9 +++++----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/meson.build b/meson.build
index 5512f77..7a7c28a 100644
--- a/meson.build
+++ b/meson.build
@@ -5,9 +5,10 @@ default_options : [
'warning_level=0'])
conf_data = configuration_data()
-conf_data.set('libtypec_VERSION_MAJOR', '0')
-conf_data.set('libtypec_VERSION_MINOR', '5')
-conf_data.set('libtypec_VERSION_PATCH', '1')
+split = meson.project_version().split('.')
+conf_data.set('libtypec_VERSION_MAJOR', split[0])
+conf_data.set('libtypec_VERSION_MINOR', split[1])
+conf_data.set('libtypec_VERSION_PATCH', split[2])
libudev_dep = dependency('libudev', required: true)
@@ -17,7 +18,7 @@ library('typec',
'libtypec.c',
'libtypec_sysfs_ops.c',
'libtypec_dbgfs_ops.c',
- version : '0.5.1',
+ version : meson.project_version(),
soversion : '5',
dependencies: libudev_dep,
-)
\ No newline at end of file
+)
diff --git a/utils/meson.build b/utils/meson.build
index 8519541..9bd2245 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -1,13 +1,14 @@
project('libtypec_utils','c',
license: 'MIT',
+version: '0.5.1',
default_options : [
'warning_level=0'])
conf_data = configuration_data()
-conf_data.set('libtypec_utils_VERSION_MAJOR', '0')
-conf_data.set('libtypec_utils_VERSION_MINOR', '5')
-conf_data.set('libtypec_utils_VERSION_PATCH', '1')
-
+split = meson.project_version().split('.')
+conf_data.set('libtypec_utils_VERSION_MAJOR', split[0])
+conf_data.set('libtypec_utils_VERSION_MINOR', split[1])
+conf_data.set('libtypec_utils_VERSION_PATCH', split[2])
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
--
2.44.1

View File

@@ -0,0 +1,41 @@
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit meson
DESCRIPTION="Library to interface with USB Type-C/Power Delivery devices"
HOMEPAGE="https://github.com/libtypec/libtypec"
SRC_URI="https://github.com/libtypec/libtypec/archive/refs/tags/libtypec-${PV}.tar.gz"
PATCHES=(
"${FILESDIR}"/${PN}-0.5.1-meson-fix-build-based-on-Gentoo-testing.patch
"${FILESDIR}"/${PN}-0.5.1-meson.build-reduce-version-duplication.patch
"${FILESDIR}"/${PN}-0.5.1-meson.build-install-lib-and-headers.patch
)
S="${WORKDIR}/libtypec-libtypec-${PV}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
BDEPEND="
virtual/pkgconfig
"
DEPEND="
dev-libs/libtypec
virtual/udev
"
RDEPEND="${DEPEND}"
src_compile() {
# Build just the utils subproject
meson setup --reconfigure utils utils_build --prefix="${EPREFIX}/usr" || die
}
src_install() {
# Install just the utils subproject
cd utils_build && DESTDIR="${D}" meson install || die
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<longdescription>
“libtypec” is aimed to provide a generic interface abstracting all
platform complexity for user space to develop tools for efficient
USB-C port management. The library can also enable development of
diagnostic and debug tools to debug system issues around USB-C/USB
PD topology.
</longdescription>
<maintainer type="person" proxied="yes">
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</maintainer>
<maintainer type="project" proxied="proxy">
<email>proxy-maint@gentoo.org</email>
<name>Proxy Maintainers</name>
</maintainer>
<upstream>
<maintainer>
<name>Rajaram Regupathy</name>
<email>rajaram.regupathy@gmail.com</email>
</maintainer>
<remote-id type="github">Rajaram-Regupathy/libtypec</remote-id>
</upstream>
</pkgmetadata>

View File

@@ -0,0 +1,76 @@
From 36a5bd5a1aeccba392d9a764be0f7651d08d33ce Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Mon, 20 May 2024 17:37:19 +0300
Subject: [PATCH 1/3] meson: fix build based on Gentoo testing
While releasing v0.5.1 upstream forgot to also bump the
meson build version. :) The meson project version was
also not set.
There are also two discrepancies between meson and cmake:
1. meson installs libtypec.so.1 whereas cmake installs
libtypec.so.0.5.1.
2. meson uses soversion = 0 for the ABI version while
cmake uses 5.
We fix these discrepancies so that mesan installs the
same files as cmake.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 13 +++++++++++--
utils/meson.build | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index a581926..5512f77 100644
--- a/meson.build
+++ b/meson.build
@@ -1,14 +1,23 @@
project('libtypec','c',
license: 'MIT',
+version: '0.5.1',
default_options : [
'warning_level=0'])
conf_data = configuration_data()
conf_data.set('libtypec_VERSION_MAJOR', '0')
conf_data.set('libtypec_VERSION_MINOR', '5')
-conf_data.set('libtypec_VERSION_PATCH', '0')
+conf_data.set('libtypec_VERSION_PATCH', '1')
+libudev_dep = dependency('libudev', required: true)
configure_file(input : 'libtypec_config.h.in', output : 'libtypec_config.h', configuration : conf_data)
-both_libraries('typec', 'libtypec.c', 'libtypec_sysfs_ops.c', 'libtypec_dbgfs_ops.c', soversion : '1')
\ No newline at end of file
+library('typec',
+ 'libtypec.c',
+ 'libtypec_sysfs_ops.c',
+ 'libtypec_dbgfs_ops.c',
+ version : '0.5.1',
+ soversion : '5',
+ dependencies: libudev_dep,
+)
\ No newline at end of file
diff --git a/utils/meson.build b/utils/meson.build
index d901167..8519541 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -6,7 +6,7 @@ default_options : [
conf_data = configuration_data()
conf_data.set('libtypec_utils_VERSION_MAJOR', '0')
conf_data.set('libtypec_utils_VERSION_MINOR', '5')
-conf_data.set('libtypec_utils_VERSION_PATCH', '0')
+conf_data.set('libtypec_utils_VERSION_PATCH', '1')
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
--
2.44.1

View File

@@ -0,0 +1,74 @@
From b59c48ce61eeca56742a4164f42139997cf84363 Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Tue, 21 May 2024 11:52:05 +0300
Subject: [PATCH 3/3] meson.build: install lib and headers
This ensures lib and headers are properly installed in
meson build, without having to hardcode for eg the builddir.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 7 +++++++
utils/meson.build | 25 +++++++++++++++++++++----
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index 7a7c28a..903c506 100644
--- a/meson.build
+++ b/meson.build
@@ -21,4 +21,11 @@ library('typec',
version : meson.project_version(),
soversion : '5',
dependencies: libudev_dep,
+ install: true,
+)
+
+install_headers(
+ 'libtypec.h',
+ meson.current_build_dir() + '/libtypec_config.h',
+ install_dir: 'include'
)
diff --git a/utils/meson.build b/utils/meson.build
index 9bd2245..7796d0a 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -12,13 +12,30 @@ conf_data.set('libtypec_utils_VERSION_PATCH', split[2])
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
+# Include current build dir for the above generated file
+inc_dir = include_directories('.')
+
cc = meson.get_compiler('c')
dep = declare_dependency(
- dependencies : cc.find_library('typec', dirs : [meson.current_source_dir()]),
- include_directories : include_directories('../../builddir/'),
+ dependencies : cc.find_library('typec')
)
+
udev_dep = meson.get_compiler('c').find_library('udev')
-executable('lstypec', 'lstypec.c', 'names.c' ,dependencies : [dep,udev_dep])
-executable('typecstatus', 'typecstatus.c', 'names.c',dependencies : [dep,udev_dep])
+executable(
+ 'lstypec',
+ 'lstypec.c', 'names.c',
+ dependencies: [dep, udev_dep],
+ include_directories: inc_dir,
+ install: true,
+ install_dir: get_option('bindir')
+)
+executable(
+ 'typecstatus',
+ 'typecstatus.c', 'names.c',
+ dependencies: [dep, udev_dep],
+ include_directories: inc_dir,
+ install: true,
+ install_dir: get_option('bindir')
+)
--
2.44.1

View File

@@ -0,0 +1,73 @@
From 56f5af15bc4796cf903ef5e9f82ed8514190e6bf Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Tue, 21 May 2024 10:38:37 +0300
Subject: [PATCH 2/3] meson.build: reduce version duplication
Gentoo dev Matt Turner asked us to reduce version duplication
in the meson.build files, to decrease the risks of getting
the version wrong like in the past by forgetting to bump the
minor version everywhere the version number is hardcoded.
Upstream-Status: In progress [https://github.com/libtypec/libtypec/pull/1]
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
meson.build | 11 ++++++-----
utils/meson.build | 9 +++++----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/meson.build b/meson.build
index 5512f77..7a7c28a 100644
--- a/meson.build
+++ b/meson.build
@@ -5,9 +5,10 @@ default_options : [
'warning_level=0'])
conf_data = configuration_data()
-conf_data.set('libtypec_VERSION_MAJOR', '0')
-conf_data.set('libtypec_VERSION_MINOR', '5')
-conf_data.set('libtypec_VERSION_PATCH', '1')
+split = meson.project_version().split('.')
+conf_data.set('libtypec_VERSION_MAJOR', split[0])
+conf_data.set('libtypec_VERSION_MINOR', split[1])
+conf_data.set('libtypec_VERSION_PATCH', split[2])
libudev_dep = dependency('libudev', required: true)
@@ -17,7 +18,7 @@ library('typec',
'libtypec.c',
'libtypec_sysfs_ops.c',
'libtypec_dbgfs_ops.c',
- version : '0.5.1',
+ version : meson.project_version(),
soversion : '5',
dependencies: libudev_dep,
-)
\ No newline at end of file
+)
diff --git a/utils/meson.build b/utils/meson.build
index 8519541..9bd2245 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -1,13 +1,14 @@
project('libtypec_utils','c',
license: 'MIT',
+version: '0.5.1',
default_options : [
'warning_level=0'])
conf_data = configuration_data()
-conf_data.set('libtypec_utils_VERSION_MAJOR', '0')
-conf_data.set('libtypec_utils_VERSION_MINOR', '5')
-conf_data.set('libtypec_utils_VERSION_PATCH', '1')
-
+split = meson.project_version().split('.')
+conf_data.set('libtypec_utils_VERSION_MAJOR', split[0])
+conf_data.set('libtypec_utils_VERSION_MINOR', split[1])
+conf_data.set('libtypec_utils_VERSION_PATCH', split[2])
configure_file(input : 'libtypec_utils_config.h.in', output : 'libtypec_utils_config.h', configuration : conf_data)
--
2.44.1

View File

@@ -0,0 +1,33 @@
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit meson
DESCRIPTION="Library to interface with USB Type-C/Power Delivery devices"
HOMEPAGE="https://github.com/libtypec/libtypec"
SRC_URI="https://github.com/libtypec/libtypec/archive/refs/tags/${P}.tar.gz"
PATCHES=(
"${FILESDIR}"/${PN}-0.5.1-meson-fix-build-based-on-Gentoo-testing.patch
"${FILESDIR}"/${PN}-0.5.1-meson.build-reduce-version-duplication.patch
"${FILESDIR}"/${PN}-0.5.1-meson.build-install-lib-and-headers.patch
)
S="${WORKDIR}/${PN}-${P}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
BDEPEND="
virtual/pkgconfig
"
DEPEND="
virtual/libudev
"
RDEPEND="
${DEPEND}
!<dev-libs/libtypec-0.5.1-r1
"

View File

@@ -1,24 +0,0 @@
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit cmake
DESCRIPTION="Library to interface with USB Type-c/Power Delivery devices"
HOMEPAGE="https://github.com/libtypec/libtypec"
SRC_URI="https://github.com/libtypec/libtypec/archive/refs/tags/${P}.tar.gz"
S="${WORKDIR}/${PN}-${P}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
src_configure() {
# don't force CFLAGS to allow Gentoo toolchain to set them
local mycmakeargs=(
-DLIBTYPEC_STRICT_CFLAGS=OFF
)
cmake_src_configure
}

View File

@@ -8,15 +8,19 @@
diagnostic and debug tools to debug system issues around USB-C/USB
PD topology.
</longdescription>
<maintainer type="person">
<maintainer type="person" proxied="yes">
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</maintainer>
<maintainer type="person">
<name>Rajaram Regupathy</name>
<email>rajaram.regupathy@gmail.com</email>
<maintainer type="project" proxied="proxy">
<email>proxy-maint@gentoo.org</email>
<name>Proxy Maintainers</name>
</maintainer>
<upstream>
<maintainer>
<name>Rajaram Regupathy</name>
<email>rajaram.regupathy@gmail.com</email>
</maintainer>
<remote-id type="github">Rajaram-Regupathy/libtypec</remote-id>
</upstream>
</pkgmetadata>