Browse Source

Add options to build PDF-TOOLS and package it.

tmp/comercial-emacs
Juan Jose Garcia-Ripoll 4 years ago
parent
commit
3688540f00
  1. 4
      emacs-build.sh
  2. 132
      extras/pdf-tools.sh
  3. 19
      extras/tools.sh

4
emacs-build.sh

@ -29,6 +29,7 @@
#
. extras/tools.sh
. extras/pdf-tools.sh
function write_help () {
cat <<EOF
@ -214,7 +215,7 @@ lib/.*.a
lib/cmake
lib/gettext/intl
lib/pkgconfig
lib/python3.8
lib/python*
share/aclocal
share/doc/gettext
share/doc/libasprintf
@ -254,6 +255,7 @@ while test -n "$*"; do
--build) actions="$actions action2_build";;
--deps) actions="$actions action3_package_deps";;
--package) actions="$actions action4_package";;
--pdf-tools) actions="$actions action3_pdf_tools";;
--help) write_help; exit 0;;
esac
shift

132
extras/pdf-tools.sh

@ -0,0 +1,132 @@
# Copyright 2020 Juan Jose Garcia-Ripoll
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
########################################
#
# PDF-TOOLS
#
# Extra components to build and configure PDF-TOOLS in MSYS2/Mingw64
#
pdf_tools_repo="https://github.com/politza/pdf-tools"
pdf_tools_branch="master"
pdf_tools_dependencies=""
pdf_tools_packages="poppler glib2"
function action3_pdf_tools ()
{
pdf_tools_source_dir="$emacs_build_git_dir/pdf-tools"
pdf_tools_server_dir="$pdf_tools_source_dir/server"
pdf_tools_build_dir="$emacs_build_build_dir/pdf-tools-$architecture"
pdf_tools_install_dir="$emacs_build_install_dir/pdf-tools-$architecture"
pdf_tools_log_file="$pdf_tools_build_dir/log"
pdf_tools_zip_file="$emacs_build_zip_dir/pdf-tools-${architecture}.zip"
if test ! -f "$emacs_install_dir/bin/emacs.exe"; then
echo You must build Emacs first using --build before PDF-TOOLS
echo
return -1
fi
pdf_tools_package
exit 0
rm -f $pdf_tools_log_file
pdf_tools_ensure_packages \
&& pdf_tools_clone \
&& prepare_source_dir "$pdf_tools_server_dir" \
&& rm -rf "$pdf_tools_build_dir" \
&& prepare_build_dir "$pdf_tools_build_dir" \
&& pdf_tools_configure \
&& pdf_tools_build \
&& pdf_tools_install \
&& pdf_tools_package
}
function pdf_tools_ensure_packages ()
{
ensure_packages `pdf_tools_dependencies`
}
function pdf_tools_clone ()
{
clone_repo $pdf_tools_branch $pdf_tools_repo $pdf_tools_source_dir
if test "$?" = 0; then
echo Prepping the PDF-TOOLS server for running
cd $pdf_tools_server_dir
./autogen.sh
fi
return $?
}
function pdf_tools_dependencies ()
{
# Print the list of all mingw/msys packages required for running emacs with
# the selected features. Cache the result value.
#
if test -z "$pdf_tools_dependencies"; then
errcho "Inspecting required packages for PDF-TOOLS: $pdf_tools_packages"
local pdf_tools_all_dependencies=`full_dependency_list "$pdf_tools_packages"`
local emacs_all_dependencies=`emacs_dependencies`
pdf_tools_dependencies=`elements_not_in_list "$pdf_tools_all_dependencies" "$emacs_all_dependencies"`
errcho Total packages required:
errcho `echo $pdf_tools_dependencies | sed -e 's, ,\n,g' -`
fi
echo $pdf_tools_dependencies
}
function pdf_tools_configure ()
{
cd $pdf_tools_build_dir && \
"$pdf_tools_server_dir/configure" \
"--prefix=$pdf_tools_install_dir" > $pdf_tools_log_file 2>&1
}
function pdf_tools_build ()
{
echo Building PDF-TOOLS into directory $pdf_tools_build_dir
make -C $pdf_tools_build_dir > $pdf_tools_log_file 2>&1
}
function pdf_tools_byte_compile ()
{
local lispdir="$pdf_tools_install_dir/share/emacs/site-lisp/"
cd $lispdir
$emacs_install_dir/bin/emacs -Q -batch -L . -f batch-byte-compile *.el || echo Failed
}
function pdf_tools_install ()
{
local lispdir="$pdf_tools_install_dir/share/emacs/site-lisp/pdf-tools"
local bindir="$pdf_tools_install_dir/bin"
local docdir="$pdf_tools_install_dir/share/doc/pdf-tools"
echo Installing PDF-TOOLS into directory $pdf_tools_install_dir
mkdir -p $bindir $lispdir $docdir \
&& cp $pdf_tools_source_dir/{README*,COPYING*,NEWS} $docdir/ \
&& cp -rf $pdf_tools_source_dir/lisp/* $lispdir \
&& cp $pdf_tools_build_dir/epdfinfo.exe $bindir
}
function pdf_tools_package ()
{
package_dependencies "$pdf_tools_zip_file" "`pdf_tools_dependencies`" \
&& cd "$pdf_tools_install_dir" \
&& zip -9r "$pdf_tools_zip_file" *
}

19
extras/tools.sh

@ -3,6 +3,24 @@ function errcho ()
echo $@ >&2
}
function elements_not_in_list ()
{
output=""
for element in $1; do
for other in $2; do
found=""
if test "$element" = "$other"; then
found="$element"
break
fi
done
if test -z "$found"; then
output="$element $output"
fi
done
echo $output
}
function clone_repo ()
{
# Download a Git repo
@ -44,7 +62,6 @@ function clone_repo ()
return $?
}
function full_dependency_list ()
{
# Given a list of packages, print a list of all dependencies

Loading…
Cancel
Save