Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
strategy:
matrix:
include:
- {os: macOS-latest}
- {os: macos-13}
- {os: macos-latest}
- {os: ubuntu-latest}

runs-on: ${{ matrix.os }}
Expand Down
32 changes: 32 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
2025-03-14 Dirk Eddelbuettel <[email protected]>

* src/authenticate.cpp: Redefine in terms of -DHaveBlp flag and bring
if/else inside the function itself
* src/bdh.cpp: Idem
* src/bdp.cpp: Idem
* src/bds.cpp: Idem
* src/beqs.cpp: Idem
* src/blpConnect.cpp: Idem
* src/blpVersion.cpp: Idem
* src/blpapi_utils.cpp: Idem
* src/bsrch.cpp: Idem
* src/fieldsearch.cpp: Idem
* src/getBars.cpp: Idem
* src/getFieldInfo.cpp: Idem
* src/getTicks.cpp: Idem
* src/lookup.cpp: Idem
* src/subscribe.cpp: Idem

* src/blpVersion.cpp: Define simple haveBlp() helper
* man/haveBlp.Rd: Documentation for haveBlp()
* R/init.R: Use more explicit haveBlp()

2025-03-13 Dirk Eddelbuettel <[email protected]>

* DESCRIPTION (Version, Date): Roll micro version and date

* configure: Streamline and simplify conditional compilation
* src/Makevars.in: Idem

* .github/workflows/ci.yaml: Add macos-13 build for no-blp x86_64

2025-03-12 John Laing <[email protected]>

* src/authenticate.cpp: Correct duplicate export declaration
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rblpapi
Title: R Interface to 'Bloomberg'
Version: 0.3.15.2
Date: 2025-03-09
Version: 0.3.15.3
Date: 2025-03-13
Authors@R: c(person("Whit", "Armstrong", role = "aut"),
person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
comment = c(ORCID = "0000-0001-6419-907X")),
Expand All @@ -18,7 +18,7 @@ SystemRequirements: A valid Bloomberg installation. The API headers and
<https://www.bloomberg.com/professional/support/api-library/> for API
documentation. Currently supported platforms are Windows and Linux (both for
x86-64 processors only) as well as macOS (for arm64 only). Other os-cpu pairings
are not supported by Bloomberg and can therefore not be supported here.
are not supported by Bloomberg and can therefore not be fully supported here.
URL: https://dirk.eddelbuettel.com/code/rblpapi.html, https://github.com/Rblp/Rblpapi
BugReports: https://github.com/Rblp/Rblpapi/issues
License: file LICENSE
Expand Down
9 changes: 9 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ getRuntimeVersion <- function() {
.Call(`_Rblpapi_getRuntimeVersion`)
}

#' This function returns a boolean indicating whether Blp support is available.
#'
#' @title Get Blp availability in current build
#' @return A logical indicating whether Blp was available at build.
#' @author Dirk Eddelbuettel
haveBlp <- function() {
.Call(`_Rblpapi_haveBlp`)
}

bsrch_Impl <- function(con, domain, limit, verbose = FALSE) {
.Call(`_Rblpapi_bsrch_Impl`, con, domain, limit, verbose)
}
Expand Down
12 changes: 5 additions & 7 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@
.pkgenv <- new.env(parent=emptyenv())

.onAttach <- function(libname, pkgname) {
hrd <- getHeaderVersion()
rtm <- getRuntimeVersion()
if (nchar(hrd) + nchar(rtm) == 0) {
packageStartupMessage("No Blp available so no Rblapi functionality.")
} else {
if (haveBlp()) {
packageStartupMessage(paste0("Rblpapi version ", packageVersion("Rblpapi"),
" using Blpapi headers ", hrd, " and run-time ", rtm, "."))
" using Blpapi headers ", getHeaderVersion(),
" and run-time ", getRuntimeVersion(), "."))
packageStartupMessage(paste0("Please respect the Bloomberg licensing agreement ",
"and terms of service."))

if (getOption("blpAutoConnect", FALSE)) {
con <- blpConnect()
if (getOption("blpVerbose", FALSE)) {
Expand All @@ -49,5 +45,7 @@
}
assign("con", con, envir=.pkgenv)
assign("blpAuth", blpAuth, envir=.pkgenv)
} else {
packageStartupMessage("No Blp available so no Rblapi functionality.")
}
}
12 changes: 6 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ else
echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first."
echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi."
echo "The build will proceed but not be functional for lack of a library."
sed -e"s/@config@//" -e"s/@badsystem@/-DNoBlpHere/" src/Makevars.in > src/Makevars
cp -ax src/Makevars.no_blp src/Makevars
exit 0
fi

