Skip to content

Commit

Permalink
dev-lang/squirrel: Fix pkg-config
Browse files Browse the repository at this point in the history
Signed-off-by: Haelwenn (lanodan) Monnier <[email protected]>
  • Loading branch information
lanodan committed Nov 18, 2024
1 parent 347f76a commit a5141d1
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 41 deletions.
3 changes: 1 addition & 2 deletions dev-lang/squirrel/Manifest
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
DIST squirrel-3.2.tar.gz 620486 BLAKE2B c03cee0dffc12ff48caa4a7c9c0fffec32cdfb23306f265b8475454b0b9f14a3d2ec620b0f2183de8e8bc83e4921d6853105ac1a8d37bf3f2d97e914a001c4fd SHA512 e488ccc07b851e1707f3fde923f691747b18dc2fcc4748d2a68f2590ab84a3c0db647c8ac9ee775796984d2302a3d3686459556ea0c49a0b96b1354fcb8a6c74
DIST squirrel-config.cmake.in_3.2 143 BLAKE2B e9e795a4f855f41206c5aca89b949c279f35dce06dad73c9153a9c03701f1721d831bdc29e3a399a2a6b2cf6e97d3a966008d81dfe955b2f5412c818d5a054bc SHA512 4820835a233b2beb5768b39e6b3ce5f06f1f9bc57c4c19df2c4f7ce2b03e67c18554c3084259317092d1eb0fee7d909bdbc56a9fc556f57ed61ef8b0f181996d
DIST squirrel-3.2.gh.tar.gz 182795 BLAKE2B 3ee5439d75fc4ff2e8e02ccc9d24e282348108288f6b0ac870638409fc38f75169885e1c01d9c98c5ce05218f4abc9923f9f81f5155ccf3a595329b0acfb5953 SHA512 1aff8e55b8439e06a80ca78edf0b32066ce6563a9e3e61fe9b0bfc18e930828fd08a20c01a88bb1b8c164cbd0dd62966619c565557cbf4761739f3749988485d
14 changes: 7 additions & 7 deletions dev-lang/squirrel/files/squirrel-3.2-CVE-2022-30292.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ index e2f248e..308d2cc 100644
--- a/squirrel/sqbaselib.cpp
+++ b/squirrel/sqbaselib.cpp
@@ -1149,6 +1149,7 @@ static SQInteger thread_call(HSQUIRRELVM v)
SQObjectPtr o = stack_get(v,1);
if(sq_type(o) == OT_THREAD) {
SQInteger nparams = sq_gettop(v);
+ sq_reservestack(_thread(o), nparams + 3);
_thread(o)->Push(_thread(o)->_roottable);
for(SQInteger i = 2; i<(nparams+1); i++)
sq_move(_thread(o),v,i);
SQObjectPtr o = stack_get(v,1);
if(sq_type(o) == OT_THREAD) {
SQInteger nparams = sq_gettop(v);
+ sq_reservestack(_thread(o), nparams + 3);
_thread(o)->Push(_thread(o)->_roottable);
for(SQInteger i = 2; i<(nparams+1); i++)
sq_move(_thread(o),v,i);
147 changes: 147 additions & 0 deletions dev-lang/squirrel/files/squirrel-3.2-pkg_config_pr264.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
From b37958bec41b9cbff0968f5ffe176609dce4ff55 Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier" <[email protected]>
Date: Sat, 14 Jan 2023 08:16:19 +0100
Subject: [PATCH] CMake: Generate and install squirrel.pc

Closes: https://github.com/albertodemichelis/squirrel/issues/259
---
CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++--
sqstdlib/CMakeLists.txt | 5 +----
squirrel.pc.in | 12 ++++++++++++
squirrel/CMakeLists.txt | 5 +----
4 files changed, 47 insertions(+), 10 deletions(-)
create mode 100644 squirrel.pc.in

Note: This patch got rebased on v3.2

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc35b6f..8ef293c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,10 @@
-cmake_minimum_required(VERSION 3.4)
-project(squirrel VERSION 3.1 LANGUAGES C CXX)
+cmake_minimum_required(VERSION 3.12)
+project(squirrel
+ VERSION 3.1
+ DESCRIPTION "The Squirrel programming language"
+ HOMEPAGE_URL "http://squirrel-lang.org/"
+ LANGUAGES C CXX
+ )

option(DISABLE_STATIC "Avoid building/installing static libraries.")
option(LONG_OUTPUT_NAMES "Use longer names for binaries and libraries: squirrel3 (not sq).")
@@ -33,6 +38,15 @@ elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

+# Need to be defined here to be visible to squirrel.pc.in
+if(LONG_OUTPUT_NAMES)
+ set(LIBSQUIRREL_NAME squirrel3)
+ set(SQSTDLIB_NAME sqstdlib3)
+else()
+ set(LIBSQUIRREL_NAME squirrel)
+ set(SQSTDLIB_NAME sqstdlib)
+endif()
+
add_subdirectory(squirrel)
add_subdirectory(sqstdlib)
add_subdirectory(sq)
@@ -92,6 +106,12 @@ export(EXPORT squirrel
FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-targets.cmake"
)

+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/squirrel.pc.in"
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
+ @ONLY
+)
+
if(NOT SQ_DISABLE_INSTALLER AND NOT SQ_DISABLE_CMAKE_INSTALLER)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/squirrel/squirrel-config-version.cmake"
@@ -100,6 +120,17 @@ if(NOT SQ_DISABLE_INSTALLER AND NOT SQ_DISABLE_CMAKE_INSTALLER)
COMPONENT Development
)

