View Javadoc

1   /***
2    * Cecilia ADL Compiler
3    * Copyright (C) 2006-2007 STMicroelectronics
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   *
19   * Contact: fractal@objectweb.org
20   *
21   * Author:Matthieu Leclercq
22   */
23  
24  package org.objectweb.fractal.cecilia.adl.compiler.gnu;
25  
26  import java.io.File;
27  import java.util.ArrayList;
28  import java.util.List;
29  import java.util.Map;
30  
31  import org.objectweb.fractal.api.Component;
32  import org.objectweb.fractal.cecilia.adl.compiler.AbstractCompilationTaskFactory;
33  import org.objectweb.fractal.task.core.TaskException;
34  
35  public class GnuCompilationTaskFactory extends AbstractCompilationTaskFactory {
36  
37    // ---------------------------------------------------------------------------
38    // Implementation of abstract methods of AbstractCompilationTaskFactory
39    // ---------------------------------------------------------------------------
40  
41    @Override
42    protected Component createCompileTask(final Object id,
43        final String compileCommand, final List<String> flags, final File outputDir,
44        final Map<Object, Object> context) throws TaskException {
45      return taskFactoryItf.newPrimitiveTask(new GnuDepCompilerTask(
46          compileCommand, outputDir, flags), id);
47    }
48  
49    @Override
50    protected Component createLinkTask(final Object id, final String linkCommand,
51        final String linkedFileName, List<String> flags, final File outputDir,
52        final int nbJobs, final Map<Object, Object> context) throws TaskException {
53      final String ldScript = tryGetContextStringArg("linker-script", context);
54      if (ldScript != null) {
55        flags.add("-T");
56        flags.add(ldScript);
57      }
58      return taskFactoryItf.newPrimitiveTask(new GnuLinkerTask(linkCommand,
59          linkedFileName, outputDir, flags, nbJobs), id);
60    }
61  
62    @Override
63    protected Component createArchiveTask(final Object id,
64        final String archiveCommand, final String archiveFileName,
65        final List<String> flags, final File outputDir,
66        final Map<Object, Object> context) throws TaskException {
67      return taskFactoryItf.newPrimitiveTask(new GnuArchiverTask(archiveCommand,
68          archiveFileName, outputDir, flags), id);
69    }
70  }