(use_mingw=False, use_gpu=False, use_mpi=False,
use_hdfs=False, boost_root=None, boost_dir=None,
boost_include_dir=None, boost_librarydir=None,
opencl_include_dir=None, opencl_library=None,
openmp_include_dir=None, openmp_library=None,
nomp=False, bit32=False)
| 87 | |
| 88 | |
| 89 | def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, |
| 90 | use_hdfs=False, boost_root=None, boost_dir=None, |
| 91 | boost_include_dir=None, boost_librarydir=None, |
| 92 | opencl_include_dir=None, opencl_library=None, |
| 93 | openmp_include_dir=None, openmp_library=None, |
| 94 | nomp=False, bit32=False): |
| 95 | |
| 96 | if os.path.exists(os.path.join(CURRENT_DIR, "build_cpp")): |
| 97 | shutil.rmtree(os.path.join(CURRENT_DIR, "build_cpp")) |
| 98 | os.makedirs(os.path.join(CURRENT_DIR, "build_cpp")) |
| 99 | os.chdir(os.path.join(CURRENT_DIR, "build_cpp")) |
| 100 | |
| 101 | logger.info("Starting to compile the library.") |
| 102 | |
| 103 | cmake_cmd = ["cmake", "../compile/"] |
| 104 | if use_gpu: |
| 105 | cmake_cmd.append("-DUSE_GPU=ON") |
| 106 | if boost_root: |
| 107 | cmake_cmd.append("-DBOOST_ROOT={0}".format(boost_root)) |
| 108 | if boost_dir: |
| 109 | cmake_cmd.append("-DBoost_DIR={0}".format(boost_dir)) |
| 110 | if boost_include_dir: |
| 111 | cmake_cmd.append("-DBoost_INCLUDE_DIR={0}".format(boost_include_dir)) |
| 112 | if boost_librarydir: |
| 113 | cmake_cmd.append("-DBOOST_LIBRARYDIR={0}".format(boost_librarydir)) |
| 114 | if opencl_include_dir: |
| 115 | cmake_cmd.append("-DOpenCL_INCLUDE_DIR={0}".format(opencl_include_dir)) |
| 116 | if opencl_library: |
| 117 | cmake_cmd.append("-DOpenCL_LIBRARY={0}".format(opencl_library)) |
| 118 | if use_mpi: |
| 119 | cmake_cmd.append("-DUSE_MPI=ON") |
| 120 | if nomp: |
| 121 | cmake_cmd.append("-DUSE_OPENMP=OFF") |
| 122 | if use_hdfs: |
| 123 | cmake_cmd.append("-DUSE_HDFS=ON") |
| 124 | |
| 125 | if system() in ('Windows', 'Microsoft'): |
| 126 | if use_mingw: |
| 127 | if use_mpi: |
| 128 | raise Exception('MPI version cannot be compiled by MinGW due to the miss of MPI library in it') |
| 129 | logger.info("Starting to compile with CMake and MinGW.") |
| 130 | silent_call(cmake_cmd + ["-G", "MinGW Makefiles"], raise_error=True, |
| 131 | error_msg='Please install CMake and all required dependencies first') |
| 132 | silent_call(["mingw32-make.exe", "_lightgbm"], raise_error=True, |
| 133 | error_msg='Please install MinGW first') |
| 134 | else: |
| 135 | status = 1 |
| 136 | lib_path = os.path.join(CURRENT_DIR, "compile", "windows", "x64", "DLL", "lib_lightgbm.dll") |
| 137 | if not any((use_gpu, use_mpi, use_hdfs, nomp, bit32)): |
| 138 | logger.info("Starting to compile with MSBuild from existing solution file.") |
| 139 | platform_toolsets = ("v142", "v141", "v140") |
| 140 | for pt in platform_toolsets: |
| 141 | status = silent_call(["MSBuild", |
| 142 | os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"), |
| 143 | "/p:Configuration=DLL", |
| 144 | "/p:Platform=x64", |
| 145 | "/p:PlatformToolset={0}".format(pt)]) |
| 146 | if status == 0 and os.path.exists(lib_path): |
no test coverage detected