## Populate Makevars
arch=$(uname -m)
if [ "${arch}" = "x86_64" -a "${platform}" = "linux" ]; then
if [ "${arch}" = "x86_64" ] && [ "${platform}" = "linux" ]; then
echo "Setting up compilation for a ${platform} ${arch} system"
sed -e"s/@config@/-lblpapi3_64/" -e"s/@badsystem@//" src/Makevars.in > src/Makevars
sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars
flavour="64"
# this used to matter when Blp supported x86 on macos, they no longer do
#if [ "${platform}" = "osx" ]; then
# cpu="x86"
#fi
elif [ "${arch}" = "arm64" -a "${platform}" = "osx" ]; then
elif [ "${arch}" = "arm64" ] && [ "${platform}" = "osx" ]; then
echo "Setting up compilation for a ${platform} ${arch} system"
sed -e"s/@config@/-lblpapi3_64/" -e"s/@badsystem@//" src/Makevars.in > src/Makevars
sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars
flavour="64"
cpu="arm"
#elif [ "${arch}" = "i686" ]; then
Expand All @@ -66,7 +66,7 @@ else
echo "Unsupported platform and architecture combination: ${platform} ${arch}."
echo "The build will proceed but not be functional for lack of a library."
echo "If you need such a combination please get in touch with the Blp vendor."
sed -e"s/@config@//" -e"s/@badsystem@/-DNoBlpHere/" src/Makevars.in > src/Makevars
cp -ax src/Makevars.no_blp src/Makevars
exit 0
fi

Expand Down
12 changes: 4 additions & 8 deletions man/blpAuthenticate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getTicks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/haveBlp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
## You should have received a copy of the GNU General Public License
## along with Rblpapi. If not, see <http://www.gnu.org/licenses/>.

## filled in by configure
BBG_LIB = @config@
## Overall 'do we expect to have blp support available' state filled in by configure
##
## (This variable is actually not used below and just left as a reminder 'how to' do
## such replacements with `sed` from `configure`. The build with blp uses the same library
## names throughout; we used to have 32 vs 64 bit builds in past.)
HAVE_BLP = @have_blp@

## this used to be filled in by configure but now both cases use the same value anyway
BBG_LIB = -lblpapi3_64
BBG_RPATH = '$$ORIGIN/../blp'

## set include and linker options
## Bbg API files are assummed to be in the standard search path
PKG_CPPFLAGS = -I../inst/include/ -I. @badsystem@
PKG_CPPFLAGS = -I../inst/include/ -I. -DHaveBlp
PKG_LIBS = $(BBG_LIB) -L../inst/blp -Wl,-rpath,$(BBG_RPATH)

all: $(SHLIB)
# we rely on configure to replace @badsystem@ here to create a side effect
# notice that that there are only two outcomes we need to differentiate:
# - either (on a 'good' system with blp) we will in an empty string, so command -v works as
# usual and we can run install_name_tool to add/update the rpath of shared librart
# - or on a bad system without blp we append -DNoBlpHere making command -v fail and avoiding
# an install_name_call that would fails as we have no Rblpapi.so to adjust
@if command -v install_name_tool@badsystem@; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi
@if command -v install_name_tool; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi
27 changes: 27 additions & 0 deletions src/Makevars.no_blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## -*- mode: makefile; -*-
##
## Makefile -- Unix build system
##
## Copyright (C) 2015-present Dirk Eddelbuettel and Jeroen Ooms
## Copyright (C) 2022-present Tomas Kalibera and Dirk Eddelbuettel
##
## This file is part of Rblpapi
##
## Rblpapi is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 of the License, or
## (at your option) any later version.
##
## Rblpapi is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Rblpapi. If not, see <http://www.gnu.org/licenses/>.

## The 'no blp' build does not require headers or linking: when no blp is
## available, none is used: the build is 'naked'

## use flag to compile without interfacing blp objects
PKG_CPPFLAGS = -DNoBlpHere
5 changes: 2 additions & 3 deletions src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## Makefile.win -- Windows build system
##
## Copyright (C) 2015 - 2024 Whit Armstrong and Dirk Eddelbuettel
## Copyright (C) 2015 - 2025 Whit Armstrong and Dirk Eddelbuettel
##
## This file is part of Rblpapi
##
Expand All @@ -28,8 +28,7 @@ else
endif

