Skip to content

Commit 4382624

Browse files
committed
Initial changes
1 parent 5b4c244 commit 4382624

File tree

3 files changed

+77
-29
lines changed

3 files changed

+77
-29
lines changed

modules/GHSWorkspaceCreator.pm

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,44 @@ sub pre_workspace {
7171
}
7272
}
7373

74+
# TODO(sonndinh): Some platform information is configurable such as
75+
# the path to an INTEGRITY installation, bsp name.
76+
# Some other information is specific to ACE such as its root directory,
77+
# its compilation and linking requirements (C++ version, flags, etc).
78+
# These can be put in some form of input to MPC instead of hardcoded here.
79+
# Update: We can use environment variables and command-line options:
80+
# --expand_vars, -use_env. Or can use the -relative command-line option.
81+
# The first option requires setting environment variables.
82+
# The second option requires passing parameters to the -relative option.
83+
7484
## Print out the preliminary information
7585
print $fh "#!gbuild$crlf",
86+
"macro __OS_DIR=C:\ghs\int1146$crlf",
87+
"macro __BSP_NAME=sim800$crlf",
88+
'macro __BSP_DIR=${__OS_DIR}\${__BSP_NAME}$crlf',
89+
"macro ACE_ROOT=%expand_path(.)$crlf",
90+
'macro __BUILD_DIR=${ACE_ROOT}\build$crlf',
91+
'macro __LIBS_DIR_BASE=${__OS_DIR}\libs$crlf',
7692
"primaryTarget=$tgt$crlf",
93+
'customization=${__OS_DIR}\target\integrity.bod$crlf',
7794
"[Project]$crlf",
78-
"\t--one_instantiation_per_object$crlf",
95+
#"\t-DACE_HAS_CPP14$crlf",
96+
"\t-gcc$crlf",
97+
"\t--c++14$crlf",
98+
"\t--libcxx$crlf",
7999
"\t:sourceDir=.$crlf",
80-
"\t--std$crlf",
81-
"\t-language=cxx$crlf",
82-
"\t--long_long$crlf",
83-
"\t--new_style_casts$crlf";
100+
'\t:optionsFile=${__OS_DIR}\target\${__BSP_NAME}.opt$crlf',
101+
'\t-I${ACE_ROOT}$crlf',
102+
"\t-language=cxx$crlf",
103+
"\t--new_style_casts$crlf",
104+
"\t-non_shared$crlf";
84105
}
85106

