From f0175ab4d97a08b7ed65908e626c10b7e9359949 Mon Sep 17 00:00:00 2001 From: Giuseppe Penone Date: Sun, 2 Feb 2025 08:56:07 +0000 Subject: [PATCH 1/2] fixes for building on windows/msys2 --- .gitignore | 2 - build/msys2-geany-plugins-release.py | 122 +++++++++++++++++++++++++++ geanygendoc/docs/Makefile.am | 2 +- lsp/src/lsp-server.c | 1 + po/LINGUAS | 1 + po/Makevars | 82 ++++++++++++++++++ po/Rules-gmo | 12 +++ 7 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 build/msys2-geany-plugins-release.py create mode 100644 po/LINGUAS create mode 100644 po/Makevars create mode 100644 po/Rules-gmo diff --git a/.gitignore b/.gitignore index 8e209cc8c..ce9ef74a9 100644 --- a/.gitignore +++ b/.gitignore @@ -64,9 +64,7 @@ cscope.files /po/*.gmo /po/*.header /po/.intltool-merge-cache -/po/LINGUAS /po/Makefile.in.in -/po/Makevars /po/*.mo /po/*.pot /po/POTFILES diff --git a/build/msys2-geany-plugins-release.py b/build/msys2-geany-plugins-release.py new file mode 100644 index 000000000..9b86f635f --- /dev/null +++ b/build/msys2-geany-plugins-release.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 + +import os +import shutil +import sys +import glob +from subprocess import check_call +from os.path import exists, isfile, join + +""" +This script prepares a Geany release on Windows. +The following steps will be executed: +- strip binary files (geany.exe, plugin .dlls) +- sign binary files with certificate +- create installers +- sign installers +""" + +VERSION = '2.1' +# adjust paths to your needs ($HOME is used because expanduser() returns the Windows home directory) +BASE_DIR = join(os.environ['HOME'], 'geany_build') +SOURCE_DIR = join(os.environ['HOME'], 'git', 'geany-plugins') +RELEASE_DIR_ORIG = join(BASE_DIR, 'release', 'geany-plugins-orig') +RELEASE_DIR = join(BASE_DIR, 'release', 'geany-plugins') +BUNDLE_BASE_DIR = join(BASE_DIR, 'bundle') +BUNDLE_GEANY_PLUGINS = join(BASE_DIR, 'bundle', 'geany-plugins-dependencies') +INSTALLER_NAME = join(BASE_DIR, f'geany-plugins-{VERSION}_setup.exe') + +# signing params +SIGN_CERTIFICATE = join(BASE_DIR, 'codesign.pem') # adjust to your needs +SIGN_CERTIFICATE_KEY = join(BASE_DIR, 'codesign_key.pem') # adjust to your needs +SIGN_WEBSITE = 'https://www.geany.org' +SIGN_NAME = 'Geany-Plugins Binary' +SIGN_TIMESTAMP = 'https://zeitstempel.dfn.de/' + + +def run_command(*cmd): + print('Execute command: {}'.format(' '.join(cmd))) + check_call(cmd) + + +def prepare_release_dir(): + os.makedirs(RELEASE_DIR_ORIG, exist_ok=True) + if exists(RELEASE_DIR): + shutil.rmtree(RELEASE_DIR) + shutil.copytree(RELEASE_DIR_ORIG, RELEASE_DIR, symlinks=True, ignore=None) + + +def convert_text_files(*paths): + for item in paths: + files = glob.glob(item) + for filename in files: + if isfile(filename): + run_command('unix2dos', '--quiet', filename) + + +def strip_files(*paths): + for item in paths: + files = glob.glob(item) + for filename in files: + run_command('strip', filename) + + +def sign_files(*paths): + if not isfile(SIGN_CERTIFICATE_KEY): + print('Skipped signing {} as {} not found'.format(paths, SIGN_CERTIFICATE_KEY)) + return + for item in paths: + files = glob.glob(item) + for filename in files: + run_command( + 'osslsigncode', + 'sign', + '-verbose', + '-certs', SIGN_CERTIFICATE, + '-key', SIGN_CERTIFICATE_KEY, + '-n', SIGN_NAME, + '-i', SIGN_WEBSITE, + '-ts', SIGN_TIMESTAMP, + '-h', 'sha512', + '-in', filename, + '-out', f'{filename}-signed') + os.replace(f'{filename}-signed', filename) + + +def make_release(): + # copy the release dir as it gets modified implicitly by signing and converting files, we want to keep a pristine version before we start + prepare_release_dir() + + binary_files = ( + f'{RELEASE_DIR}/bin/libgeanypluginutils-0.dll', + f'{RELEASE_DIR}/lib/*.dll', + f'{RELEASE_DIR}/lib/geany/*.dll', + f'{RELEASE_DIR}/lib/geany-plugins/geanylua/libgeanylua.dll') + # strip binaries + strip_files(*binary_files) + # sign binaries + sign_files(*binary_files) + # unix2dos conversion + text_files = ( + f'{RELEASE_DIR}/share/doc/geany-plugins/*/AUTHORS', + f'{RELEASE_DIR}/share/doc/geany-plugins/*/COPYING', + f'{RELEASE_DIR}/share/doc/geany-plugins/*/ChangeLog', + f'{RELEASE_DIR}/share/doc/geany-plugins/*/NEWS', + f'{RELEASE_DIR}/share/doc/geany-plugins/*/README', + f'{RELEASE_DIR}/share/doc/geany-plugins/*/manual.rst') + convert_text_files(*text_files) + # create installer + run_command( + 'makensis', + '/WX', + '/V3', + f'/DGEANY_PLUGINS_RELEASE_DIR={RELEASE_DIR}', + f'/DDEPENDENCY_BUNDLE_DIR={BUNDLE_GEANY_PLUGINS}', + f'-DGEANY_PLUGINS_INSTALLER_NAME={INSTALLER_NAME}', + f'{SOURCE_DIR}/build/geany-plugins.nsi') + # sign installer + sign_files(f'{INSTALLER_NAME}') + + +if __name__ == '__main__': + make_release() diff --git a/geanygendoc/docs/Makefile.am b/geanygendoc/docs/Makefile.am index f3975b69e..bde0f83a2 100644 --- a/geanygendoc/docs/Makefile.am +++ b/geanygendoc/docs/Makefile.am @@ -15,6 +15,6 @@ dist_pluginhtmldoc_DATA = \ if BUILD_RST manual.html: manual.rst manual.css html4css1.css $(AM_V_GEN) $(RST2HTML) -d --strict \ - --stylesheet-path $(abs_srcdir)/html4css1.css,$(abs_srcdir)/manual.css \ + --stylesheet-path $(srcdir)/html4css1.css,$(srcdir)/manual.css \ $(srcdir)/manual.rst $@ endif BUILD_RST diff --git a/lsp/src/lsp-server.c b/lsp/src/lsp-server.c index 82180bd99..bac104c3c 100644 --- a/lsp/src/lsp-server.c +++ b/lsp/src/lsp-server.c @@ -45,6 +45,7 @@ # include "spawn/lspunixoutputstream.h" #endif +#include static void start_lsp_server(LspServer *server); static LspServer *lsp_server_init(gint ft); diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 000000000..dba8c7f72 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +be ca da de el es fr gl it ja kk nl pt pt_BR ru tr uk zh_CN diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 000000000..6525eb355 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,82 @@ +# Makefile variables for PO directory in any package using GNU gettext. +# +# Copyright (C) 2003-2019 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation gives +# unlimited permission to use, copy, distribute, and modify it. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = The Geany contributors + +# This tells whether or not to prepend "GNU " prefix to the package +# name that gets inserted into the header of the $(DOMAIN).pot file. +# Possible values are "yes", "no", or empty. If it is empty, try to +# detect it automatically by scanning the files in $(top_srcdir) for +# "GNU packagename" string. +PACKAGE_GNU = no + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = https://github.com/geany/geany/issues + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# context. Possible values are "yes" and "no". Set this to yes if the +# package uses functions taking also a message context, like pgettext(), or +# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. +USE_MSGCTXT = no + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = + +# These options get passed to msginit. +# If you want to disable line wrapping when writing PO files, add +# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and +# MSGINIT_OPTIONS. +MSGINIT_OPTIONS = + +# This tells whether or not to regenerate a PO file when $(DOMAIN).pot +# has changed. Possible values are "yes" and "no". Set this to no if +# the POT file is checked in the repository and the version control +# program ignores timestamps. +PO_DEPENDS_ON_POT = no + +# This tells whether or not to forcibly update $(DOMAIN).pot and +# regenerate PO files on "make dist". Possible values are "yes" and +# "no". Set this to no if the POT file and PO files are maintained +# externally. +DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po/Rules-gmo b/po/Rules-gmo new file mode 100644 index 000000000..5ff761e32 --- /dev/null +++ b/po/Rules-gmo @@ -0,0 +1,12 @@ +# Make sure the gmo files are regenerated when the po files are updated, +# without the need for manually calling `make update-gmo` or `make ll.gmo`. +# See e.g. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400453#24, I +# couldn't find any canonical info on this. + +DISTFILES.common += Rules-gmo + +# Make sure changing this files updates the generated Makefile +Makefile: Rules-gmo + +# Just make the gmo files a default dependency, the rest is done automatically. +all-yes: $(GMOFILES) From cedc15999f2f0369153fbae4e9d5ffb1ab24eb75 Mon Sep 17 00:00:00 2001 From: Giuseppe Penone Date: Wed, 5 Feb 2025 22:25:49 +0000 Subject: [PATCH 2/2] reverted unnecessary changes --- .gitignore | 2 + geanygendoc/docs/Makefile.am | 2 +- po/LINGUAS | 1 - po/Makevars | 82 ------------------------------------ po/Rules-gmo | 12 ------ 5 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 po/LINGUAS delete mode 100644 po/Makevars delete mode 100644 po/Rules-gmo diff --git a/.gitignore b/.gitignore index ce9ef74a9..8e209cc8c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,9 @@ cscope.files /po/*.gmo /po/*.header /po/.intltool-merge-cache +/po/LINGUAS /po/Makefile.in.in +/po/Makevars /po/*.mo /po/*.pot /po/POTFILES diff --git a/geanygendoc/docs/Makefile.am b/geanygendoc/docs/Makefile.am index bde0f83a2..f3975b69e 100644 --- a/geanygendoc/docs/Makefile.am +++ b/geanygendoc/docs/Makefile.am @@ -15,6 +15,6 @@ dist_pluginhtmldoc_DATA = \ if BUILD_RST manual.html: manual.rst manual.css html4css1.css $(AM_V_GEN) $(RST2HTML) -d --strict \ - --stylesheet-path $(srcdir)/html4css1.css,$(srcdir)/manual.css \ + --stylesheet-path $(abs_srcdir)/html4css1.css,$(abs_srcdir)/manual.css \ $(srcdir)/manual.rst $@ endif BUILD_RST diff --git a/po/LINGUAS b/po/LINGUAS deleted file mode 100644 index dba8c7f72..000000000 --- a/po/LINGUAS +++ /dev/null @@ -1 +0,0 @@ -be ca da de el es fr gl it ja kk nl pt pt_BR ru tr uk zh_CN diff --git a/po/Makevars b/po/Makevars deleted file mode 100644 index 6525eb355..000000000 --- a/po/Makevars +++ /dev/null @@ -1,82 +0,0 @@ -# Makefile variables for PO directory in any package using GNU gettext. -# -# Copyright (C) 2003-2019 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation gives -# unlimited permission to use, copy, distribute, and modify it. - -# Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) - -# These two variables depend on the location of this directory. -subdir = po -top_builddir = .. - -# These options get passed to xgettext. -XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 - -# This is the copyright holder that gets inserted into the header of the -# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding -# package. (Note that the msgstr strings, extracted from the package's -# sources, belong to the copyright holder of the package.) Translators are -# expected to transfer the copyright for their translations to this person -# or entity, or to disclaim their copyright. The empty string stands for -# the public domain; in this case the translators are expected to disclaim -# their copyright. -COPYRIGHT_HOLDER = The Geany contributors - -# This tells whether or not to prepend "GNU " prefix to the package -# name that gets inserted into the header of the $(DOMAIN).pot file. -# Possible values are "yes", "no", or empty. If it is empty, try to -# detect it automatically by scanning the files in $(top_srcdir) for -# "GNU packagename" string. -PACKAGE_GNU = no - -# This is the email address or URL to which the translators shall report -# bugs in the untranslated strings: -# - Strings which are not entire sentences, see the maintainer guidelines -# in the GNU gettext documentation, section 'Preparing Strings'. -# - Strings which use unclear terms or require additional context to be -# understood. -# - Strings which make invalid assumptions about notation of date, time or -# money. -# - Pluralisation problems. -# - Incorrect English spelling. -# - Incorrect formatting. -# It can be your email address, or a mailing list address where translators -# can write to without being subscribed, or the URL of a web page through -# which the translators can contact you. -MSGID_BUGS_ADDRESS = https://github.com/geany/geany/issues - -# This is the list of locale categories, beyond LC_MESSAGES, for which the -# message catalogs shall be used. It is usually empty. -EXTRA_LOCALE_CATEGORIES = - -# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' -# context. Possible values are "yes" and "no". Set this to yes if the -# package uses functions taking also a message context, like pgettext(), or -# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. -USE_MSGCTXT = no - -# These options get passed to msgmerge. -# Useful options are in particular: -# --previous to keep previous msgids of translated messages, -# --quiet to reduce the verbosity. -MSGMERGE_OPTIONS = - -# These options get passed to msginit. -# If you want to disable line wrapping when writing PO files, add -# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and -# MSGINIT_OPTIONS. -MSGINIT_OPTIONS = - -# This tells whether or not to regenerate a PO file when $(DOMAIN).pot -# has changed. Possible values are "yes" and "no". Set this to no if -# the POT file is checked in the repository and the version control -# program ignores timestamps. -PO_DEPENDS_ON_POT = no - -# This tells whether or not to forcibly update $(DOMAIN).pot and -# regenerate PO files on "make dist". Possible values are "yes" and -# "no". Set this to no if the POT file and PO files are maintained -# externally. -DIST_DEPENDS_ON_UPDATE_PO = yes diff --git a/po/Rules-gmo b/po/Rules-gmo deleted file mode 100644 index 5ff761e32..000000000 --- a/po/Rules-gmo +++ /dev/null @@ -1,12 +0,0 @@ -# Make sure the gmo files are regenerated when the po files are updated, -# without the need for manually calling `make update-gmo` or `make ll.gmo`. -# See e.g. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400453#24, I -# couldn't find any canonical info on this. - -DISTFILES.common += Rules-gmo - -# Make sure changing this files updates the generated Makefile -Makefile: Rules-gmo - -# Just make the gmo files a default dependency, the rest is done automatically. -all-yes: $(GMOFILES)