Commit 66e0de5e authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding cpprestsdk as externalproject, xacc lone dep is now openssl 1.0.2


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 84c471f9
...@@ -19,7 +19,6 @@ message(STATUS "C++ version ${CXX_STANDARD} configured.") ...@@ -19,7 +19,6 @@ message(STATUS "C++ version ${CXX_STANDARD} configured.")
# Make sure all build libraries have reference to their dependents # Make sure all build libraries have reference to their dependents
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
include(ExternalProject) include(ExternalProject)
...@@ -44,16 +43,33 @@ ExternalProject_Add(cppmicroservices ...@@ -44,16 +43,33 @@ ExternalProject_Add(cppmicroservices
GIT_REPOSITORY https://github.com/cppmicroservices/cppmicroservices GIT_REPOSITORY https://github.com/cppmicroservices/cppmicroservices
GIT_TAG v3.1.0 GIT_TAG v3.1.0
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/cppus_install INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
)
find_package(OpenSSL 1.0.2 REQUIRED)
message(STATUS "Found OpenSSL version ${OPENSSL_VERSION}")
ExternalProject_Add(cpprestsdk
GIT_REPOSITORY https://github.com/Microsoft/cpprestsdk
GIT_TAG v2.10.1
CONFIGURE_COMMAND ${CMAKE_COMMAND} ../cpprestsdk/Release/ -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
) )
set(CppMicroServices_BASE_DIR ${CMAKE_BINARY_DIR}/cppus_install/usr/local)
set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3) set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib) set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(CppRSDK_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(CppRSDK_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
# Look for OpenMP, add it we find it # Look for OpenMP, add it we find it
find_package(OpenMP) find_package(OpenMP)
if (OPENMP_FOUND) if (OPENMP_FOUND)
...@@ -61,16 +77,19 @@ if (OPENMP_FOUND) ...@@ -61,16 +77,19 @@ if (OPENMP_FOUND)
endif() endif()
ExternalProject_Add(xacc-core ExternalProject_Add(xacc-core
DEPENDS cppmicroservices DEPENDS cppmicroservices cpprestsdk
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xacc SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xacc
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DBOOST_ROOT=${BOOST_ROOT} -DBOOST_ROOT=${BOOST_ROOT}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR} -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR} -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR} -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1 BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/stage INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/stage
...@@ -94,8 +113,11 @@ ExternalProject_Add(xacc-quantum ...@@ -94,8 +113,11 @@ ExternalProject_Add(xacc-quantum
-DBOOST_ROOT=${BOOST_ROOT} -DBOOST_ROOT=${BOOST_ROOT}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR} -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR} -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc #${XACC_INCLUDE_DIR} -DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR} -DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1 BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
...@@ -116,6 +138,9 @@ ExternalProject_Add(xacc-python ...@@ -116,6 +138,9 @@ ExternalProject_Add(xacc-python
-DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include #${XACC_INCLUDE_DIR} -DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include #${XACC_INCLUDE_DIR}
-DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR} -DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1 BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
......
set (XACC_ROOT "@CMAKE_INSTALL_PREFIX@") set (XACC_ROOT "@CMAKE_INSTALL_PREFIX@")
set (XACC_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/cppmicroservices3;@CMAKE_INSTALL_PREFIX@/include/xacc;@CMAKE_INSTALL_PREFIX@/include/quantum/gate;@CMAKE_INSTALL_PREFIX@/include/quantum/aqc;@CMAKE_INSTALL_PREFIX@/include/spdlog;@CMAKE_INSTALL_PREFIX@/include/eigen") set (XACC_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/cppmicroservices3;@CMAKE_INSTALL_PREFIX@/include/xacc;@CMAKE_INSTALL_PREFIX@/include/quantum/gate;@CMAKE_INSTALL_PREFIX@/include/quantum/aqc;@CMAKE_INSTALL_PREFIX@/include/spdlog;@CMAKE_INSTALL_PREFIX@/include/eigen;@CMAKE_INSTALL_PREFIX@/include/rapidjson/include;@CMAKE_INSTALL_PREFIX@/include;@OPENSSL_INCLUDE_DIR@")
set (XACC_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib") set (XACC_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib")
set(CppUsLib CppMicroServicesd) set(CppUsLib CppMicroServicesd)
link_directories("@CMAKE_INSTALL_PREFIX@/lib") link_directories("@CMAKE_INSTALL_PREFIX@/lib")
find_library(cppus_has_d_suffix CppMicroServicesd PATHS @CMAKE_INSTALL_PREFIX@/lib) find_library(cppus_has_d_suffix CppMicroServicesd PATHS @CMAKE_INSTALL_PREFIX@/lib)
if (NOT cppus_has_d_suffix) if (NOT cppus_has_d_suffix)
set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;CppMicroServices") set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;CppMicroServices;cpprest;@OPENSSL_LIBRARIES@")
else() else()
set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;CppMicroServicesd") set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;CppMicroServicesd;cpprest;@OPENSSL_LIBRARIES@")
endif() endif()
...@@ -52,7 +52,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd) ...@@ -52,7 +52,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix) if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices) set(CppUsLib CppMicroServices)
endif() endif()
target_link_libraries(pyxacc ${PYTHON_LIBRARY} xacc xacc-quantum-gate xacc-quantum-aqc ${CppUsLib} ${Boost_LIBRARIES}) target_link_libraries(pyxacc ${PYTHON_LIBRARY} xacc xacc-quantum-gate xacc-quantum-aqc ${CppUsLib} ${Boost_LIBRARIES} cpprest ${OPENSSL_LIBRARIES})
install(TARGETS pyxacc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python) install(TARGETS pyxacc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python)
endif() endif()
\ No newline at end of file
...@@ -44,5 +44,8 @@ include_directories(${CMAKE_BINARY_DIR}) ...@@ -44,5 +44,8 @@ include_directories(${CMAKE_BINARY_DIR})
link_directories(${XACC_LIBRARY_DIR}) link_directories(${XACC_LIBRARY_DIR})
link_directories(${CPPUS_LIBRARY_DIR}) link_directories(${CPPUS_LIBRARY_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${CppRSDK_INCLUDE_DIR})
add_subdirectory(gate) add_subdirectory(gate)
add_subdirectory(aqc) add_subdirectory(aqc)
...@@ -60,7 +60,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd) ...@@ -60,7 +60,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix) if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices) set(CppUsLib CppMicroServices)
endif() endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} xacc) target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} xacc cpprest ${OPENSSL_LIBRARIES})
add_subdirectory(ir) add_subdirectory(ir)
add_subdirectory(compiler) add_subdirectory(compiler)
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
# *******************************************************************************/ # *******************************************************************************/
# Gather tests # Gather tests
file (GLOB test_files tests/*.cpp) file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};dl;pthread;xacc-quantum-aqc;xacc") add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};dl;pthread;xacc-quantum-aqc;xacc;cpprest;${OPENSSL_LIBRARIES}")
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
# *******************************************************************************/ # *******************************************************************************/
# Gather tests # Gather tests
file (GLOB test_files tests/*.cpp) file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc") add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;cpprest;${OPENSSL_LIBRARIES}")
...@@ -65,7 +65,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd) ...@@ -65,7 +65,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix) if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices) set(CppUsLib CppMicroServices)
endif() endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} xacc ${CppUsLib}) target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} xacc ${CppUsLib} cpprest ${OPENSSL_LIBRARIES})
add_subdirectory(compiler) add_subdirectory(compiler)
add_subdirectory(ir) add_subdirectory(ir)
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
# *******************************************************************************/ # *******************************************************************************/
# Gather tests # Gather tests
file (GLOB test_files tests/*.cpp) file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc") add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc;cpprest;${OPENSSL_LIBRARIES}")
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
# Gather tests # Gather tests
file (GLOB test_files tests/*.cpp) file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};xacc;xacc-quantum-gate") add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LIBRARY_NAME};${Boost_LIBRARIES};xacc;xacc-quantum-gate;cpprest;${OPENSSL_LIBRARIES}")
...@@ -14,6 +14,6 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen) ...@@ -14,6 +14,6 @@ include_directories(${CMAKE_SOURCE_DIR}/tpls/eigen)
# Gather tests # Gather tests
file (GLOB test_files tests/*.cpp) file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;xacc-quantum-gate") add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc;xacc-quantum-gate;cpprest;${OPENSSL_LIBRARIES}")
...@@ -22,18 +22,20 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules") ...@@ -22,18 +22,20 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules")
include(tests) include(tests)
# We require Boost without MPI # We require Boost without MPI
find_package(Boost COMPONENTS system program_options regex filesystem chrono thread REQUIRED) find_package(Boost COMPONENTS system program_options regex filesystem chrono thread graph REQUIRED)
#endif() #endif()
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
include_directories(${XACC_ROOT}/tpls/spdlog) include_directories(${XACC_ROOT}/tpls/spdlog)
include_directories(${CPPUS_INCLUDE_DIR}) include_directories(${CPPUS_INCLUDE_DIR})
include_directories(${CppRSDK_INCLUDE_DIR})
include_directories("${CMAKE_SOURCE_DIR}") include_directories("${CMAKE_SOURCE_DIR}")
include_directories("${CMAKE_SOURCE_DIR}/ir") include_directories("${CMAKE_SOURCE_DIR}/ir")
include_directories("${CMAKE_SOURCE_DIR}/compiler") include_directories("${CMAKE_SOURCE_DIR}/compiler")
include_directories("${CMAKE_SOURCE_DIR}/program") include_directories("${CMAKE_SOURCE_DIR}/program")
include_directories("${CMAKE_SOURCE_DIR}/accelerator") include_directories("${CMAKE_SOURCE_DIR}/accelerator")
include_directories("${CMAKE_SOURCE_DIR}/utils") include_directories("${CMAKE_SOURCE_DIR}/utils")
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR})
# Create a xacc config header file # Create a xacc config header file
...@@ -45,7 +47,7 @@ install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc) ...@@ -45,7 +47,7 @@ install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc)
set (LIBRARY_NAME xacc) set (LIBRARY_NAME xacc)
file (GLOB HEADERS XACC.hpp ir/*.hpp program/*.hpp compiler/*.hpp accelerator/*.hpp accelerator/remote/*.hpp utils/*.hpp) file (GLOB HEADERS XACC.hpp ir/*.hpp program/*.hpp compiler/*.hpp accelerator/*.hpp accelerator/remote/*.hpp utils/*.hpp)
file (GLOB SRC *.cpp program/*.cpp utils/*.cpp) file (GLOB SRC *.cpp program/*.cpp utils/*.cpp accelerator/remote/*.cpp)
set(CppUsLib CppMicroServicesd) set(CppUsLib CppMicroServicesd)
link_directories(${CPPUS_LIBRARY_DIR}) link_directories(${CPPUS_LIBRARY_DIR})
...@@ -56,7 +58,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd) ...@@ -56,7 +58,7 @@ find_library(cppus_has_d_suffix CppMicroServicesd)
if (NOT cppus_has_d_suffix) if (NOT cppus_has_d_suffix)
set(CppUsLib CppMicroServices) set(CppUsLib CppMicroServices)
endif() endif()
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib}) target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${CppUsLib} ${OPENSSL_LIBRARIES} cpprest)
# Get the test files # Get the test files
file(GLOB test_files utils/tests/*Tester.cpp accelerator/tests/*Tester.cpp) file(GLOB test_files utils/tests/*Tester.cpp accelerator/tests/*Tester.cpp)
......
/*******************************************************************************
* Copyright (c) 2018 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompanies this
* distribution. The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
* is available at https://eclipse.org/org/documents/edl-v10.php
*
* Contributors:
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#include "RemoteAccelerator.hpp"
namespace xacc {
const std::string RestClient::post(const std::string& remoteUrl,
const std::string& path, const std::string& postStr,
std::map<std::string, std::string> headers) {
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
headers.insert(std::make_pair("Accept", "*/*"));
}
http::uri uri = http::uri(remoteUrl);
http_client postClient(
http::uri_builder(uri).append_path(U(path)).to_uri());
http_request postRequest(methods::POST);
for (auto& kv : headers) {
postRequest.headers().add(kv.first, kv.second);
}
postRequest.set_body(postStr);
// Post the problem, get the response as json
auto postResponse = postClient.request(postRequest);
auto respJson = postResponse.get().extract_string().get();
// Map that response to a string
std::stringstream ss;
ss << respJson;
return ss.str();
}
const std::string RestClient::get(const std::string& remoteUrl,
const std::string& path, std::map<std::string, std::string> headers) {
http_client getClient(
http::uri_builder(http::uri(remoteUrl)).append_path(U(path)).to_uri());
http_request getRequest(methods::GET);
for (auto& kv : headers) {
getRequest.headers().add(kv.first, kv.second);
}
auto getResponse = getClient.request(getRequest);
// get the result as a string
std::stringstream z;
try {
z << getResponse.get().extract_json().get();
// xacc::info("GET RESPONSE: " + z.str());
} catch (std::exception& e) {
std::cout << "HELLO WORLD!, Caught exception, " << e.what() << "\n";
}
return z.str();
}
void RemoteAccelerator::execute(std::shared_ptr<AcceleratorBuffer> buffer,
const std::shared_ptr<Function> function) {
auto jsonPostStr = processInput(buffer, std::vector<std::shared_ptr<Function>> {
function });
auto responseStr = restClient->post(remoteUrl, postPath, jsonPostStr, headers);
processResponse(buffer, responseStr);
return;
}
std::vector<std::shared_ptr<AcceleratorBuffer>> RemoteAccelerator::execute(
std::shared_ptr<AcceleratorBuffer> buffer,
const std::vector<std::shared_ptr<Function>> functions) {
auto jsonPostStr = processInput(buffer, functions);
auto responseStr = restClient->post(remoteUrl, postPath, jsonPostStr, headers);
return processResponse(buffer, responseStr);
}
}
...@@ -34,55 +34,12 @@ public: ...@@ -34,55 +34,12 @@ public:
virtual const std::string post(const std::string& remoteUrl, virtual const std::string post(const std::string& remoteUrl,
const std::string& path, const std::string& postStr, const std::string& path, const std::string& postStr,
std::map<std::string, std::string> headers = std::map<std::string, std::map<std::string, std::string> headers = std::map<std::string,
std::string> { }) { std::string> { });
if (headers.empty()) {
headers.insert(std::make_pair("Content-type", "application/json"));
headers.insert(std::make_pair("Connection", "keep-alive"));
headers.insert(std::make_pair("Accept", "*/*"));
}
http::uri uri = http::uri(remoteUrl);
http_client postClient(
http::uri_builder(uri).append_path(U(path)).to_uri());
http_request postRequest(methods::POST);
for (auto& kv : headers) {
postRequest.headers().add(kv.first, kv.second);
}
postRequest.set_body(postStr);
// Post the problem, get the response as json
auto postResponse = postClient.request(postRequest);
auto respJson = postResponse.get().extract_string().get();
// Map that response to a string
std::stringstream ss;
ss << respJson;
return ss.str();
}
virtual const std::string get(const std::string& remoteUrl, virtual const std::string get(const std::string& remoteUrl,
const std::string& path, const std::string& path,
std::map<std::string, std::string> headers = std::map<std::string, std::map<std::string, std::string> headers = std::map<std::string,
std::string> { }) { std::string> { });
http_client getClient(
http::uri_builder(http::uri(remoteUrl)).append_path(U(path)).to_uri());
http_request getRequest(methods::GET);
for (auto& kv : headers) {
getRequest.headers().add(kv.first, kv.second);
}
auto getResponse = getClient.request(getRequest);
// get the result as a string
std::stringstream z;
try {
z << getResponse.get().extract_json().get();
// xacc::info("GET RESPONSE: " + z.str());
} catch (std::exception& e) {
std::cout << "HELLO WORLD!, Caught exception, " << e.what() << "\n";
}
return z.str();
}
virtual ~RestClient() {} virtual ~RestClient() {}
...@@ -105,18 +62,7 @@ public: ...@@ -105,18 +62,7 @@ public:
* @param function The kernel to execute. * @param function The kernel to execute.
*/ */
virtual void execute(std::shared_ptr<AcceleratorBuffer> buffer, virtual void execute(std::shared_ptr<AcceleratorBuffer> buffer,
const std::shared_ptr<Function> function) { const std::shared_ptr<Function> function);
auto jsonPostStr = processInput(buffer, std::vector<std::shared_ptr<Function>> {
function });
auto responseStr = restClient->post(remoteUrl, postPath, jsonPostStr, headers);
processResponse(buffer, responseStr);
return;
}
/** /**
* Execute a set of kernels with one remote call. Return * Execute a set of kernels with one remote call. Return
...@@ -130,13 +76,7 @@ public: ...@@ -130,13 +76,7 @@ public:
*/ */
virtual std::vector<std::shared_ptr<AcceleratorBuffer>> execute( virtual std::vector<std::shared_ptr<AcceleratorBuffer>> execute(
std::shared_ptr<AcceleratorBuffer> buffer, std::shared_ptr<AcceleratorBuffer> buffer,
const std::vector<std::shared_ptr<Function>> functions) { const std::vector<std::shared_ptr<Function>> functions);
auto jsonPostStr = processInput(buffer, functions);
auto responseStr = restClient->post(remoteUrl, postPath, jsonPostStr, headers);
return processResponse(buffer, responseStr);
}
virtual bool isRemote() { virtual bool isRemote() {
return true; return true;
......
...@@ -5,15 +5,15 @@ namespace xacc { ...@@ -5,15 +5,15 @@ namespace xacc {
void ServiceRegistry::initialize() { void ServiceRegistry::initialize() {
if (!initialized) { if (!initialized) {
XACCLogger::instance()->info("Creating CppUs Framework."); // XACCLogger::instance()->info("Creating CppUs Framework.");
framework = FrameworkFactory().NewFramework(); framework = FrameworkFactory().NewFramework();
// Initialize the framework, such that we can call // Initialize the framework, such that we can call
// GetBundleContext() later. // GetBundleContext() later.
XACCLogger::instance()->info("Running Framework.Init."); // XACCLogger::instance()->info("Running Framework.Init.");
framework.Init(); framework.Init();
XACCLogger::instance()->info("Getting the Framework Bundle Context."); // XACCLogger::instance()->info("Getting the Framework Bundle Context.");
context = framework.GetBundleContext(); context = framework.GetBundleContext();
if (!context) { if (!context) {
XACCLogger::instance()->error( XACCLogger::instance()->error(
...@@ -22,31 +22,12 @@ void ServiceRegistry::initialize() { ...@@ -22,31 +22,12 @@ void ServiceRegistry::initialize() {
const std::string xaccLibDir = std::string(XACC_INSTALL_DIR) + std::string("/lib"); const std::string xaccLibDir = std::string(XACC_INSTALL_DIR) + std::string("/lib");
DIR *dir; XACCLogger::instance()->info("XACC Library Directory: " + xaccLibDir);
struct dirent *ent;
if ((dir = opendir (xaccLibDir.c_str())) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
printf ("DIRENT: %s\n", ent->d_name);
}
closedir (dir);
} else {
/* could not open directory */
perror ("");
}
XACCLogger::instance()->info("XACC Lib Directory: " + xaccLibDir);
for (auto &entry : boost::filesystem::directory_iterator(xaccLibDir)) { for (auto &entry : boost::filesystem::directory_iterator(xaccLibDir)) {
XACCLogger::instance()->info("TEST: " + entry.path().filename().string());
if (entry.path().filename().string() == "lib") {
for (auto& e : boost::filesystem::directory_iterator(entry.path())) {
XACCLogger::instance()->info("SUB LIB: " + e.path().string());
}
}
// We want the gate and aqc bundles that come with XACC // We want the gate and aqc bundles that come with XACC
if (boost::contains(entry.path().filename().string(), if (boost::contains(entry.path().filename().string(),
"libxacc-quantum")) { "libxacc-quantum")) {
XACCLogger::instance()->info("Installing base plugin " + entry.path().string()); XACCLogger::instance()->info("Installing base plugin " + entry.path().filename().string());
context.InstallBundles(entry.path().string()); context.InstallBundles(entry.path().string());
} }
} }
...@@ -55,15 +36,12 @@ void ServiceRegistry::initialize() { ...@@ -55,15 +36,12 @@ void ServiceRegistry::initialize() {
boost::filesystem::directory_iterator end_itr; boost::filesystem::directory_iterator end_itr;
boost::filesystem::path xaccPluginPath( boost::filesystem::path xaccPluginPath(
std::string(XACC_INSTALL_DIR) + std::string("/lib/plugins")); std::string(XACC_INSTALL_DIR) + std::string("/lib/plugins"));
XACCLogger::instance()->info("XACC Plugin Lib Directory: " + std::string(XACC_INSTALL_DIR) + std::string("/lib/plugins"));
if (boost::filesystem::exists(xaccPluginPath)) { if (boost::filesystem::exists(xaccPluginPath)) {
for (auto& entry : boost::filesystem::directory_iterator(xaccPluginPath)) { for (auto& entry : boost::filesystem::directory_iterator(xaccPluginPath)) {
auto p = entry.path();