<commit_before>package Mkvcbuild;

#
# Package that generates build files for msvc build
#
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.49 2010/01/20 04:14:06 adunstan Exp $
#
use Carp;
use Win32;
use strict;
use warnings;
use Project;
use Solution;
use Cwd;
use File::Copy;

use Exporter;
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(Mkvcbuild);

my $solution;
my $libpgport;
my $postgres;
my $libpq;

my $contrib_defines = {'refint' => 'REFINT_VERBOSE'};
my @contrib_uselibpq = ('dblink', 'oid2name', 'pgbench', 'vacuumlo');
my @contrib_uselibpgport = ('oid2name', 'pgbench', 'pg_standby', 'vacuumlo');
my $contrib_extralibs = {'pgbench' => ['wsock32.lib']};
my $contrib_extraincludes = {'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend']};
my $contrib_extrasource = {
    'cube' => ['cubescan.l','cubeparse.y'],
    'seg' => ['segscan.l','segparse.y']
};
my @contrib_excludes = ('pgcrypto','intagg');

sub mkvcbuild
{
    our $config = shift;

    chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
    die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');

    $solution = new Solution($config);

    our @pgportfiles = qw(
      chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
      getaddrinfo.c gettimeofday.c kill.c open.c erand48.c
      snprintf.c strlcat.c strlcpy.c copydir.c dirmod.c exec.c noblock.c path.c pipe.c
      pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c thread.c
      getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c);

    $libpgport = $solution->AddProject('libpgport','lib','misc');
    $libpgport->AddDefine('FRONTEND');
    $libpgport->AddFiles('src\port',@pgportfiles);

    $postgres = $solution->AddProject('postgres','exe','','src\backend');
    $postgres->AddIncludeDir('src\backend');
    $postgres->AddDir('src\backend\port\win32');
    $postgres->AddFile('src\backend\utils\fmgrtab.c');
    $postgres->ReplaceFile('src\backend\port\dynloader.c','src\backend\port\dynloader\win32.c');
    $postgres->ReplaceFile('src\backend\port\pg_sema.c','src\backend\port\win32_sema.c');
    $postgres->ReplaceFile('src\backend\port\pg_shmem.c','src\backend\port\win32_shmem.c');
    $postgres->AddFiles('src\port',@pgportfiles);
    $postgres->AddDir('src\timezone');
    $postgres->AddFiles('src\backend\parser','scan.l','gram.y');
    $postgres->AddFiles('src\backend\bootstrap','bootscanner.l','bootparse.y');
    $postgres->AddFiles('src\backend\utils\misc','guc-file.l');
    $postgres->AddDefine('BUILDING_DLL');
    $postgres->AddLibrary('wsock32.lib');
    $postgres->AddLibrary('ws2_32.lib');
    $postgres->AddLibrary('secur32.lib');
    $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
    $postgres->FullExportDLL('postgres.lib');

    my $snowball = $solution->AddProject('dict_snowball','dll','','src\backend\snowball');
    $snowball->RelocateFiles('src\backend\snowball\libstemmer', sub {
        return shift !~ /dict_snowball.c$/;
    });
    $snowball->AddIncludeDir('src\include\snowball');
    $snowball->AddReference($postgres);

    my $plpgsql = $solution->AddProject('plpgsql','dll','PLs','src\pl\plpgsql\src');
    $plpgsql->AddFiles('src\pl\plpgsql\src', 'gram.y');
    $plpgsql->AddReference($postgres);

    if ($solution->{options}->{perl})
    {
		my $plperlsrc = "src\\pl\\plperl\\";
        my $plperl = $solution->AddProject('plperl','dll','PLs','src\pl\plperl');
        $plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
        $plperl->AddDefine('PLPERL_HAVE_UID_GID');
		foreach my $xs ('SPI.xs', 'Util.xs')
		{
			(my $xsc = $xs) =~ s/\.xs/.c/;
			if (Solution::IsNewer("$plperlsrc$xsc","$plperlsrc$xs"))
			{
				print "Building $plperlsrc$xsc...\n";
				system( $solution->{options}->{perl}
						. '/bin/perl '
						. $solution->{options}->{perl}
						. '/lib/ExtUtils/xsubpp -typemap '
						. $solution->{options}->{perl}
						. '/lib/ExtUtils/typemap ' 
						. "$plperlsrc$xs " 
						. ">plperlsrc$xsc");
				if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc")
				{
					unlink("$plperlsrc$xsc"); # if zero size
					die "Failed to create $xsc.\n";
				}
			}
		}
        if (  Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_perlboot.pl')
            ||Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_safe_bad.pl')
            ||Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_safe_ok.pl'))
        {
            print 'Building src\pl\plperl\perlchunks.h ...' . "\n";
            my $basedir = getcwd;
            chdir 'src\pl\plperl';
            system( $solution->{options}->{perl}
                  . '/bin/perl '
                  . 'text2macro.pl '
                  . '--strip="^(\#.*|\s*)$$" '
                  . 'plc_perlboot.pl plc_safe_bad.pl plc_safe_ok.pl '
                  .	'>perlchunks.h');
            chdir $basedir;
            if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h')
            {
                unlink('src\pl\plperl\perlchunks.h'); # if zero size<commit_msg>Fix typo in Mkvcbuild.pl<commit_after>package Mkvcbuild;

#
# Package that generates build files for msvc build
#
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.50 2010/01/20 04:29:07 adunstan Exp $
#
use Carp;
use Win32;
use strict;
use warnings;
use Project;
use Solution;
use Cwd;
use File::Copy;

use Exporter;
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(Mkvcbuild);

my $solution;
my $libpgport;
my $postgres;
my $libpq;

my $contrib_defines = {'refint' => 'REFINT_VERBOSE'};
my @contrib_uselibpq = ('dblink', 'oid2name', 'pgbench', 'vacuumlo');
my @contrib_uselibpgport = ('oid2name', 'pgbench', 'pg_standby', 'vacuumlo');
my $contrib_extralibs = {'pgbench' => ['wsock32.lib']};
my $contrib_extraincludes = {'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend']};
my $contrib_extrasource = {
    'cube' => ['cubescan.l','cubeparse.y'],
    'seg' => ['segscan.l','segparse.y']
};
my @contrib_excludes = ('pgcrypto','intagg');

sub mkvcbuild
{
    our $config = shift;

    chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
    die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');

    $solution = new Solution($config);

    our @pgportfiles = qw(
      chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
      getaddrinfo.c gettimeofday.c kill.c open.c erand48.c
      snprintf.c strlcat.c strlcpy.c copydir.c dirmod.c exec.c noblock.c path.c pipe.c
      pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c thread.c
      getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c);

    $libpgport = $solution->AddProject('libpgport','lib','misc');
    $libpgport->AddDefine('FRONTEND');
    $libpgport->AddFiles('src\port',@pgportfiles);

    $postgres = $solution->AddProject('postgres','exe','','src\backend');
    $postgres->AddIncludeDir('src\backend');
    $postgres->AddDir('src\backend\port\win32');
    $postgres->AddFile('src\backend\utils\fmgrtab.c');
    $postgres->ReplaceFile('src\backend\port\dynloader.c','src\backend\port\dynloader\win32.c');
    $postgres->ReplaceFile('src\backend\port\pg_sema.c','src\backend\port\win32_sema.c');
    $postgres->ReplaceFile('src\backend\port\pg_shmem.c','src\backend\port\win32_shmem.c');
    $postgres->AddFiles('src\port',@pgportfiles);
    $postgres->AddDir('src\timezone');
    $postgres->AddFiles('src\backend\parser','scan.l','gram.y');
    $postgres->AddFiles('src\backend\bootstrap','bootscanner.l','bootparse.y');
    $postgres->AddFiles('src\backend\utils\misc','guc-file.l');
    $postgres->AddDefine('BUILDING_DLL');
    $postgres->AddLibrary('wsock32.lib');
    $postgres->AddLibrary('ws2_32.lib');
    $postgres->AddLibrary('secur32.lib');
    $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
    $postgres->FullExportDLL('postgres.lib');

    my $snowball = $solution->AddProject('dict_snowball','dll','','src\backend\snowball');
    $snowball->RelocateFiles('src\backend\snowball\libstemmer', sub {
        return shift !~ /dict_snowball.c$/;
    });
    $snowball->AddIncludeDir('src\include\snowball');
    $snowball->AddReference($postgres);

    my $plpgsql = $solution->AddProject('plpgsql','dll','PLs','src\pl\plpgsql\src');
    $plpgsql->AddFiles('src\pl\plpgsql\src', 'gram.y');
    $plpgsql->AddReference($postgres);

    if ($solution->{options}->{perl})
    {
		my $plperlsrc = "src\\pl\\plperl\\";
        my $plperl = $solution->AddProject('plperl','dll','PLs','src\pl\plperl');
        $plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
        $plperl->AddDefine('PLPERL_HAVE_UID_GID');
		foreach my $xs ('SPI.xs', 'Util.xs')
		{
			(my $xsc = $xs) =~ s/\.xs/.c/;
			if (Solution::IsNewer("$plperlsrc$xsc","$plperlsrc$xs"))
			{
				print "Building $plperlsrc$xsc...\n";
				system( $solution->{options}->{perl}
						. '/bin/perl '
						. $solution->{options}->{perl}
						. '/lib/ExtUtils/xsubpp -typemap '
						. $solution->{options}->{perl}
						. '/lib/ExtUtils/typemap ' 
						. "$plperlsrc$xs " 
						. ">$plperlsrc$xsc");
				if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc")
				{
					unlink("$plperlsrc$xsc"); # if zero size
					die "Failed to create $xsc.\n";
				}
			}
		}
        if (  Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_perlboot.pl')
            ||Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_safe_bad.pl')
            ||Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_safe_ok.pl'))
        {
            print 'Building src\pl\plperl\perlchunks.h ...' . "\n";
            my $basedir = getcwd;
            chdir 'src\pl\plperl';
            system( $solution->{options}->{perl}
                  . '/bin/perl '
                  . 'text2macro.pl '
                  . '--strip="^(\#.*|\s*)$$" '
                  . 'plc_perlboot.pl plc_safe_bad.pl plc_safe_ok.pl '
                  .	'>perlchunks.h');
            chdir $basedir;
            if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h')
            {
                unlink('src\pl\plperl\perlchunks.h'); # if zero size
{'fraction_non_alphanumeric': 0.20503316426063206, 'fraction_numerical': 0.009559110417479515, 'mean_word_length': 3.2632016632016634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5740602', 'n_tokens_mistral': 4309, 'n_tokens_neox': 3908, 'n_words': 544}