## Standard compiler / linker flags including windows flavor
# CXX_STD = CXX11
PKG_CPPFLAGS = -I../inst/include -I.
PKG_CPPFLAGS = -I../inst/include -I. -DHaveBlp
PKG_LIBS = -lblpapi3_${WIN} -L${FLV}


Expand Down
15 changes: 13 additions & 2 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ BEGIN_RCPP
END_RCPP
}
// beqs_Impl
DataFrame beqs_Impl(SEXP con, std::string screenName, std::string screenType, std::string group, std::string pitdate, std::string languageId, bool verbose);
Rcpp::DataFrame beqs_Impl(SEXP con, std::string screenName, std::string screenType, std::string group, std::string pitdate, std::string languageId, bool verbose);
RcppExport SEXP _Rblpapi_beqs_Impl(SEXP conSEXP, SEXP screenNameSEXP, SEXP screenTypeSEXP, SEXP groupSEXP, SEXP pitdateSEXP, SEXP languageIdSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Expand Down Expand Up @@ -148,8 +148,18 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// haveBlp
bool haveBlp();
RcppExport SEXP _Rblpapi_haveBlp() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(haveBlp());
return rcpp_result_gen;
END_RCPP
}
// bsrch_Impl
DataFrame bsrch_Impl(SEXP con, std::string domain, std::string limit, bool verbose);
Rcpp::DataFrame bsrch_Impl(SEXP con, std::string domain, std::string limit, bool verbose);
RcppExport SEXP _Rblpapi_bsrch_Impl(SEXP conSEXP, SEXP domainSEXP, SEXP limitSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Expand Down Expand Up @@ -264,6 +274,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_Rblpapi_blpConnect_Impl", (DL_FUNC) &_Rblpapi_blpConnect_Impl, 4},
{"_Rblpapi_getHeaderVersion", (DL_FUNC) &_Rblpapi_getHeaderVersion, 0},
{"_Rblpapi_getRuntimeVersion", (DL_FUNC) &_Rblpapi_getRuntimeVersion, 0},
{"_Rblpapi_haveBlp", (DL_FUNC) &_Rblpapi_haveBlp, 0},
{"_Rblpapi_bsrch_Impl", (DL_FUNC) &_Rblpapi_bsrch_Impl, 4},
{"_Rblpapi_fieldSearch_Impl", (DL_FUNC) &_Rblpapi_fieldSearch_Impl, 2},
{"_Rblpapi_getBars_Impl", (DL_FUNC) &_Rblpapi_getBars_Impl, 8},
Expand Down
25 changes: 11 additions & 14 deletions src/authenticate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
// You should have received a copy of the GNU General Public License
// along with Rblpapi. If not, see <http://www.gnu.org/licenses/>.

#if !defined(NoBlpHere)

#if defined(HaveBlp)
#include <string>
#include <blpapi_defs.h>
#include <blpapi_element.h>
Expand All @@ -32,7 +31,6 @@
#include <blpapi_session.h>
#include <blpapi_event.h>
#include <blpapi_message.h>
#include <Rcpp.h>
#include <finalizers.h>
#include <blpapi_utils.h>

Expand Down Expand Up @@ -180,27 +178,26 @@ Identity* authenticateWithApp(SEXP con_) {
}
return identity_p;
}
#else
#include <Rcpp/Lightest>
#endif

// Simpler interface
//
// [[Rcpp::export]]
SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_,
SEXP app_name_) {
SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_, SEXP app_name_) {
#if defined(HaveBlp)
Identity* identity_p = NULL;
if (uuid_ == R_NilValue) {
identity_p = authenticateWithApp(con_);
} else {
identity_p = authenticateWithId(con_, uuid_, ip_address_, is_auth_id_, app_name_);
}
if(identity_p == NULL) { Rcpp::stop("Identity pointer is null\n"); }
if (identity_p == NULL) {
Rcpp::stop("Identity pointer is null\n");
}
return createExternalPointer<Identity>(identity_p, identityFinalizer, "blpapi::Identity*");
}

#else // ie if defined(NoBlpHere)

#include <Rcpp/Lightest>
SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_, SEXP app_name_) {
#else // ie no Blp
return R_NilValue;
}

#endif
}
Loading