diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java index d74808110ba9a577a59ba6d8d527f6828ea086a9..b1ee77a3cc63ee2c8e4c11f7fd6b2290dc8ff52c 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/RaspberryPIExecutable.java @@ -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. */ diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java index ba111b3382cf37eb8196120c451977b1086bee2d..6cf4b58dd5646c9988dcaf0dcd9012f9764acc07 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/templates/RasPiCTemplates.java @@ -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);