C++程序  |  99行  |  2.66 KB

/*
 * Copyright 2012, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BCC_SUPPORT_LINKER_CONFIG_H
#define BCC_SUPPORT_LINKER_CONFIG_H

#include <string>

#include <mcld/MC/MCLDInfo.h>
#include <mcld/Support/TargetRegistry.h>
#include <mcld/LD/DiagnosticLineInfo.h>
#include <mcld/LD/DiagnosticPrinter.h>

namespace bcc {

class LinkerConfig {
private:
  //===--------------------------------------------------------------------===//
  // Available Configurations
  //===--------------------------------------------------------------------===//
  const std::string mTriple;
  bool mShared;
  std::string mSOName;

private:
  //===--------------------------------------------------------------------===//
  // These are generated by LinkerConfig during initialize().
  //===--------------------------------------------------------------------===//
  const mcld::Target *mTarget;
  bool initializeTarget();

  mcld::MCLDInfo *mLDInfo;
  bool initializeLDInfo();

  mcld::DiagnosticLineInfo *mDiagLineInfo;
  mcld::DiagnosticPrinter *mDiagPrinter;
  bool initializeDiagnostic();

public:
  //===--------------------------------------------------------------------===//
  // Getters
  //===--------------------------------------------------------------------===//
  inline const std::string &getTriple() const
  { return mTriple; }

  inline const mcld::Target *getTarget() const
  { return mTarget; }

  inline mcld::MCLDInfo* getLDInfo()
  { return mLDInfo; }

  inline const mcld::MCLDInfo* getLDInfo() const
  { return mLDInfo; }

  inline bool isShared() const
  { return mShared; }

  inline std::string getSOName() const
  { return mSOName; }

  void setShared(bool pEnable = true);

  void setBsymbolic(bool pEnable = true);

  void setSOName(const std::string &pSOName);

  void setDyld(const std::string &pDyld);

  void setSysRoot(const std::string &pSysRoot);

  void addWrap(const std::string &pWrapSymbol);

  void addPortable(const std::string &pPortableSymbol);

  void addSearchDir(const std::string &pDir);

public:
  LinkerConfig(const std::string& pTriple);

  virtual ~LinkerConfig();
};

} // end namespace bcc

#endif // BCC_SUPPORT_LINKER_CONFIG_H