blob: a5f6c8f6e8baba2cb1f2071b6b013394cab3dbb9 [file] [log] [blame]
Manuel Pégourié-Gonnard1b578782013-09-16 13:33:42 +02001#!/usr/bin/perl
2
Manuel Pégourié-Gonnard684e9dc2013-09-20 15:11:44 +02003# create individual project files for example programs
4# for VS6 and VS2010
5
Manuel Pégourié-Gonnard1b578782013-09-16 13:33:42 +02006use warnings;
7use strict;
8
9my $vs6_dir = "../visualc/VS6";
10my $vs6_ext = "dsp";
11my $vs6_template_file = "data_files/vs6-app-template.$vs6_ext";
12
13my $vsx_dir = "../visualc/VS2010";
14my $vsx_ext = "vcxproj";
15my $vsx_template_file = "data_files/vs2010-app-template.$vsx_ext";
16
17exit( main() );
18
19sub slurp_file {
20 my ($filename) = @_;
21
22 local $/ = undef;
23 open my $fh, '<', $filename or die "Could not read $filename\n";
24 my $content = <$fh>;
25 close $fh;
26
27 return $content;
28}
29
30sub gen_app {
31 my ($path, $template, $dir, $ext) = @_;
32
33 $path =~ s!/!\\!g;
34 (my $appname = $path) =~ s/.*\\//;
35
36 my $content = $template;
37 $content =~ s/<PATHNAME>/$path/g;
38 $content =~ s/<APPNAME>/$appname/g;
39
40 open my $app_fh, '>', "$dir/$appname.$ext";
41 print $app_fh $content;
42 close $app_fh;
43}
44
45sub get_app_list {
46 my $app_list = `cd ../programs && make list`;
47 die "make list failed: $!\n" if $?;
48
49 return split /\s+/, $app_list;
50}
51
52sub main {
53 -d $vs6_dir || die "VS6 directory not found: $vs6_dir\n";
54 -d $vsx_dir || die "VS2010 directory not found: $vsx_dir\n";
55
56 my $vs6_tpl = slurp_file( $vs6_template_file );
57 my $vsx_tpl = slurp_file( $vsx_template_file );
58
59 for my $app ( get_app_list() ) {
60 printf "$app\n";
61 gen_app( $app, $vs6_tpl, $vs6_dir, $vs6_ext );
62 gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext );
63 }
64
65 return 0;
66}