Skip to content

Commit

Permalink
Edited Cli added pathEmsdk parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
CiccioTecchio committed Oct 28, 2019
1 parent 01eadd2 commit e0859b2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/main/java/com/cicciotecchio/yaspl/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.cicciotecchio.yaspl.lexer.LexerLex;
import com.cicciotecchio.yaspl.parser.ParserCup;
import java_cup.runtime.ComplexSymbolFactory;
import com.cicciotecchio.yaspl.syntaxTree.Programma;
import com.cicciotecchio.yaspl.visitor.*;
import java_cup.runtime.ComplexSymbolFactory;

import java.io.*;

Expand All @@ -28,7 +28,6 @@ public class Cli {
private static boolean scope = false;
private static boolean enrich = false;
private static boolean js = false;
private static final String PATHEMSDK = "src/main/resources/emsdk";

public static void main(String[] args) {
try {
Expand Down Expand Up @@ -71,29 +70,26 @@ public static void main(String[] args) {
fw.write(genC.visit(p));
fw.close();
pb.redirectErrorStream(true);
String pathEmsdk = args[args.length-2];

if(js){
pb.command("bash", "-c", "cd yasplSource;"
+ "clang target.c -o ../a.out;"
//+ "clang -S -emit-llvm target.c -o ../target.ll;"
);
pb.command("bash", "-c", "source "+pathEmsdk+"/emsdk_env.sh;"
+ "cd yasplSource;"
+ "clang target.c -o ../a.out; gindent target.c;"
+ "emcc target.c -o ../yaspl.out.js");
}else{
pb.command("bash", "-c", "cd yasplSource; clang target.c -o ../a.out");
pb.command("bash", "-c", "cd yasplSource; clang target.c -o ../a.out; gindent target.c");
}

process = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = reader.readLine();

while (line != null) {
System.out.println(line);
line = reader.readLine();
}

if(js) {
pb.command("bash", "-c", "source "+PATHEMSDK+"/emsdk_env.sh;"
+ "emcc yasplSource/target.c -o yaspl.out.js");
process = pb.start();
}

reader.close();
process.destroy();
} catch (FileNotFoundException e) {
Expand Down

0 comments on commit e0859b2

Please sign in to comment.