Adding support for .S files in libraries and cores. Patches from René Bohne.

This commit is contained in:
David A. Mellis 2009-09-25 19:31:01 +00:00
parent f2010ebd2b
commit 048143f3d5
2 changed files with 45 additions and 8 deletions

View File

@ -86,6 +86,7 @@ public class Compiler implements MessageConsumer {
List<File> targetObjectFiles = List<File> targetObjectFiles =
compileFiles(avrBasePath, buildPath, includePaths, compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(target.getPath(), "S", true),
findFilesInPath(target.getPath(), "c", true), findFilesInPath(target.getPath(), "c", true),
findFilesInPath(target.getPath(), "cpp", true)); findFilesInPath(target.getPath(), "cpp", true));
@ -115,12 +116,14 @@ public class Compiler implements MessageConsumer {
includePaths.add(libraryFolder.getPath() + File.separator + "utility"); includePaths.add(libraryFolder.getPath() + File.separator + "utility");
objectFiles.addAll( objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(libraryFolder, "S", false),
findFilesInFolder(libraryFolder, "c", false), findFilesInFolder(libraryFolder, "c", false),
findFilesInFolder(libraryFolder, "cpp", false))); findFilesInFolder(libraryFolder, "cpp", false)));
outputFolder = new File(outputFolder, "utility"); outputFolder = new File(outputFolder, "utility");
createFolder(outputFolder); createFolder(outputFolder);
objectFiles.addAll( objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(new File(libraryFolder, "utility"), "S", false),
findFilesInFolder(new File(libraryFolder, "utility"), "c", false), findFilesInFolder(new File(libraryFolder, "utility"), "c", false),
findFilesInFolder(new File(libraryFolder, "utility"), "cpp", false))); findFilesInFolder(new File(libraryFolder, "utility"), "cpp", false)));
// other libraries should not see this library's utility/ folder // other libraries should not see this library's utility/ folder
@ -131,6 +134,7 @@ public class Compiler implements MessageConsumer {
objectFiles.addAll( objectFiles.addAll(
compileFiles(avrBasePath, buildPath, includePaths, compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(buildPath, "S", false),
findFilesInPath(buildPath, "c", false), findFilesInPath(buildPath, "c", false),
findFilesInPath(buildPath, "cpp", false))); findFilesInPath(buildPath, "cpp", false)));
@ -190,11 +194,20 @@ public class Compiler implements MessageConsumer {
private List<File> compileFiles(String avrBasePath, private List<File> compileFiles(String avrBasePath,
String buildPath, List<File> includePaths, String buildPath, List<File> includePaths,
List<File> sSources,
List<File> cSources, List<File> cppSources) List<File> cSources, List<File> cppSources)
throws RunnerException { throws RunnerException {
List<File> objectPaths = new ArrayList<File>(); List<File> objectPaths = new ArrayList<File>();
for (File file : sSources) {
String objectPath = buildPath + File.separator + file.getName() + ".o";
objectPaths.add(new File(objectPath));
execAsynchronously(getCommandCompilerS(avrBasePath, includePaths,
file.getAbsolutePath(),
objectPath));
}
for (File file : cSources) { for (File file : cSources) {
String objectPath = buildPath + File.separator + file.getName() + ".o"; String objectPath = buildPath + File.separator + file.getName() + ".o";
objectPaths.add(new File(objectPath)); objectPaths.add(new File(objectPath));
@ -202,7 +215,7 @@ public class Compiler implements MessageConsumer {
file.getAbsolutePath(), file.getAbsolutePath(),
objectPath)); objectPath));
} }
for (File file : cppSources) { for (File file : cppSources) {
String objectPath = buildPath + File.separator + file.getName() + ".o"; String objectPath = buildPath + File.separator + file.getName() + ".o";
objectPaths.add(new File(objectPath)); objectPaths.add(new File(objectPath));
@ -430,16 +443,13 @@ public class Compiler implements MessageConsumer {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
static private List getCommandCompilerC(String avrBasePath, List includePaths, static private List getCommandCompilerS(String avrBasePath, List includePaths,
String sourceName, String objectName) { String sourceName, String objectName) {
List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] { List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc", avrBasePath + "avr-gcc",
"-c", // compile, don't link "-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers) "-g", // include debugging info (so errors include line numbers)
"-Os", // optimize for size "-assembler-with-cpp",
"-w", // surpress all warnings
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"), "-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"), "-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
})); }));
@ -455,9 +465,36 @@ public class Compiler implements MessageConsumer {
} }
static private List getCommandCompilerC(String avrBasePath, List includePaths,
String sourceName, String objectName) {
List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc",
"-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers)
"-Os", // optimize for size
"-w", // surpress all warnings
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
}));
for (int i = 0; i < includePaths.size(); i++) {
baseCommandCompiler.add("-I" + (String) includePaths.get(i));
}
baseCommandCompiler.add(sourceName);
baseCommandCompiler.add("-o"+ objectName);
return baseCommandCompiler;
}
static private List getCommandCompilerCPP(String avrBasePath, static private List getCommandCompilerCPP(String avrBasePath,
List includePaths, String sourceName, String objectName) { List includePaths, String sourceName, String objectName) {
List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-g++", avrBasePath + "avr-g++",
"-c", // compile, don't link "-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers) "-g", // include debugging info (so errors include line numbers)

View File

@ -52,7 +52,7 @@ public class Target {
base); base);
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
if (files[i].endsWith(".c") || files[i].endsWith(".cpp")) if (files[i].endsWith(".S") || files[i].endsWith(".c") || files[i].endsWith(".cpp"))
sources.add(files[i]); sources.add(files[i]);
if (files[i].endsWith(".o")) if (files[i].endsWith(".o"))
objects.add(files[i]); objects.add(files[i]);