Skip to content

Commit

Permalink
Implement support for Blizzard's new api endpoints
Browse files Browse the repository at this point in the history
This commit also adds libcurl as a requirement for simulationcraft
compilation (unless SC_NO_NETWORKING is used). Instructions on how to
use libcurl on Windows, Linuxes, and MacOS are in the HowToBuild wiki
entry.

With the new api endpoints, new client credentials are also needed. Wiki
BattleNetImport instructions have also been updated to reflect the new
process.

The old "apikey" option now accepts the new client credentials (in a
colon separated format). A new option "apitoken" has been introduced
that allows the user to supply a custom oauth 2.0 client credentials
bearer token to use for the armory api requests.

Simc tries relatively hard to cache bearer tokens and to reuse them for
as long as the api endpoints allow. On windows, the bearer token is
cached in a text file, either in %HOMEPATH%%HOMEDRIVE%\simc-apitoken, or
in the directory simc.exe (or simulationcraft.exe) is invoked from. On
unixes, the default save path is $HOME/.simc-apitoken, or if $HOME is
not available, in the current working directory.

All reasonably sensible build systems that Simulationcraft uses are
updated to support the libcurl compilation.
  • Loading branch information
navv1234 committed Jan 9, 2019
1 parent f682533 commit 5386b0c
Show file tree
Hide file tree
Showing 17 changed files with 689 additions and 771 deletions.
31 changes: 6 additions & 25 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,12 @@ endif()

# Networking libs
if(NOT SC_NO_NETWORKING)
if(WIN32)
find_library(WININET wininet)
if(NOT WININET)
message(FATAL_ERROR "WinInet not found")
endif()
target_link_libraries(engine ${WININET})
endif()
endif()

# Detect SSL if networking is enabled
if(NOT SC_NO_NETWORKING)
if(APPLE)
find_library(MACOS_SECURITY Security)
find_library(MACOS_CORE_FOUNDATION CoreFoundation)
target_link_libraries(engine ${MACOS_SECURITY} ${MACOS_CORE_FOUNDATION})
message(STATUS "Using macOS native SSL library")
else()
find_package(OpenSSL QUIET)
if(${OPENSSL_FOUND})
message(STATUS "Using OpenSSL")
target_compile_definitions(engine PUBLIC SC_USE_OPENSSL)
target_link_libraries(engine OpenSSL::SSL OpenSSL::Crypto)
else()
message(WARNING "No SSL library available. HTTPS access not available.")
endif()
find_package(CURL REQUIRED)
if (CURL_FOUND)
target_link_libraries(engine ${CURL_LIBRARIES})
target_include_directories(engine PUBLIC ${CURL_INCLUDE_DIRS})
else(CURL_FOUND)
message(FATAL_ERROR "libcurl not found")
endif()
endif()

Expand Down
6 changes: 6 additions & 0 deletions engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ GIT = $(shell [ -d ../.git ] && which git)

LINK_LIBS =

ifeq (${SC_NO_NETWORKING},)
LINK_LIBS += -lcurl
else
OPTS += -DSC_NO_NETWORKING
endif

# Include build setting from user configuration file
-include ../build.conf

Expand Down
Loading

0 comments on commit 5386b0c

Please sign in to comment.