Skip to content

Commit cd63a88

Browse files
authored
Refine conditional build (#410)
* Streamline and simplify configure and Makevars.in * Add macos-13 to CI matrix for test on x86_64 macos without blp * Remove a bashism in configure * GNU make is a SystemRequirement (because of ifeq/endif) * Roll micro version and date * Cover 'yes/no' case fully from configure so no ifeq needed in make * Rework in terms of an affirming -DHaveBlp and streamline code
1 parent a509c71 commit cd63a88

28 files changed

+293
-300
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
- {os: macOS-latest}
17+
- {os: macos-13}
18+
- {os: macos-latest}
1819
- {os: ubuntu-latest}
1920

2021
runs-on: ${{ matrix.os }}

ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2025-03-14 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/authenticate.cpp: Redefine in terms of -DHaveBlp flag and bring
4+
if/else inside the function itself
5+
* src/bdh.cpp: Idem
6+
* src/bdp.cpp: Idem
7+
* src/bds.cpp: Idem
8+
* src/beqs.cpp: Idem
9+
* src/blpConnect.cpp: Idem
10+
* src/blpVersion.cpp: Idem
11+
* src/blpapi_utils.cpp: Idem
12+
* src/bsrch.cpp: Idem
13+
* src/fieldsearch.cpp: Idem
14+
* src/getBars.cpp: Idem
15+
* src/getFieldInfo.cpp: Idem
16+
* src/getTicks.cpp: Idem
17+
* src/lookup.cpp: Idem
18+
* src/subscribe.cpp: Idem
19+
20+
* src/blpVersion.cpp: Define simple haveBlp() helper
21+
* man/haveBlp.Rd: Documentation for haveBlp()
22+
* R/init.R: Use more explicit haveBlp()
23+
24+
2025-03-13 Dirk Eddelbuettel <[email protected]>
25+
26+
* DESCRIPTION (Version, Date): Roll micro version and date
27+
28+
* configure: Streamline and simplify conditional compilation
29+
* src/Makevars.in: Idem
30+
31+
* .github/workflows/ci.yaml: Add macos-13 build for no-blp x86_64
32+
133
2025-03-12 John Laing <[email protected]>
234

335
* src/authenticate.cpp: Correct duplicate export declaration

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rblpapi
22
Title: R Interface to 'Bloomberg'
3-
Version: 0.3.15.2
4-
Date: 2025-03-09
3+
Version: 0.3.15.3
4+
Date: 2025-03-13
55
Authors@R: c(person("Whit", "Armstrong", role = "aut"),
66
person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
77
comment = c(ORCID = "0000-0001-6419-907X")),
@@ -18,7 +18,7 @@ SystemRequirements: A valid Bloomberg installation. The API headers and
1818
<https://www.bloomberg.com/professional/support/api-library/> for API
1919
documentation. Currently supported platforms are Windows and Linux (both for
2020
x86-64 processors only) as well as macOS (for arm64 only). Other os-cpu pairings
21-
are not supported by Bloomberg and can therefore not be supported here.
21+
are not supported by Bloomberg and can therefore not be fully supported here.
2222
URL: https://dirk.eddelbuettel.com/code/rblpapi.html, https://github.com/Rblp/Rblpapi
2323
BugReports: https://github.com/Rblp/Rblpapi/issues
2424
License: file LICENSE

R/RcppExports.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ getRuntimeVersion <- function() {
5959
.Call(`_Rblpapi_getRuntimeVersion`)
6060
}
6161

62+
#' This function returns a boolean indicating whether Blp support is available.
63+
#'
64+
#' @title Get Blp availability in current build
65+
#' @return A logical indicating whether Blp was available at build.
66+
#' @author Dirk Eddelbuettel
67+
haveBlp <- function() {
68+
.Call(`_Rblpapi_haveBlp`)
69+
}
70+
6271
bsrch_Impl <- function(con, domain, limit, verbose = FALSE) {
6372
.Call(`_Rblpapi_bsrch_Impl`, con, domain, limit, verbose)
6473
}

R/init.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,12 @@
2121
.pkgenv <- new.env(parent=emptyenv())
2222

2323
.onAttach <- function(libname, pkgname) {
24-
hrd <- getHeaderVersion()
25-
rtm <- getRuntimeVersion()
26-
if (nchar(hrd) + nchar(rtm) == 0) {
27-
packageStartupMessage("No Blp available so no Rblapi functionality.")
28-
} else {
24+
if (haveBlp()) {
2925
packageStartupMessage(paste0("Rblpapi version ", packageVersion("Rblpapi"),
30-
" using Blpapi headers ", hrd, " and run-time ", rtm, "."))
26+
" using Blpapi headers ", getHeaderVersion(),
27+
" and run-time ", getRuntimeVersion(), "."))
3128
packageStartupMessage(paste0("Please respect the Bloomberg licensing agreement ",
3229
"and terms of service."))
33-
3430
if (getOption("blpAutoConnect", FALSE)) {
3531
con <- blpConnect()
3632
if (getOption("blpVerbose", FALSE)) {
@@ -49,5 +45,7 @@
4945
}
5046
assign("con", con, envir=.pkgenv)
5147
assign("blpAuth", blpAuth, envir=.pkgenv)
48+
} else {
49+
packageStartupMessage("No Blp available so no Rblapi functionality.")
5250
}
5351
}

configure

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ else
3939
echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first."
4040
echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi."
4141
echo "The build will proceed but not be functional for lack of a library."
42-
sed -e"s/@config@//" -e"s/@badsystem@/-DNoBlpHere/" src/Makevars.in > src/Makevars
42+
cp -ax src/Makevars.no_blp src/Makevars
4343
exit 0
4444
fi
4545

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

man/blpAuthenticate.Rd

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/getTicks.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/haveBlp.Rd

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Makevars.in

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@
2020
## You should have received a copy of the GNU General Public License
2121
## along with Rblpapi. If not, see <http://www.gnu.org/licenses/>.
2222

23-
## filled in by configure
24-
BBG_LIB = @config@
23+
## Overall 'do we expect to have blp support available' state filled in by configure
24+
##
25+
## (This variable is actually not used below and just left as a reminder 'how to' do
26+
## such replacements with `sed` from `configure`. The build with blp uses the same library
27+
## names throughout; we used to have 32 vs 64 bit builds in past.)
28+
HAVE_BLP = @have_blp@
29+
30+
## this used to be filled in by configure but now both cases use the same value anyway
31+
BBG_LIB = -lblpapi3_64
2532
BBG_RPATH = '$$ORIGIN/../blp'
2633

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

3239
all: $(SHLIB)
33-
# we rely on configure to replace @badsystem@ here to create a side effect
34-
# notice that that there are only two outcomes we need to differentiate:
35-
# - either (on a 'good' system with blp) we will in an empty string, so command -v works as
36-
# usual and we can run install_name_tool to add/update the rpath of shared librart
37-
# - or on a bad system without blp we append -DNoBlpHere making command -v fail and avoiding
38-
# an install_name_call that would fails as we have no Rblpapi.so to adjust
39-
@if command -v install_name_tool@badsystem@; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi
40+
@if command -v install_name_tool; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi

0 commit comments

Comments
 (0)