Restore PERL bindings

This commit is contained in:
Gregory Hellings 2020-12-14 14:45:27 -06:00
parent e8736bb849
commit 8c2bff53f6
2 changed files with 122 additions and 13 deletions

105
cmake-perl-bindings.diff Normal file
View File

@ -0,0 +1,105 @@
diff -bru a/bindings/swig/perl/CMakeLists.txt b/bindings/swig/perl/CMakeLists.txt
--- a/bindings/swig/perl/CMakeLists.txt 2020-07-29 18:59:48.000000000 +0200
+++ b/bindings/swig/perl/CMakeLists.txt 2020-11-01 19:56:20.825016280 +0100
@@ -1,68 +1,35 @@
-# This method works but there is no good way to install the results of it
-#FIND_PACKAGE(PerlLibs REQUIRED)
-#INCLUDE_DIRECTORIES(${PERL_INCLUDE_PATH})
-#
-#SET_SOURCE_FILES_PROPERTIES(../sword.i PROPERTIES CPLUSPLUS ON)
-#SET_SOURCE_FILES_PROPERTIES(../sword.i PROPERTIES SWIG_FLAGS "")
-#
-#SWIG_ADD_MODULE(Sword perl
-# "../sword.i"
-#)
-#
-#SWIG_LINK_LIBRARIES(Sword ${PERL_LIBRARY} ${SWORD_LINK_NAME})
-
-FIND_PACKAGE(Perl REQUIRED)
-
-SET(PERL_MAKEFILE "#!${PERL_EXECUTABLE}
-
-use ExtUtils::MakeMaker;
-
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written
-WriteMakefile(
- 'NAME' => 'Sword',
- 'VERSION' => '${SWORD_VERSION}',
- 'INC' => '-I\"${CMAKE_SOURCE_DIR}/include\" -I\"${CMAKE_CURRENT_SOURCE_DIR}/..\"',
- 'DEFINE' => '-DSWIG',
- 'LIBS' => '-L\"${CMAKE_BINARY_DIR}\" -lsword -lz',
- 'FIRST_MAKEFILE' => 'Makefile.perlswig',
- 'PREREQ_PM' => {},
- ($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT => 'Sword Project perl bindings', # retrieve abstract from module
- AUTHOR => 'Sword Project <sword-devel@crosswire.org>') : ()),
-);
-
-rename 'Makefile.perlswig', 'Makefile.perlswig.old' or die \"Can't rename Makefile\";
-open(INPUT, '<Makefile.perlswig.old') or die \"Can't open input Makefile.old\";
-open(OUTPUT,'>Makefile.perlswig') or die \"Can't open output Makefile\";
-while (<INPUT>) {
- s/\\-lsword/\\-lsword \\-lstdc\\+\\+/;
- print OUTPUT \"$_\";
-}
-
-close INPUT;
-close OUTPUT;")
-FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Makefile.PL "${PERL_MAKEFILE}")
-
-SET(SKIP_MAKEFILE "\\.old
-~$
-\\.bak
-^CVS
-Makefile$")
-FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Makefile.SKIP "${SKIP_MAKEFILE}")
-
-SWORD_SWIG_GENERATE(perl)
-
-ADD_CUSTOM_COMMAND(OUTPUT MANIFEST Makefile.perlswig
- COMMAND ${PERL_EXECUTABLE} Makefile.PL && make -f Makefile.perlswig clean
- COMMAND ${PERL_EXECUTABLE} Makefile.PL && make -f Makefile.perlswig manifest
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-
-ADD_CUSTOM_TARGET(perlswig ALL
- COMMAND make -f Makefile.perlswig
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx ${CMAKE_CURRENT_BINARY_DIR}/Makefile.perlswig ${SWORD_LINK_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+# Perl Swig bindings
-INSTALL(SCRIPT install.cmake)
+cmake_minimum_required(VERSION 3.14.7)
+cmake_policy(SET CMP0078 NEW)
+cmake_policy(SET CMP0086 NEW)
+set(UseSWIG_MODULE_VERSION 2)
-MESSAGE(STATUS "Perl: yes")
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(PerlLibs REQUIRED)
+include_directories(${PERL_INCLUDE_PATH})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+
+set_source_files_properties(../sword.i PROPERTIES CPLUSPLUS ON)
+
+SWIG_ADD_LIBRARY(Sword
+ TYPE SHARED
+ LANGUAGE perl SOURCES ../sword.i
+ )
+TARGET_LINK_LIBRARIES(Sword ${PERL_LIBRARIES} ${SWORD_LINK_NAME})
+
+
+install(
+ TARGETS Sword
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}/perl5/vendor_perl/auto/Sword"
+)
+get_target_property(SWIG_BUILDIR Sword SWIG_SUPPORT_FILES_DIRECTORY)
+
+message(STATUS "SWIG_BUILDIR=${SWIG_BUILDIR}")
+install(
+ FILES ${SWIG_BUILDIR}/Sword.pm
+ DESTINATION "${LIB_INSTALL_DIR}/perl5/vendor_perl"
+)

View File

@ -20,9 +20,12 @@ BuildRequires: cppunit-devel
BuildRequires: swig BuildRequires: swig
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: perl-devel BuildRequires: perl-devel
BuildRequires: perl-macros
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++
Patch0: cmake-perl-bindings.diff
%description %description
The SWORD Project is the CrossWire Bible Society's free Bible software The SWORD Project is the CrossWire Bible Society's free Bible software
project. Its purpose is to create cross-platform open-source tools-- project. Its purpose is to create cross-platform open-source tools--
@ -64,20 +67,22 @@ Requires: python3
%description -n python3-sword %description -n python3-sword
Python bindings for The SWORD Library. Python bindings for The SWORD Library.
#%package -n perl-sword %package -n perl-sword
#%{?perl_provide:%perl_provide perl-sword} %{?perl_provide:%perl_provide perl-sword}
#Summary: Perl bindings for Sword Summary: Perl bindings for Sword
#Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{version}-%{release}
#Requires: perl Requires: perl
#Requires: perl-XML-LibXML Requires: perl-XML-LibXML
#Requires: perl-HTML-Strip Requires: perl-HTML-Strip
#%description -n perl-sword %description -n perl-sword
#Perl bindings for The SWORD Library. Perl bindings for The SWORD Library.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .perl
%build %build
%cmake -DLIBSWORD_LIBRARY_TYPE=Shared \ %cmake -DLIBSWORD_LIBRARY_TYPE=Shared \
-DSWORD_PYTHON_3:BOOL=TRUE \ -DSWORD_PYTHON_3:BOOL=TRUE \
@ -138,10 +143,9 @@ make tests
%{python3_sitearch}/__pycache__/* %{python3_sitearch}/__pycache__/*
%{python3_sitearch}/sword-%{pkg_version}-py%{python3_version}.egg-info %{python3_sitearch}/sword-%{pkg_version}-py%{python3_version}.egg-info
#%files -n perl-sword %files -n perl-sword
#%{perl_vendorarch}/* %{perl_vendorarch}/*
#%exclude %dir %{perl_vendorarch}/auto/ %exclude %dir %{perl_vendorarch}/auto/
#%exclude %{_libdir}/perl5/perllocal.pod
%changelog %changelog