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?
PCTCompile can use mappers. An example in this page is:
<scriptmapper language="javascript">
self.addMappedName(source.toLowerCase());
</scriptmapper>
But why lowercase everything ?
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.
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>
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.
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.
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
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