summaryrefslogtreecommitdiff
path: root/infrastructure/setupexternal.pl
blob: 87ec5560374c953736284e10f5183f56867d6947 (plain)
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
#!@PERL@
use strict;

# This script links in the essential directories and processes various
# files to allow the Box libraries to be used in projects outside the main
# box library tree.

# directories to link through
my @linkdirs = qw/lib infrastructure/;

# ----------------------------------------------------

my $libdir = $ARGV[0];
die "Provided library dir $libdir does not exist" unless -d $libdir;

# Check and remove links from the directory, then add new symlinks
for my $d (@linkdirs)
{
	if(-e $d)
	{
		die "In project, $d is not a symbolic link"
			unless -l $d;
		print "Removing existing symlink $d\n";
		unlink $d;
	}
	my $link_target = "$libdir/$d";
	print "Add symlink $d -> $link_target\n";
	die "Can't create symlink $d" unless
		symlink $link_target, $d;
}

# Copy and create a base modules file which includes all the libraries
print "Create new modules_base.txt file\n";
open OUT,">modules_base.txt" or die "Can't open modules_base.txt file for writing";
print OUT <<__E;
#
# Automatically generated file, do not edit
#
# Source: $libdir/modules.txt
#

__E

open IN,"$libdir/modules.txt" or die "Can't open $libdir/modules.txt for reading";

while(<IN>)
{
	if(m/\A(lib\/.+?)\s/)
	{
		print OUT
	}
}

close IN;
close OUT;