summaryrefslogtreecommitdiff
path: root/samwise/PerlSam/Generator/VisualAge.pm
blob: ccf38e07e8ad651d2485cf1873dab18eb9e67f90 (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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# $Id$

package PerlSam::Generator::VisualAge;

use Cwd;
use Data::Dumper;
use File::Basename;
use FileHandle;
use strict;

###############################################################################
# Forward Declarations


###############################################################################
# Constructor

sub new (@)
{
    my $proto = shift;
    my $class = ref ($proto) || $proto;
    my $self = {};

    bless ($self, $class);
    return $self;
}

###############################################################################
# Methods

sub GenerateWorkspace (\%)
{
    my $self = shift;
    my $data = shift;

    my $string;

    $string .= "//\n";
    $string .= "//\n";
    $string .= "// \$Id\$\n";
    $string .= "//\n";
    $string .= "// Visual Age C++ 5 super-project generated by the Samwise Compiler\n";
    $string .= "//\n";
    $string .= "//\n";
    $string .= "\n";

    foreach my $project (PerlSam::Generator::ProjectOrder (%{$data})) {
        $string .= "subproject $project, icc \"".$project.".icc\", ics \"".$project.".ics\"\n";
        $string .= "{\n";
        $string .= "}\n";
        $string .= "\n";
    }

    $string .= "build all\n";
    $string .= "{\n";
    foreach my $project (PerlSam::Generator::ProjectOrder (%{$data})) {
        $string .= "use $project\n";
    }
    $string .= "}\n";

    my $file_name;

    if (defined $data->{WORKSPACE}->{NAME}) {
        $file_name = $data->{WORKSPACE}->{NAME};
    }
    else {
        $file_name = getcwd ();

        if ($file_name =~ m/\/([^\/]*)$/) {
            $file_name = $1;
        }
    }

    $file_name = $file_name . ".icp";

    print "Creating Workspace: $file_name\n";

    my $file_handle = new FileHandle ($file_name, "w");
    binmode $file_handle;
    $string =~ s/\n/\r\n/g;
    print $file_handle $string;
}

sub GenerateProjects (\%)
{
    my $self = shift;
    my $data = shift;

    foreach my $project (sort keys %{$data->{PROJECTS}}) {
        my $string;
        my $description = $data->{PROJECTS}->{$project}->{DESCRIPTION};
        my $target = $data->{PROJECTS}->{$project}->{TARGET};
        my $type = $data->{PROJECTS}->{$project}->{TYPE};

        my $file_name = $project . ".icc";

        my $string;
        $string .= "//\n";
        $string .= "// Visual Age C++ 5 Project file generated by the Samwise Compiler\n";
        $string .= "//\n";

        my $ace_root = PerlSam::Generator::ConvertPathToRelative ("/");

        $string .= "include \"".$ace_root."samwise/makeinclude/vacpp_setup.icc\"\n";
        $string .= "option\n";
        $string .= "    link(libSearchPath,),\n";

        print "Creating Project: $file_name\n";

        # my $file_handle = new FileHandle ($file_name, "w");
        # print $file_handle $string;
    }
}

###############################################################################
# Internal Methods

1;