Skip to content

Commit

Permalink
Update Makevars
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Feb 5, 2024
1 parent 40f21f6 commit f27c627
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 29 deletions.
51 changes: 51 additions & 0 deletions run_conan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3

# Copyright (C) 2024 Roberto Rossini <[email protected]>
#
# SPDX-License-Identifier: MIT

import subprocess as sp
import shutil
import os


def find_conan():
conan = shutil.which("conan")
if conan is None:
raise RuntimeError("Unable to find conan in your PATH.\n"
"Please install conan: https://conan.io/downloads")

return conan


def run_conan_profile_detect(conan):
sp.run(conan, "profile", "detect", stderr=sp.DEVNULL, stdout=sp.DEVNULL)


def run_conan_install(conan):
sp.check_call(conan, "install", "../conanfile.txt", "--settings=build_type=Release",
"--settings=compiler.cppstd=17", "--output-folder=conan-staging",
"--build=missing" "--update", stdout=sp.DEVNULL)


def main():
conan = find_conan()
pwd = os.getcwd()

conandeps_mk = os.path.join(pwd, "conan-staging", "conandeps.mk")

if os.path.exists(conandeps_mk):
print(conandeps_mk)
return

conan_home = os.getenv("CONAN_HOME")
if conan_home is not None:
os.makedirs(conan_home, exist_ok=True)

run_conan_profile_detect(conan)
run_conan_install(conan)
print(conandeps_mk)


if __name__ == "__main__":
main()
24 changes: 0 additions & 24 deletions run_conan.sh

This file was deleted.

11 changes: 6 additions & 5 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
dollar = $
PWD := $(pwd)
CONAN_HOME := "$(PWD)/conan-staging/.conan2"
CONANDEPS_MK := $(shell "$(CONAN_HOME)" ../run_conan.py)
include $(CONANDEPS_MK)

RUN_CONAN_RESULT := $(shell CONAN_HOME="$(dollar)PWD/conan-staging/.conan2" ../run_conan.sh)
include conan-staging/conandeps.mk

PKG_CPPFLAGS := $(shell "$R_HOME/bin/Rscript" -e 'Rcpp:::CxxFlags()' 2> /dev/null)
PKG_CPPFLAGS := -std=c++17
PKG_CPPFLAGS := $(PKG_CPPFLAGS) $(shell "$(R_HOME)/bin/Rscript" -e 'Rcpp:::CxxFlags()' 2> /dev/null)
PKG_CPPFLAGS := $(PKG_CPPFLAGS) $(addprefix -isystem ,$(CONAN_INCLUDE_DIRS))
PKG_CPPFLAGS := $(PKG_CPPFLAGS) $(addprefix -isystem ,$(CONAN_INCLUDE_DIRS_HDF5_HDF5_C))
PKG_CPPFLAGS := $(PKG_CPPFLAGS) $(addprefix -D ,$(CONAN_DEFINES))
Expand Down

0 comments on commit f27c627

Please sign in to comment.