Permalink
Browse files

USE-REVVIDEO and USE-UNDERLINE compile options

Also include compilation procedure generated on-the-fly
  • Loading branch information...
strachpr01 authored and gquerret committed Jan 6, 2018
1 parent ebe7548 commit 1773ffce4a6143fd542396dfd9de9f7cbdb0b57e
View
Binary file not shown.
@@ -16,7 +16,12 @@
*/
package com.phenix.pct;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -44,6 +49,8 @@
private boolean multiCompile = false;
private boolean streamIO = false;
private boolean v6Frame = false;
private boolean useRevvideo = false;
private boolean useUnderline = false;
private boolean stringXref = false;
private boolean appendStringXref = false;
private boolean saveR = true;
@@ -157,6 +164,16 @@ public void setv6Frame(boolean v6Frame) {
this.v6Frame = v6Frame;
}
@Override
public void setUseRevvideo(boolean useRevvideo) {
this.useRevvideo = useRevvideo;
}
@Override
public void setUseUnderline(boolean useUnderline) {
this.useUnderline = useUnderline;
}
@Override
public void setKeepXref(boolean keepXref) {
this.keepXref = keepXref;
@@ -307,6 +324,14 @@ public boolean isV6Frame() {
return v6Frame;
}
public boolean isUseRevvideo() {
return useRevvideo;
}
public boolean isUseUnderline() {
return useUnderline;
}
public boolean isStringXref() {
return stringXref;
}
@@ -382,4 +407,67 @@ public String getIgnoredIncludes() {
public int getFileList() {
return fileList;
}
protected void writeCompilationProcedure(File f, Charset c) {
try (FileOutputStream fos = new FileOutputStream(f);
OutputStreamWriter osw = new OutputStreamWriter(fos, c);
BufferedWriter bw = new BufferedWriter(osw)) {
bw.write("DEFINE INPUT PARAMETER ipSrcFile AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipSaveDir AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipDbg AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipListing AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipPreprocess AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipStrXref AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipXREF AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("COMPILE VALUE(ipSrcFile) ");
if (isSaveR())
bw.write("SAVE INTO VALUE(ipSaveDir) ");
bw.write(" DEBUG-LIST VALUE(ipDbg) ");
if (getLanguages() != null) {
bw.write("LANGUAGES (\"" + getLanguages() + "\") ");
if (getGrowthFactor() > 0)
bw.write("TEXT-SEG-GROWTH=" + getGrowthFactor() + " ");
}
if (isMd5())
bw.write("GENERATE-MD5 ");
if (isMinSize())
bw.write("MIN-SIZE ");
if (isStreamIO())
bw.write("STREAM-IO ");
if (isV6Frame()) {
bw.write("V6FRAME ");
if (isUseRevvideo())
bw.write("USE-REVVIDEO ");
else if (isUseUnderline())
bw.write("USE-UNDERLINE ");
}
if (!isXcode()) {
bw.write("LISTING VALUE(ipListing) ");
bw.write("PREPROCESS VALUE(ipPreprocess) ");
bw.write("STRING-XREF VALUE(ipStrXref) ");
if (isAppendStringXref())
bw.write("APPEND ");
if (isXmlXref())
bw.write("XREF-XML VALUE(ipXREF) ");
else
bw.write("XREF VALUE(ipXREF) ");
} else if (getXcodeKey() != null) {
bw.write("XCODE \"" + getXcodeKey() + "\" ");
}
bw.write("NO-ERROR.");
bw.newLine();
} catch (IOException caught) {
throw new BuildException(Messages.getString("PCTCompile.2"), caught); //$NON-NLS-1$
}
}
}
@@ -195,6 +195,16 @@ public void setv6Frame(boolean v6Frame) {
compAttributes.setv6Frame(v6Frame);
}
@Override
public void setUseRevvideo(boolean useRevvideo) {
compAttributes.setUseRevvideo(useRevvideo);
}
@Override
public void setUseUnderline(boolean useUnderline) {
compAttributes.setUseUnderline(useUnderline);
}
@Override
public void setKeepXref(boolean keepXref) {
compAttributes.setKeepXref(keepXref);
@@ -113,6 +113,16 @@
*/
void setv6Frame(boolean v6Frame);
/**
* Enables USE-REVVIDEO attribute in COMPILE statement
*/
void setUseRevvideo(boolean useRevvideo);
/**
* Enables USE-UNDERLINE attribute in COMPILE statement
*/
void setUseUnderline(boolean useUnderline);
/**
* Generates a .xref in the .pct directory, result of XREF option in the COMPILE statement
*/
@@ -618,7 +618,7 @@ protected static String escapeString(String str) {
}
protected static final int nextRandomInt() {
return RANDOM.nextInt() & 0xffff;
return RANDOM.nextInt() & 0xfffffff;
}
// ----------------------------------
@@ -672,4 +672,4 @@ protected static void copyStreamFromJar(String streamName, File outFile) throws
}
}
}
}
}
@@ -16,18 +16,9 @@
*/
package com.phenix.pct;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.Socket;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
@@ -36,6 +27,15 @@
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils;
/**
* Class for compiling Progress procedures
*
@@ -50,10 +50,16 @@
private int compOk = 0;
private int compNotOk = 0;
private int compSkipped = 0;
// Internal use
private int compId = -1;
private File compDir = null;
public PCTBgCompile() {
super();
compAttrs = new CompilationAttributes(this);
compId = PCT.nextRandomInt();
compDir = new File(System.getProperty("java.io.tmpdir"), "pctcomp" + compId);
}
/**
@@ -95,6 +101,11 @@ public void execute() {
throw new BuildException(Messages.getString("PCTCompile.34")); //$NON-NLS-1$
}
if (compDir.exists() || !compDir.mkdirs()) {
this.cleanup();
throw new BuildException("Unable to create temp directory for compile procedure");
}
// Test output directory
if (compAttrs.getDestDir().exists()) {
if (!compAttrs.getDestDir().isDirectory()) {
@@ -133,6 +144,8 @@ public void execute() {
}
initializeCompilationUnits();
compAttrs.writeCompilationProcedure(new File(compDir, "pctcomp.p"), getCharset());
getOptions().addPropath(new Path(getProject(), compDir.getAbsolutePath()));
try {
super.execute();
@@ -214,6 +227,15 @@ protected BackgroundWorker createOpenEdgeWorker(Socket socket) {
return worker;
}
@Override
protected void cleanup() {
super.cleanup();
if (getOptions().isDebugPCT())
return;
deleteFile(compDir);
}
public class CompilationBackgroundWorker extends BackgroundWorker {
private int customStatus = 0;
@@ -275,18 +297,18 @@ public void setCustomOptions(Map<String, String> options) {
private String getOptions() {
StringBuilder sb = new StringBuilder();
sb.append(Boolean.toString(compAttrs.isRunList())).append(';');
sb.append(Boolean.toString(compAttrs.isMinSize())).append(';');
sb.append(Boolean.toString(compAttrs.isMd5())).append(';');
sb.append("").append(';'); // Previously min-size
sb.append("").append(';'); // Previously MD5
sb.append(Boolean.toString(compAttrs.isXcode())).append(';');
sb.append(compAttrs.getXcodeKey() == null ? "" : compAttrs.getXcodeKey()).append(';');
sb.append(Boolean.toString(compAttrs.isForceCompile())).append(';');
sb.append(Boolean.toString(false /* FIXME noCompile */)).append(';');
sb.append(Boolean.toString(compAttrs.isKeepXref())).append(';');
sb.append(compAttrs.getLanguages() == null ? "" : compAttrs.getLanguages()).append(';');
sb.append(Integer.toString(compAttrs.getGrowthFactor() > 0 ? compAttrs.getGrowthFactor() : -1)).append(';');
sb.append("").append(';'); // Previously languages
sb.append("").append(';'); // Previously growth factor
sb.append(Boolean.toString(compAttrs.isMultiCompile())).append(';');
sb.append(Boolean.toString(compAttrs.isStreamIO())).append(';');
sb.append(Boolean.toString(compAttrs.isV6Frame())).append(';');
sb.append("").append(';'); // Previously stream-io
sb.append("").append(';'); // Previous v6frame
sb.append(Boolean.toString(PCTBgCompile.this.getOptions().useRelativePaths())).append(';');
sb.append(compAttrs.getDestDir().getAbsolutePath()).append(';');
sb.append(Boolean.toString(compAttrs.isPreprocess())).append(';');
@@ -298,7 +320,7 @@ private String getOptions() {
sb.append(Boolean.toString(compAttrs.isXmlXref())).append(';');
sb.append(Boolean.toString(compAttrs.isStringXref())).append(';');
sb.append(Boolean.toString(compAttrs.isAppendStringXref())).append(';');
sb.append(Boolean.toString(compAttrs.isSaveR())).append(';');
sb.append("").append(';'); // Previously saveR
sb.append(compAttrs.getListingSource()).append(';');
sb.append(Boolean.toString(compAttrs.isNoParse())).append(';');
sb.append(Boolean.toString(compAttrs.isStopOnError())).append(';');
@@ -31,6 +31,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileResource;
@@ -45,6 +46,8 @@
private CompilationAttributes compAttrs;
// Internal use
private int compId = -1;
private File compDir = null;
private int fsListId = -1;
private File fsList = null;
private int paramsId = -1;
@@ -60,8 +63,10 @@ public PCTCompile() {
fsListId = PCT.nextRandomInt();
paramsId = PCT.nextRandomInt();
compId = PCT.nextRandomInt();
fsList = new File(System.getProperty(PCT.TMPDIR), "pct_filesets" + fsListId + ".txt"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
params = new File(System.getProperty(PCT.TMPDIR), "pct_params" + paramsId + ".txt"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
compDir = new File(System.getProperty(PCT.TMPDIR), "pctcomp" + compId); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -167,10 +172,6 @@ private void writeParams() {
bw.newLine();
bw.write("PCTDIR=" + compAttrs.getxRefDir().getAbsolutePath()); //$NON-NLS-1$
bw.newLine();
bw.write("MINSIZE=" + (compAttrs.isMinSize() ? 1 : 0)); //$NON-NLS-1$
bw.newLine();
bw.write("MD5=" + (compAttrs.isMd5() ? 1 : 0)); //$NON-NLS-1$
bw.newLine();
bw.write("FORCECOMPILE=" + (compAttrs.isForceCompile() ? 1 : 0)); //$NON-NLS-1$
bw.newLine();
bw.write("FAILONERROR=" + (runAttributes.isFailOnError() ? 1 : 0)); //$NON-NLS-1$
@@ -217,24 +218,8 @@ private void writeParams() {
bw.newLine();
bw.write("MULTICOMPILE=" + (compAttrs.isMultiCompile() ? 1 : 0));
bw.newLine();
bw.write("STREAM-IO=" + (compAttrs.isStreamIO() ? 1 : 0));
bw.newLine();
if (compAttrs.isV6Frame()) {
bw.write("V6FRAME=1");
bw.newLine();
}
bw.write("SAVER=" + (compAttrs.isSaveR() ? 1 : 0)); //$NON-NLS-1$
bw.newLine();
bw.write("RELATIVE=" + (runAttributes.useRelativePaths() ? 1 : 0));
bw.newLine();
if (compAttrs.getLanguages() != null) {
bw.write("LANGUAGES=" + compAttrs.getLanguages()); //$NON-NLS-1$
bw.newLine();
if (compAttrs.getGrowthFactor() > 0) {
bw.write("GROWTH=" + compAttrs.getGrowthFactor()); //$NON-NLS-1$
bw.newLine();
}
}
if (compAttrs.getXcodeKey() != null) {
bw.write("XCODEKEY=" + compAttrs.getXcodeKey()); //$NON-NLS-1$
bw.newLine();
@@ -287,6 +272,11 @@ public void execute() {
throw new BuildException(MessageFormat.format(Messages.getString("PCTCompile.36"), "destDir")); //$NON-NLS-1$
}
if (compDir.exists() || !compDir.mkdirs()) {
this.cleanup();
throw new BuildException("Unable to create temp directory for compile procedure");
}
// Test xRef directory
if (compAttrs.getxRefDir() == null) {
compAttrs.setXRefDir(new File(compAttrs.getDestDir(), ".pct")); //$NON-NLS-1$
@@ -341,8 +331,10 @@ public void execute() {
checkDlcHome();
try {
compAttrs.writeCompilationProcedure(new File(compDir, "pctcomp.p"), getCharset());
writeFileList();
writeParams();
runAttributes.addPropath(new Path(getProject(), compDir.getAbsolutePath()));
runAttributes.setProcedure(this.getProgressProcedures().getCompileProcedure());
runAttributes.setParameter(params.getAbsolutePath());
super.execute();
@@ -361,5 +353,6 @@ protected void cleanup() {
return;
deleteFile(fsList);
deleteFile(params);
deleteFile(compDir);
}
}
Oops, something went wrong.

0 comments on commit 1773ffc

Please sign in to comment.