86-
107+
# TODO(sonndinh): Looks like this only support [INTEGRITY Application] with
108+
# only one [Program] (i.e., executable) in the image. But this seems sufficient
109+
# for most cases.
110+
# How does a [INTEGRITY Application] gpj file look with more
111+
# than one [Program]s and how does the corresponding .int file look?
87112
sub create_integrity_project {
88113
my($self, $int_proj, $project, $type, $target) = @_;
89114
my $outdir = $self->get_outdir();
@@ -111,9 +136,9 @@ sub create_integrity_project {
111136
"AddressSpace$crlf",
112137
"\tFilename\t\t\t$target$crlf",
113138
"\tLanguage\t\t\tC++$crlf",
114-
"\tLibrary\t\t\t\tlibINTEGRITY.so$crlf",
115-
"\tLibrary\t\t\t\tlibc.so$crlf",
116-
"\tLibrary\t\t\t\tlibscxx_e.so$crlf",
139+
#"\tLibrary\t\t\t\tlibINTEGRITY.so$crlf",
140+
#"\tLibrary\t\t\t\tlibc.so$crlf",
141+
#"\tLibrary\t\t\t\tlibscxx_e.so$crlf",
117142
"\tTask Initial$crlf",
118143
"\t\tStackLength\t\t0x8000$crlf",
119144
"\tEndTask$crlf",
@@ -137,25 +162,34 @@ sub mix_settings {
137162
my $integrity_project = (index($tgt, 'integrity') >= 0);
138163
my($int_proj, $int_type, $target);
139164

165+
# (sonndinh): Go through the lines in this project's gpj file.
166+
# Each line may result in some changes added to the workspace gpj file.
167+
# The changes are returned in the $mix variable.
168+
# In case the project is an
140169
while(<$rh>) {
170+
# (sonndinh): Don't need to add compiler/linker options to the workspace file.
171+
# The gpj file for each individual project should have those already.
172+
# In the workspace file (the top-level project file), only need to list the child projects.
141173
if (/^\s*(\[(Program|Library|Subproject)\])\s*$/) {
142174
my $type = $1;
143175
if ($integrity_project && $type eq '[Program]') {
144-
$int_proj = $project;
145-
$int_proj =~ s/(\.gpj)$/_int$1/;
146-
$int_type = $type;
147-
$mix =~ s/(\.gpj)$/_int$1/;
148-
$type = $integrity;
176+
$int_proj = $project; #E.g., tests/ARGV_Test.gpj
177+
$int_proj =~ s/(\.gpj)$/_int$1/; #E.g., tests/ARGV_Test_int.gpj
178+
$int_type = $type; #E.g., [Program]
179+
$mix =~ s/(\.gpj)$/_int$1/; #E.g., tests/ARGV_Test_int.gpj
180+
$type = $integrity; # [INTEGRITY Application]
149181
}
150-
$mix .= "\t\t$type$crlf" .
151-
"\t-object_dir=" . $self->mpc_dirname($project) .
152-
'/.obj' . $crlf;
182+
$mix .= "\t\t$type$crlf";
183+
#$mix .= "\t\t$type$crlf" .
184+
# "\t-object_dir=" . $self->mpc_dirname($project) .
185+
# '/.obj' . $crlf;
153186
}
154187
elsif (/^\s*(\[Shared Object\])\s*$/) {
155-
$mix .= "\t\t$1$crlf" .
156-
"\t-pic$crlf" .
157-
"\t-object_dir=" . $self->mpc_dirname($project) .
158-
'/.shobj' . $crlf;
188+
$mix .= "\t\t$1$crlf";
189+
#$mix .= "\t\t$1$crlf" .
190+
# "\t-pic$crlf" .
191+
# "\t-object_dir=" . $self->mpc_dirname($project) .
192+
# '/.shobj' . $crlf;
159193
}
160194
elsif ($integrity_project && /^(.*\.bsp)\s/) {
161195
push(@integ_bsps, $1);
@@ -164,7 +198,7 @@ sub mix_settings {
164198
if (/^\s*\-((\w)\w*)/) {
165199
## Save the required options into the mixed project string
166200
if (defined $directives{$2} || defined $directives{$1}) {
167-
$mix .= $_;
201+
#$mix .= $_;
168202
}
169203

170204
## If this is an integrity project, we need to find out
@@ -189,7 +223,17 @@ sub mix_settings {
189223
sub write_comps {
190224
my($self, $fh) = @_;
191225

192-
## Print out each projet
226+
#my $projects = $self->get_projects();
227+
#my @list = $self->sort_dependencies($projects);
228+
229+
#foreach (@list) {
230+
# print "$_\n";
231+
#}
232+
233+
# TODO(sonndinh): Looks like the individual project files are produced before this happens.
234+
# And this module relies on them to add contents to the workspace file (default.gpj in case of GHS).
235+
236+
## Print out each project
193237
foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
194238
print $fh $self->mix_settings($project);
195239
}

templates/ghs.mpd

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
{optional} -non_shared
88
<%endif%>
99
<%else%>
10-
<%if(sharedname)%>
11-
[Shared Object]
12-
-o <%if(dllout)%><%reltop_dllout%><%else%><%reltop_libout%><%endif%>/<%lib_prefix%><%libname_prefix%><%sharedname%><%if(use_lib_modifier)%><%lib_modifier%><%endif%><%libext(".so")%>
13-
<%else%>
10+
<%comment("TODO-sonndinh: If we put the sharedname branch before the staticname branch, MPC picks")%>
11+
<%comment("the sharedname branch even if we have a specific clause with ghs type in .mpc file")%>
12+
<%comment("and call mpc.pl -type ghs with that .mpc file. As a temporary fix, put staticname first.")%>
1413
<%if(staticname)%>
1514
[Library]
16-
-o <%reltop_libout%>/<%lib_prefix%><%libname_prefix%><%staticname%><%if(use_lib_modifier)%><%lib_modifier%><%endif%><%libext(".a")%>
15+
-o <%reltop_libout%>\<%lib_prefix%><%libname_prefix%><%staticname%><%if(use_lib_modifier)%><%lib_modifier%><%endif%><%libext(".a")%>
16+
<%else%>
17+
<%if(sharedname)%>
18+
[Shared Object]
19+
-o <%if(dllout)%><%reltop_dllout%><%else%><%reltop_libout%><%endif%>/<%lib_prefix%><%libname_prefix%><%sharedname%><%if(use_lib_modifier)%><%lib_modifier%><%endif%><%libext(".so")%>
1720
<%else%>
18-
[Subproject]
21+
[Subproject]
1922
<%endif%>
2023
<%endif%>
2124
<%endif%>

templates/ghscommon.mpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ conditional_include "unixcommon"
55
optimize = 1
66
exceptions = 1
77
lib_modifier =
8+
need_staticflags = 1

0 commit comments

Comments
 (0)