ScintillaOrg / lexilla

A library of language lexers for use with Scintilla
https://www.scintilla.org/Lexilla.html
Other
186 stars 67 forks source link

Support out of tree builds #266

Closed rhaberkorn closed 2 months ago

rhaberkorn commented 2 months ago

When integrating Scintilla and Lexilla into their parent projects, authors are faced with a dilemma: Their Makefiles do not install the libraries and few operating systems provide ready to use packages. You have to copy or link to the upstream sources and build them as part of your "meta" build system. Either you reproduce their Makefile rules and port them to Autotools or CMake or you recurse Make into Scintilla/Lexilla. For SciTECO I have always done the latter, as it reduces the maintenance overhead when bumping versions. As a consequence however, you will have to live with the restrictions of the Scintilla/Lexilla Makefiles. In particular, they don't support out of tree builds, which is a staple with other build systems like CMake or Autotools.

I suggest to add some kind of out-of-tree build support to the official Scintilla/Lexilla Makefiles. I could help with this, but would like to hear the opinion of @nyamatongwe first. Perhaps he will outright refuse.

Unfortunately, just setting VPATH on the make-command-line does not suffice due to a number of relative paths used for -I. Either we try to work around that by inferring the source directory from one of the source files in VPATH; or we simply rely on being told where to output files by the make-caller. I suggest adding a variable like BUILDDIR=. and prefix all output file paths with it. The bin vs. src output directory separation could be kept. In order to perform an out-of-tree build, the make-caller could first mkdir -p both the bin and src directory - or perhaps we just include a Makefile rule doing that - and then invoke make -C from the original source directory, overwriting BUILDDIR from the command line. For instance:

mkdir -p build/lexilla/src build/lexilla/bin
make -C lexilla/src BUILDDIR=$PWD/build/lexilla/src
rhaberkorn commented 2 months ago

Oh I just realize that there already is DIR_O in Lexilla. DepGen.py does not use it, but that shouldn't hurt since deps.mak is checked into the repo. It's just not in Scintilla, at least not in gtk/makefile. So if at all, I should file a Scintilla feature request over there on Sourceforge.

rhaberkorn commented 2 months ago

PS: You should use SCINTILLA_INCLUDE in the vpath statement as well.

nyamatongwe commented 2 months ago

It's just not in Scintilla, at least not in gtk/makefile.

This is implemented in the opposite direction by specifying source location srcdir through this contribution. Changing gtk/makefile to use DIR_O may break downstream projects.

https://sourceforge.net/p/scintilla/scite/ci/5a17576bcca0aba10d228e6a20dac563a11ec285/ https://sourceforge.net/p/scintilla/feature-requests/1154/

rhaberkorn commented 2 months ago

It works. Well, almost. The deps.mak generation does not yet take srcdir into account. And even if it worked, it would always regenerate deps.mak and draw in an unnecessary Python dependency. I can work around that by just touching it, but you should fix it upstream.

Also, I will have to add srcdir/basedir support to Scinterm as well.

nyamatongwe commented 2 months ago

but you should fix it upstream

This isn't something I use. Its up to the people that want out of tree builds to maintain that feature.