All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.mind.compilation.CompilerContextHelper Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
/**
 * Copyright (C) 2009 STMicroelectronics
 *
 * This file is part of "Mind Compiler" is free software: you can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public License 
 * as published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * Contact: [email protected]
 *
 * Authors: Matthieu Leclercq
 * Contributors: 
 */

package org.ow2.mind.compilation;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public final class CompilerContextHelper {

  public static final String LINKER_COMMAND_CONTEXT_KEY   = "linker-command";
  public static final String COMPILER_COMMAND_CONTEXT_KEY = "compiler-command";
  public static final String DEFAULT_COMPILER_COMMAND     = "gcc";
  public static final String DEFAULT_LINKER_COMMAND       = "gcc";

  public static final String EXECUTABLE_NAME_CONTEXT_KEY  = "executable-name";

  public static final String C_FLAGS_CONTEXT_KEY          = "c-flags";
  public static final String LD_FLAGS_CONTEXT_KEY         = "ld-flags";
  public static final String LINKER_SCRIPT_CONTEXT_KEY    = "linker-script";

  private CompilerContextHelper() {
  }

  public static void setCFlags(final Map context,
      final List flags) {
    context.put(C_FLAGS_CONTEXT_KEY, flags);
  }

  public static List getCFlags(final Map context) {
    List flags = (List) context.get(C_FLAGS_CONTEXT_KEY);
    if (flags == null) flags = Collections.emptyList();
    return flags;
  }

  public static void setLDFlags(final Map context,
      final List flags) {
    context.put(LD_FLAGS_CONTEXT_KEY, flags);
  }

  public static List getLDFlags(final Map context) {
    List flags = (List) context.get(LD_FLAGS_CONTEXT_KEY);
    if (flags == null) flags = Collections.emptyList();
    return flags;
  }

  public static void setCompilerCommand(final Map context,
      final String compilerCmd) {
    context.put(COMPILER_COMMAND_CONTEXT_KEY, compilerCmd);
  }

  public static String getCompilerCommand(final Map context) {
    String compilerCmd = (String) context.get(COMPILER_COMMAND_CONTEXT_KEY);
    if (compilerCmd == null) {
      compilerCmd = DEFAULT_COMPILER_COMMAND;
    }
    return compilerCmd;
  }

  public static void setLinkerCommand(final Map context,
      final String linkerCmd) {
    context.put(LINKER_COMMAND_CONTEXT_KEY, linkerCmd);
  }

  public static String getLinkerCommand(final Map context) {
    String compilerCmd = (String) context.get(LINKER_COMMAND_CONTEXT_KEY);
    if (compilerCmd == null) {
      compilerCmd = DEFAULT_LINKER_COMMAND;
    }
    return compilerCmd;
  }

  public static void setLinkerScript(final Map context,
      final String linkerScript) {
    context.put(LINKER_SCRIPT_CONTEXT_KEY, linkerScript);
  }

  public static String getLinkerScript(final Map context) {
    return (String) context.get(LINKER_SCRIPT_CONTEXT_KEY);
  }

  public static void setExecutableName(final Map context,
      final String executableName) {
    context.put(EXECUTABLE_NAME_CONTEXT_KEY, executableName);
  }

  public static String getExecutableName(final Map context) {
    return (String) context.get(EXECUTABLE_NAME_CONTEXT_KEY);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy