Compiling C++ extensions on MSVC using scripts in src/tools

Lists: pgsql-hackers
From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-11-26 04:46:17
Message-ID: CAB7nPqSC3KPU7+AUBU48e8w29eQoTOxYGr1Fv0Zds5rj-shy9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

In the stuff I work on in a daily basis there are a couple of
extensions written in C++, compiling them with MSVC on Windows using
slightly-different scripts available in src/tools after copying them
directly in contrib/. However, the build scripts available in
src/tools/msvc are not able to detect files suffixed as cpp or
similar. Attached is a two-line patch that enables their detection. I
believe this would be useful for packagers on Windows.

Patch is added to the next commit fest.
Regards,
--
Michael

Attachment Content-Type Size
20141126_msvc_cpp.patch text/x-patch 1.1 KB

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-11-26 16:25:31
Message-ID: 5475FEFB.6090401@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 11/25/2014 11:46 PM, Michael Paquier wrote:
> Hi all,
>
> In the stuff I work on in a daily basis there are a couple of
> extensions written in C++, compiling them with MSVC on Windows using
> slightly-different scripts available in src/tools after copying them
> directly in contrib/. However, the build scripts available in
> src/tools/msvc are not able to detect files suffixed as cpp or
> similar. Attached is a two-line patch that enables their detection. I
> believe this would be useful for packagers on Windows.
>

+ unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl](pp)?$/);

This doesn't seem to me to be terribly well expressed (I know it's not your fault, quite possibly it's mine.) Perhaps we should replace

[r]?[cyl](pp)?

with

(c|cpp|y|l|rc)

which I think is what's intended, and seems much less obscure to me.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-11-26 16:40:09
Message-ID: 16430.1417020009@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> This doesn't seem to me to be terribly well expressed (I know it's not your fault, quite possibly it's mine.) Perhaps we should replace
> [r]?[cyl](pp)?
> with
> (c|cpp|y|l|rc)

+1 ... the original coding is illegible already, not to mention wrong
since it will match stuff it shouldn't.

regards, tom lane


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-11-27 04:39:13
Message-ID: CAB7nPqRNSqGzsDiMR9YCCErBUQHLFQYVJvEwHqJwvSqRyPS7GQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 27, 2014 at 1:40 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> This doesn't seem to me to be terribly well expressed (I know it's not your fault, quite possibly it's mine.) Perhaps we should replace
>> [r]?[cyl](pp)?
>> with
>> (c|cpp|y|l|rc)
>
> +1 ... the original coding is illegible already, not to mention wrong
> since it will match stuff it shouldn't.
Yes even the older code could find matches with ry or rl. Except that,
lpp and ypp could be present as well. OK, there are low chances to be
present in a Postgres extension (I don't have such extensions myself),
still they could. So I think that this expression should be written
like that instead:
(c|cpp|l|lpp|y|ypp|rc).
Updated patch is attached.
--
Michael

Attachment Content-Type Size
20141127_msvc_cpp_v2.patch text/x-patch 1.6 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-12-17 19:55:38
Message-ID: 5491DFBA.6010102@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/27/2014 06:39 AM, Michael Paquier wrote:
> On Thu, Nov 27, 2014 at 1:40 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>> This doesn't seem to me to be terribly well expressed (I know it's not your fault, quite possibly it's mine.) Perhaps we should replace
>>> [r]?[cyl](pp)?
>>> with
>>> (c|cpp|y|l|rc)
>>
>> +1 ... the original coding is illegible already, not to mention wrong
>> since it will match stuff it shouldn't.
> Yes even the older code could find matches with ry or rl. Except that,
> lpp and ypp could be present as well. OK, there are low chances to be
> present in a Postgres extension (I don't have such extensions myself),
> still they could. So I think that this expression should be written
> like that instead:
> (c|cpp|l|lpp|y|ypp|rc).
> Updated patch is attached.

If .lp and .ypp files are supposed to be Bison and Flex files with C++
code in them, it wouldn't work anyway, because the rules elsewhere in
the MSVC scripts just check for /\.y$/) to decide whether to run bison
on it.

I committed Andrew's suggestion:

/^(.*)\\([^\\]+)\.(c|cpp|y|l|rc)$/

- Heikki


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compiling C++ extensions on MSVC using scripts in src/tools
Date: 2014-12-18 01:47:43
Message-ID: CAB7nPqRFzfYWxwmi1sTZJJ+wMYAVR45qqBnBMStpv+PHfEooPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 18, 2014 at 4:55 AM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)com> wrote:
> If .lp and .ypp files are supposed to be Bison and Flex files with C++ code
> in them, it wouldn't work anyway, because the rules elsewhere in the MSVC
> scripts just check for /\.y$/) to decide whether to run bison on it.
>
> I committed Andrew's suggestion:
> /^(.*)\\([^\\]+)\.(c|cpp|y|l|rc)$/
Thanks, that's enough for my stuff.
--
Michael