Skip to content
Snippets Groups Projects
Commit 8d88f427 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Libraries and build process files are generated properly.

refs 3079
parent 7f0251ef
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,9 @@ import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.cre
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade.addUserHeaderInclude;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCSourcePackage;
import static org.fortiss.af3.generator.common.utils.SourceModelElementFactory.createByteContentUnitForPluginFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getConfigureFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getEclipseProjectFile;
import static org.fortiss.af3.platform.raspberry.generator.templates.RasPiCTemplates.getMakedefsFile;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.TransformationUtils.createTransformedObjectFor;
......@@ -59,9 +61,11 @@ import org.fortiss.tooling.kernel.extension.exception.ChainTransformationFailedE
* @ConQAT.Rating RED Hash:
*/
public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<RaspberryPi, CSourcePackage> {
/** Folder name for library source files. */
private static final String SRC_LIB_SUB_PACKAGE_NAME = "src-lib";
/** Folder name for library include files. */
private static final String INC_LIB_SUB_PACKAGE_NAME = "inc-lib";
/** Folder name for linkable static library files. */
private static final String LIB_SUB_PACKAGE_NAME = "lib";
/** Constructor. */
......@@ -81,7 +85,8 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
addDataDictionaryCode(context, sourcePackage);
addLogicalComponentCode(deployedComponents, context, sourcePackage);
addEclipseCProjectFiles(sourcePackage, modelElement.getName());
addLibraryCode(sourcePackage);
addStaticLibraries(sourcePackage);
addConfigureAndMakedefsFiles(sourcePackage, modelElement.getName());
} catch(Exception ex) {
error(AF3PlatformRaspberryActivator.getDefault(), ex.getMessage(), ex);
ex.printStackTrace();
......@@ -89,8 +94,14 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
return sourcePackage;
}
/** Adds the build process files: configure and Makedefs. */
private void addConfigureAndMakedefsFiles(CSourcePackage sourcePackage, String binaryName) {
sourcePackage.addUnit(getConfigureFile(binaryName));
sourcePackage.addUnit(getMakedefsFile());
}
/** Adds the library code need by the deployment code generator. */
private void addLibraryCode(CSourcePackage sourcePackage) throws Exception {
private void addStaticLibraries(CSourcePackage sourcePackage) throws Exception {
CSourcePackage srcLib =
AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage();
srcLib.setBaseLocation(SRC_LIB_SUB_PACKAGE_NAME);
......@@ -102,16 +113,16 @@ public class RaspberryPIExecutable extends ExecutionUnitExecutableBase<Raspberry
sourcePackage.getSubPackages().add(incLib);
CSourcePackage lib = AF3GeneratorCommonLanguagesCFactory.eINSTANCE.createCSourcePackage();
incLib.setBaseLocation(LIB_SUB_PACKAGE_NAME);
lib.setBaseLocation(LIB_SUB_PACKAGE_NAME);
sourcePackage.getSubPackages().add(lib);
lib.addUnit(getStaticLibraryUnit("libbrick.a"));
// lib.addUnit(getStaticLibraryUnit("libaf3pihal.a"));
lib.addUnit(getStaticLibraryUnit("libaf3pihal.a"));
}
/** Creates a {@link ByteContentUnit} for the given static library. */
private AbstractUnit getStaticLibraryUnit(String libName) throws Exception {
return createByteContentUnitForPluginFile(AF3PlatformRaspberryActivator.PLUGIN_ID,
"code-gen-hal/lin", libName, false);
"code-gen-hal/lib", libName, false);
}
/** Adds auxiliary files for Eclipse C project. */
......
......@@ -48,6 +48,19 @@ public final class RasPiCTemplates {
return unit;
}
/** Returns the 'configure' file used to create a Makefile. */
public static AbstractUnit getConfigureFile(String binaryName) {
StringTemplate template = makeTemplate("ConfigureFile.stg", "ConfigureFile");
template.setAttribute("binary", binaryName);
return createStaticContentSourceUnit("configure", template.toString(), true);
}
/** Returns the 'Makedefs' file used to create a Makefile. */
public static AbstractUnit getMakedefsFile() {
StringTemplate template = makeTemplate("MakedefsFile.stg", "MakedefsFile");
return createStaticContentSourceUnit("Makedefs", template.toString(), true);
}
/** Evaluates the given template. */
protected static StringTemplate makeTemplate(String stgFile, String instance) {
StringTemplateGroup stg = loadResourceSTG(stgFile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment