Re: the ScriptingMojo

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Kartik Ohri <kartikohri13(at)gmail(dot)com>
Cc: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: the ScriptingMojo
Date: 2020-08-26 19:25:02
Message-ID: 5F46B70E.6070601@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 08/26/20 12:55, Kartik Ohri wrote:
> I have made some progress on the plugin. The Mac OS X configuration is
> working and passing the CI. I have also begun work on completing the
> Windows configuration. I am having some issues with the File.separator
> being used in paths. Once I am able to resolve it, we should have all the
> basic functionality ready. Also, I noticed that running pg_config in the
> Windows command line (MSVC) environment gives values of cc, cflags and
> ldflags so on as not recorded.

That rings a bell. I seem to recall that PostgreSQL's own build process,
when using MSVC, operates rather differently from other build environments.
A lot of what would be passed as command-line arguments to other compilers
or linkers will be used to generate 'project' or 'solution' files instead,
and MSVC reads those:

https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/tools/msvc/README;hb=HEAD

I have not delved into whether the nar-maven-plugin is doing something
similar under the hood.

PostgreSQL's src/tools/msvc seems to have around 2400 lines of Perl
dedicated to writing properly-formatted project and solution files.

(In reality, it's not really that bad, because that's the build system
/for PostgreSQL itself/, and a lot of the lines in Solution.pm are
devoted to writing the files like pg_config.h with the right values
in them. When building an extension, that just gets #include'd; it was
already written when PostgreSQL was built, so we don't have to generate it.)

The info on the (slightly less involved) needs for simply building an
extension with MSVC is here:

https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules#Windows_with_Microsoft_Visual_Studio

To me, translating a couple thousand lines of Perl to Java in order to
generate project and solution files would have a very unappetizing sound.

If the nar-maven-plugin is also generating such files when it uses MSVC
to build, then probably it also has some classes to help generating those
files (or it uses a dependency that has some classes to help generating
those files). It might not be too bad to end up adding that as a dependency
of the PGXS plugin (added by a profile conditioned on Windows os) in order
to reuse that part of its code, if it is accessible.

Regards,
-Chap

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-08-26 22:04:32 Re: the ScriptingMojo
Previous Message Kartik Ohri 2020-08-26 16:55:08 Re: the ScriptingMojo