+ # pc(5) only allows static variant to have extra flags, not an entirely new
+ # set of flags. While it's uncommon, a way to do it would be to generate a
+ # ${PROJECT_NAME}_static.pc file.
+ if(NOT DISABLE_DYNAMIC)
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+ COMPONENT Development
+ )
+ endif()
+
install(EXPORT squirrel
NAMESPACE squirrel::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/squirrel"
diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt
index 34fba82..a606ba8 100644
--- a/sqstdlib/CMakeLists.txt
+++ b/sqstdlib/CMakeLists.txt
@@ -11,6 +11,7 @@ if(NOT DISABLE_DYNAMIC)
add_library(sqstdlib SHARED ${SQSTDLIB_SRC})
add_library(squirrel::sqstdlib ALIAS sqstdlib)
set_property(TARGET sqstdlib PROPERTY EXPORT_NAME sqstdlib)
+ set_property(TARGET sqstdlib PROPERTY OUTPUT_NAME ${SQSTDLIB_NAME})
target_link_libraries(sqstdlib squirrel)
if(NOT SQ_DISABLE_INSTALLER)
install(TARGETS sqstdlib EXPORT squirrel
@@ -42,10 +43,6 @@ if(NOT DISABLE_STATIC)
endif()

if(LONG_OUTPUT_NAMES)
- if(NOT DISABLE_DYNAMIC)
- set_target_properties(sqstdlib PROPERTIES OUTPUT_NAME sqstdlib3)
- endif()
-
if(NOT DISABLE_STATIC)
set_target_properties(sqstdlib_static PROPERTIES OUTPUT_NAME sqstdlib3_static)
endif()
diff --git a/squirrel.pc.in b/squirrel.pc.in
new file mode 100644
index 0000000..ea66485
--- /dev/null
+++ b/squirrel.pc.in
@@ -0,0 +1,12 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: @PROJECT_NAME@
+Version: @PROJECT_VERSION@
+Description: @PROJECT_DESCRIPTION@
+URL: @PROJECT_HOMEPAGE_URL@
+Requires:
+Provides: squirrel3 = @PROJECT_VERSION@
+Libs: -L${libdir} -l@LIBSQUIRREL_NAME@ -l@SQSTDLIB_NAME@
+Cflags: -I${includedir}
diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt
index f96b958..c8a31b9 100644
--- a/squirrel/CMakeLists.txt
+++ b/squirrel/CMakeLists.txt
@@ -15,6 +15,7 @@ if(NOT DISABLE_DYNAMIC)
add_library(squirrel SHARED ${SQUIRREL_SRC})
add_library(squirrel::squirrel ALIAS squirrel)
set_property(TARGET squirrel PROPERTY EXPORT_NAME squirrel)
+ set_property(TARGET squirrel PROPERTY OUTPUT_NAME ${LIBSQUIRREL_NAME})
if(NOT SQ_DISABLE_INSTALLER)
install(TARGETS squirrel EXPORT squirrel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Libraries
@@ -45,10 +46,6 @@ if(NOT DISABLE_STATIC)
endif()

if(LONG_OUTPUT_NAMES)
- if(NOT DISABLE_DYNAMIC)
- set_target_properties(squirrel PROPERTIES OUTPUT_NAME squirrel3)
- endif()
-
if(NOT DISABLE_STATIC)
set_target_properties(squirrel_static PROPERTIES OUTPUT_NAME squirrel3_static)
endif()
--
2.41.0

12 changes: 0 additions & 12 deletions dev-lang/squirrel/files/squirrel.pc.in

This file was deleted.

23 changes: 3 additions & 20 deletions dev-lang/squirrel/squirrel-3.2.ebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2022 Gentoo Authors
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
Expand All @@ -7,9 +7,7 @@ inherit cmake

DESCRIPTION="A interpreted language mainly used for games"
HOMEPAGE="http://squirrel-lang.org/"
# Missing file in the tarball, do the same as Mageia
SRC_URI="https://download.sourceforge.net/squirrel/${PN}_${PV/./_}_stable.tar.gz -> ${P}.tar.gz
https://raw.githubusercontent.com/albertodemichelis/squirrel/v${PV}/squirrel-config.cmake.in -> squirrel-config.cmake.in_${PV}"
SRC_URI="https://github.com/albertodemichelis/squirrel/archive/refs/tags/v3.2.tar.gz -> ${P}.gh.tar.gz"

LICENSE="ZLIB"
SLOT="0"
Expand All @@ -19,18 +17,12 @@ IUSE="examples static-libs"
RDEPEND=""
DEPEND="${RDEPEND}"

S="${WORKDIR}/${PN}3"

PATCHES=(
# Fixed in master
"${FILESDIR}/${P}-CVE-2022-30292.patch"
"${FILESDIR}/squirrel-3.2-pkg_config_pr264.patch"
)

src_prepare() {
cp "${DISTDIR}/squirrel-config.cmake.in_${PV}" "${S}/squirrel-config.cmake.in" || die
cmake_src_prepare
}

src_configure() {
local mycmakeargs=(
$(usex static-libs '' -DDISABLE_STATIC=YES)
Expand All @@ -51,13 +43,4 @@ src_install() {
docompress -x /usr/share/doc/${PF}/samples
dodoc -r samples
fi

# Add pkgconfig file, needed for some reverse deps (follows Mageia
# one)
# https://github.com/albertodemichelis/squirrel/issues/259
dodir /usr/$(get_libdir)/pkgconfig
sed \
-e "s/@libdir@/$(get_libdir)/" \
-e "s/@version@/${PV}/" \
"${FILESDIR}/${PN}.pc.in" > "${ED}/usr/$(get_libdir)/pkgconfig/${PN}.pc" || die
}

0 comments on commit a5141d1

Please sign in to comment.