How to compile with PCT to lowercase path and filename

Posted by Roel de Wildt on 28-Apr-2018 06:24

Hello,

I'm trying to rebuild our building infrastructure with PCT. Until now it compiles the projects just fine but there is one problem where I have no solution found yet.

The problem is that I have by example this directory structure with files mixed with upper- and lowercase files in it:

SRCa/Abc.p
SRCa/DEF.P
SRCB/zzZ.p

A snippet from my configuration of ant is as following:

<PCTCompile destDir="rcode">
  <fileset dir="source" casesensitive="False">
    <include name="*.p" />
    <include name="*.w" />
  </fileset>
</PCTCompile>

But I want the geerated rcode all lowercase. How to do this?

All Replies

Posted by Riverside Software on 28-Apr-2018 14:52

PCTCompile can use mappers. An example in this page is:

<scriptmapper language="javascript">

 self.addMappedName(source.toLowerCase());

</scriptmapper>

But why lowercase everything ?

Posted by Thomas Mercer-Hursh on 28-Apr-2018 14:58

Mixed case source like this is a potential hazard depending on platform.  On Windows it will run, but on Unix, the casing in the source and the casing in the file system must match.

Posted by Roel de Wildt on 28-Apr-2018 16:54

It is corect that the source code must be able to run on unix which is casesenitive. That is why the rcode files must be lowercase because all our RUN statements have the file in lowercase.

I have tested with the following code in the xml file which I use for ant:

<PCTCompile destDir="rcode">
  <fileset dir="source" casesensitive="False">
    <include name="*.p" />
    <include name="*.w" />
  </fileset>
  <scriptmapper language="javascript">
    self.addMappedName(source.toLowerCase());
  </scriptmapper>
</PCTCompile>

Now I get everything twice in the output:

SRCa/Abc.r

SRCa/abc.p

SRCa/DEF.r

SRCa/def.p

SRCB/zzz.p

SRCB/zzZ.r

Even with a self.clear() before the self.addMappedName() gives not the result I wanted. The source name is now to output name:

SRCa/abc.p

SRCa/def.p

SRCB/zzz.p

When I use the following javascript function to lowercase everything only the extension is lowercase:

<scriptmapper language="javascript">
  var baseName = source.substring(0, source.lastIndexOf('.'));
  self.clear();
  self.addMappedName(baseName.toLowerCase() + ".r");
</scriptmapper>

Posted by Riverside Software on 29-Apr-2018 03:07

A quick test showed that there's an issue in PCT when using only toLowerCase(), probably a case-insensitive comparison in the code. I'll try to have a look.

> It is corect that the source code must be able to run on unix which is casesenitive. That is why the rcode files must be lowercase because all our RUN statements have the file in lowercase.

Rather than silently fixing the issue during the build, I'd make sure the repository doesn't contain mixed case procedures (with commit hooks or SonarQube code analysis) and educate developers.

Posted by Riverside Software on 30-Apr-2018 02:46

I confirm the issue won't be fixed in PCT, there are way too many consequences for a very limited use case.

To achieve what you want to do, you can use <mappedresources> in the <zip> task for example.

Posted by Roel de Wildt on 30-Apr-2018 03:29

Thanks for looking at the issue, sadly it won't be fixed in PCT

There are 2 options now:

- Converting the source in the source control system

- Convert after the build with a post compile step before the pls are constructed

I think I would correct the filename case in source control and enforce it in there with a rule

Posted by Riverside Software on 30-Apr-2018 04:44

If you generate PL files, option 2 can be implemented with a <copy> and <mapper> between PCTCompile and PCTLibrary (as mapper are not supported at all in PCTLibrary).

The conversion would still be my preferred way. A commit hook can be used to enforce the rule, or you can use the OpenEdge plugin for SonarQube.

Gilles

This thread is closed