Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rdipardo committed Nov 28, 2023
0 parents commit 7250943
Show file tree
Hide file tree
Showing 31 changed files with 10,648 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .circleci/build_geany.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# SPDX-FileCopyrightText: (c) 2023 Robert Di Pardo
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Permitted usage is detailed in the COPYING file.
#
# https://circleci.com/docs/2.0/orbs-best-practices/#check-for-root
if [[ $EUID == 0 ]]; then export SUDO=''; else export SUDO='sudo'; fi
$SUDO apt update && $SUDO apt install -qqy --no-install-recommends \
build-essential \
autopoint \
ccache \
gettext \
intltool \
libtool \
libgtk-3-dev
NOCONFIGURE=1 ./autogen.sh
mkdir -p _build && cd _build
CFLAGS='-g -O0' \
../configure --prefix=/usr \
--disable-html-docs \
--disable-pdf-docs \
--disable-api-docs \
--disable-gtkdoc-header \
--enable-binreloc=no
make -j4 && $SUDO make install && $SUDO ldconfig
36 changes: 36 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2.1
#
# SPDX-FileCopyrightText: (c) 2023 Robert Di Pardo
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Permitted usage is detailed in the COPYING file.
#
orbs:
lazarus: rdipardo/lazarus@2
jobs:
linux-make-all:
machine:
image: ubuntu-2204:current
resource_class: medium
steps:
- checkout
- lazarus/install:
lazarus-version: '3.0.0'
platform: 'linux'
- run:
name: Fetch Geany source tree
command: |
git reset --hard
git submodule sync --recursive
git submodule update --init --recursive
- run:
name: Build Geany
command: bash ../.circleci/build_geany.sh
working_directory: geany
- run:
name: Build package and sample project
command: make
workflows:
test-deploy:
jobs:
- linux-make-all
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text eol=lf
*.inc linguist-language=Pascal
*.png binary
*.ico binary
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*~
*.bak
*.res
*.zip
*.exe
*.dll
*.so
*.dcu
*.dci
*.dcp
*.dsk
*.dof
*.h
*.o
*.or
*.ppu
*.drc
*.lps
*.local
*.tmp
**/gtk3.cfg
**/[Dd]efault/*
**/[Dd]ebug/*
**/[Rr]elease/*
**/[Ll]ib/**/*
**/[Bb]in/**/*
**/backup/
**/docs/html
!src/h2pas*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "geany"]
path = geany
url = https://github.com/geany/geany.git
604 changes: 604 additions & 0 deletions COPYING

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Builds the fpgeanyplugin package and sample project.
#
# SPDX-FileCopyrightText: (c) 2023 Robert Di Pardo
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Permitted usage is detailed in the COPYING file.
#
.PHONY: all clean deps plugin clean-deps geany-deps

PACKAGE = fpgeanyplugin
GEANY_VERSION_TAG ?= 2.0.0

PPC ?= /usr/bin/ppcx64
PPCFLAGS = -MObjFPC
DEFINES = -dLCL -dLCLgtk3
VERBOSITY = -l -vewnibq -vm5023
BUILD_MODE = Release

ifdef DEBUG
PPCFLAGS += -Scagi -CirotR -O1 -g -gl -gh -Xg -gt
BUILD_MODE = Debug
else
PPCFLAGS += -Scgi -O3 -Xs -XX
endif

ifdef SEARCH_PATHS
VERBOSITY += -vt
endif

ifdef LOGGING
VERBOSITY += -vv
endif

ifdef QUIET
VERBOSITY = -v0
endif

OUT_DIR = $(shell $(PPC) -iTP)-$(shell $(PPC) -iTO)/$(BUILD_MODE)
PPCFLAGS += -FE./lib/$(OUT_DIR) -Fi./lib/$(OUT_DIR) -Fu./lib/$(OUT_DIR) -Fu./src @gtk3.cfg

all: plugin

$(PACKAGE): deps lib/$(OUT_DIR)
$(PPC) $(PPCFLAGS) $(DEFINES) $(VERBOSITY) $(PACKAGE).pas

plugin: $(PACKAGE) example/bin/$(OUT_DIR)
$(PPC) $(PPCFLAGS) -FU./example/bin/$(OUT_DIR) $(DEFINES) $(VERBOSITY) \
-o./example/bin/$(OUT_DIR)/$(PACKAGE)demo.$(if $(findstring Win,$(OS)),dll -WR,so -Cg) \
example/$(PACKAGE)demo.lpr

deps:
@./scripts/build_gtk3_widgets $(BUILD_MODE)

geany-deps:
@./scripts/parse_headers $(GEANY_VERSION_TAG)

clean-deps:
git clean -dxf src

clean:
-rm -rf lib/$(OUT_DIR)/* example/bin/$(OUT_DIR)/*

lib/$(OUT_DIR):
@mkdir -p $@

example/bin/$(OUT_DIR):
@mkdir -p $@
64 changes: 64 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
fpgeanyplugin package
=====================

|fpc| |cci-build-status|

:WARNING: This package depends on the ``gtk3bindings`` units
provided by the LCL's `GTK3 interface`_, which is still
considered alpha quality

.. _GTK3 interface: https://wiki.lazarus.freepascal.org/GTK3_Interface

Usage
------
fpgeanyplugin currently provides two units:

* geanyplugin - compatible with Geany >= 2.0 (API version 247)
* geanyplugin240 - compatible with Geany >= 1.38, < 2.0 (API version 240)

Include the package in a shared library project and add the appropriate
unit to the ``uses`` section. A subset of `Geany's plugin API`_ will be
callable from your Object Pascal code.

.. _Geany's plugin API: https://www.geany.org/manual/reference

Since they implement different versions of the same interface, you cannot
include both units in the same file. Use a conditional expression if your
project needs to target multiple API versions, e.g.,

.. code-block:: pascal
{$macro ON}
uses
{$if GEANY_API_VERSION > 246}
geanyplugin
{$else}
geanyplugin240
{$endif};
Development
-----------
Clone the source tree and submodules::

git clone --recursive https://github.com/rdipardo/fpgeanyplugin

Run ``make`` to build the package and a sample plugin.
See `<example/README>`_ for instructions on building with ``lazbuild``.

Run ``make geany-deps`` to transpile Geany's headers into Object Pascal.
The transpiler script will first check out the git tag of a Geany release.
Only versions 1.38 and 2.0 are currently supported.


Requirements
------------
* lazarus >= 3.0
* fpc >= 3.2

.. |cci-build-status| image:: https://circleci.com/gh/rdipardo/fpgeanyplugin.svg?style=svg
:alt: CircleCI
:target: https://circleci.com/gh/rdipardo/fpgeanyplugin

.. |fpc| image:: https://img.shields.io/github/languages/top/rdipardo/fpgeanyplugin?style=flat-square&color=lightblue&label=Free%20Pascal&logo=lazarus
:alt: Built with Free Pascal
40 changes: 40 additions & 0 deletions example/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Free Pascal Plugin Demo
=======================

About
-----

A simple Geany plugin using Free Pascal bindings to GTK3

Features
--------

* Adds a new button to Geany's toolbar

Building
--------

* `Install Lazarus`_

:NOTE: You will need at least version 3.0. The required GTK3 bindings
may also be available in a stable 2.2.x distribution, but they
are broken on Windows (`<https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39578>`_)

.. _Install Lazarus: https://wiki.freepascal.org/Installing_Lazarus_on_Linux#FPC_and_Lazarus_from_SourceForge

* Open a terminal and run::

lazbuild --ws=gtk3 fpgeanyplugindemo.lpr

* Move ``fpgeanyplugindemo.so`` (Linux, macOS) or ``fpgeanyplugindemo.dll`` (Windows) into Geany's plugin directory

* Start Geany and select "Free Pascal Plugin Demo" from the menu at ``Tools > Plugin Manager``

Requirements
------------

* geany >= 2.0, or, with ``-dFPGEANY_LEGACY_API``, geany >= 1.38, < 2.0
* lazarus >= 3.0
* fpc >= 3.2

.. vim: ft=rst
Loading

0 comments on commit 7250943

Please sign in to comment.