Commit c672f060 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Support the use of '~' in AADL files to avoid hardcoded paths.

parent aeae7a35
......@@ -18,8 +18,13 @@ public static class CommonCode
// No ASN.1 grammar provided, we must create one for us
//
// First, trim the quote (") from the DataView list provided by the AADL parser
AadlGlobals.aadlDataViews =
AadlGlobals.aadlDataViews.Select(x => x.Trim('"')).ToList();
AadlGlobals.aadlDataViews = AadlGlobals.aadlDataViews.Select(
x => x.Trim('"')).ToList();
// Then replace any characters leading to a '~' for the HOME folder
var sweetHome = Environment.GetEnvironmentVariable("HOME");
Regex rgx = new Regex("^[^~]*~");
AadlGlobals.aadlDataViews = AadlGlobals.aadlDataViews.Select(
x => rgx.Replace(x, sweetHome)).ToList();
// Then check if the dataviews exist - if not, prepend the basedir of the IF view
AadlGlobals.aadlDataViews = AadlGlobals.aadlDataViews.Select(
x => File.Exists(x) ? x :
......@@ -47,9 +52,12 @@ public static class CommonCode
{
// Use a regexp to extract from Source_Text properties
var extractDataViews = new Regex(@"Source_Text => (.*);", RegexOptions.Singleline);
foreach (var fname in AadlGlobals.aadlDataViews) {
foreach (var fnameWithPotentialTilda in AadlGlobals.aadlDataViews) {
// For each AADL DataView:
//
// Fix the '~':
var fname = rgx.Replace(fnameWithPotentialTilda, sweetHome);
// Check if it exists
if (!File.Exists(fname))
throw new UserException(
......@@ -64,6 +72,10 @@ public static class CommonCode
{
// it does, take the filename and remove parens and quotes
var asnFilename = matches.Groups[1].ToString().Trim('(',')','"');
// Fix any '~' references:
asnFilename = rgx.Replace(asnFilename, sweetHome);
// is it an absolute path?
if (!asnFilename.StartsWith("/"))
// No, prepent the basedir of this AADL DataView
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment