summaryrefslogtreecommitdiff
path: root/devtools/mapbuild/syncChangedMaps.pl
blob: 912294713ab50d5f06310489917c9594a110a580 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use strict;

my $forceBuild = 0;
if ( $ARGV[1] =~ /-forcebuild/ )
{
	$forceBuild = 1;
}

# Read in the list of changed maps

my $filename = "buildlist.txt";

open(INFILE, $filename);
my @maps = <INFILE>;
close( INFILE );

# forcelist.txt allows maps to be manually added to the build. 

open(INFILE, "forcelist.txt");
my @forcemaps = <INFILE>;
close( INFILE );

my $retval = 1;

system( "echo. > $filename" );
system( "echo. > forcelist.txt" );

# Run through the list of maps to see if any should be built

for( @maps) 
{
	if( /updating (.*)|adding (.*)/ )
	{
		# Check if this map should be built now
		if ( shouldBuild( $1 ) == 0 )
		{
			next;
		}

		# Add this map name to the build list

		system( "p4 sync -f $1 >> $filename" );
		system( "echo Adding to the build list: $1 >> log.txt" );
		$retval = 0;
	}
}

for( @forcemaps )
{
	if ( /\.vmf/ )
	{
		# Add this map name to the build list

		$_ =~ /(.*)/;
		system( "p4 sync -f $1 >> $filename" );
		system( "echo Forcing add to the build list: $1 >> log.txt" );
		$retval = 0;
	}
}

exit $retval;

#-----------------------------------
# Check if this map should build now
#-----------------------------------
sub shouldBuild
{
	my $map = shift;

	# if command line flag was set, build the map

	if ( $forceBuild == 1 )
	{
		return 1;
	}

	# if the map line contains the force flag, build the map

	if ( $map =~ /-forcebuild/ )
	{
		return 1;
	}

	# Dump the comments from the last checkin of this map

	system( "p4 changes -m 1 -s submitted -l $map > comments.txt" );

	# parse comments for the autocompile keyword

	open(INFILE, "comments.txt");
	my @comments = <INFILE>;
	close(INFILE);

	for( @comments )
	{
		if ( /autocompile/i )
		{
			return 1;
		}
	}

	return 0;
}