1 /* 2 * Copyright 2013, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ABCC_ABCC_HOST_H 18 #define ABCC_ABCC_HOST_H 19 20 #include <cstdio> 21 #include "Abcc.h" 22 23 #define LOG(format, ...) do { \ 24 fprintf(stderr, format, ##__VA_ARGS__); \ 25 fprintf(stderr, "\n"); \ 26 } while(0) 27 28 extern bool kVerbose; 29 #define LOGE LOG 30 #define LOGV(format, ...) do {\ 31 if (kVerbose) LOG(format, ##__VA_ARGS__); \ 32 } while(0) 33 34 namespace abcc { 35 36 class HostBitcodeCompiler : public BitcodeCompiler { 37 std::string mIn; 38 std::string mOut; 39 std::string mNDKDir; // empty string if standalone mode 40 std::string mPlatform; 41 std::string mToolchainBinPath; // Used at ndk mode to prevent tedious path issue 42 std::map<std::string, std::string> mRuntimePath; // mappings of library name and full path 43 44 public: 45 HostBitcodeCompiler(const std::string &abi, const std::string &sysroot, const std::string &toolchain_bin, 46 const std::string &input, const std::string &output, const std::string &working_dir, 47 const std::string &platform, const bool savetemps, bool bit32 = true); 48 HostBitcodeCompiler(const std::string &abi, const std::string &sysroot, const std::string &ndk_dir, const std::string &toolchain_bin, 49 const std::string &input, const std::string &output, const std::string &working_dir, 50 const std::string &platform, const bool savetemps, bool bit32 = true); 51 52 public: 53 virtual int parseLDFlags(BitcodeInfo &info, const std::string &str); 54 55 private: 56 virtual void getBitcodeFiles(); 57 virtual void prepareToolchain(); 58 virtual void copyRuntime(const BitcodeInfo &info); 59 virtual void removeIntermediateFile(const std::string &path); 60 void initRuntimePath(); 61 const std::string getRuntimePath(const std::string &libname); 62 63 private: 64 const std::string getToolchainBinPath() const; 65 const std::string getCompilerRTPath() const; 66 const std::string getGAbixxPath() const; 67 const std::string getLibPortablePath() const; 68 const std::string getGCCUnwindPath() const; 69 }; 70 71 } // namespace abcc 72 73 #endif 74