Commit 94350a1c authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Move method addRessource() to JuliacConfig.

parent 25108594
......@@ -444,33 +444,6 @@ public class Juliac {
return uri;
}
/**
* Add the specified resource file.
*
* @param sf the resource file
* @source 2.6
*/
public void addResource( SourceFile sf ) throws IOException {
JuliacConfig jconf = getJuliacConfig();
CompilationRounds rounds = jconf.getCompilationRounds();
String fileName = sf.getFullName();
byte[] content = sf.getContent();
// Copy the resource to the directory for generated code
File genDir = jconf.getGenDir();
File file = new File(genDir,fileName);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
fos.write(content);
fos.close();
// Add the resource to the current compilation round
CompilationRound round = rounds.getCurrentCompilationRound();
round.addResource(sf);
}
/**
* Return <code>true</code> if the specified type has already been generated
* or exists in the classpath.
......
......@@ -24,6 +24,7 @@
package org.objectweb.fractal.juliac.conf;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
......@@ -274,6 +275,31 @@ public class JuliacConfig {
}
}
/**
* Add the specified resource file.
*
* @param sf the resource file
* @source 2.6
*/
public void addResource( SourceFile sf ) throws IOException {
String fileName = sf.getFullName();
byte[] content = sf.getContent();
// Copy the resource to the directory for generated code
File genDir = getGenDir();
File file = new File(genDir,fileName);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
fos.write(content);
fos.close();
// Add the resource to the current compilation round
CompilationRounds rounds = getCompilationRounds();
CompilationRound round = rounds.getCurrentCompilationRound();
round.addResource(sf);
}
public String[] getSrclibs() {
/*
* Return a copy in order to prevent unwanted adding in the list.
......
......@@ -337,7 +337,7 @@ public class FracletGenerator {
* TODO do not compile if no file has been generated
*/
SourceFile sf = new SourceFileString(adl,sb.toString(),"fractal");
jc.addResource(sf);
jc.getJuliacConfig().addResource(sf);
jc.build();
/*
......
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