1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3# reserved. See files LICENSE and NOTICE for details. 4# 5# This file is part of CEED, a collection of benchmarks, miniapps, software 6# libraries and APIs for efficient high-order finite element and spectral 7# element discretizations for exascale applications. For more information and 8# source code availability see http://github.com/ceed. 9# 10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11# a collaborative effort of two U.S. Department of Energy organizations (Office 12# of Science and the National Nuclear Security Administration) responsible for 13# the planning and preparation of a capable exascale ecosystem, including 14# software, applications, hardware, advanced system engineering and early 15# testbed platforms, in support of the nation's exascale computing imperative. 16 17import os 18from cffi import FFI 19ffibuilder = FFI() 20 21# ------------------------------------------------------------------------------ 22# Provide C definitions to CFFI 23# ------------------------------------------------------------------------------ 24with open(os.path.abspath("include/ceed.h")) as f: 25 lines = [line.strip() for line in f if 26 not line.startswith("#") and 27 not line.startswith(" static") and 28 "CeedErrorImpl" not in line and 29 "const char *, ...);" not in line and 30 not line.startswith("CEED_EXTERN const char *const")] 31 lines = [line.replace("CEED_EXTERN", "extern") for line in lines] 32 header = '\n'.join(lines) 33 header = header.split("static inline CeedInt CeedIntPow", 1)[0] 34ffibuilder.cdef(header) 35 36# ------------------------------------------------------------------------------ 37# Set source of libCEED header file 38# ------------------------------------------------------------------------------ 39ceed_dir = os.getenv("CEED_DIR", None) 40if ceed_dir: 41 ceed_lib_dirs = [os.path.abspath("lib"), os.path.join(ceed_dir, "lib")] 42else: 43 ceed_lib_dirs = [os.path.abspath("lib")] 44 45ffibuilder.set_source("_ceed_cffi", 46 """ 47 #include <ceed.h> // the C header of the library 48 """, 49 include_dirs = [os.path.abspath("include")], # include path 50 libraries = ["ceed"], # library name, for the linker 51 library_dirs = [os.path.abspath("lib")], # library path, for the linker 52 runtime_library_dirs = ceed_lib_dirs # library path, at runtime 53) 54 55# ------------------------------------------------------------------------------ 56# Builder 57# ------------------------------------------------------------------------------ 58if __name__ == "__main__": 59 ffibuilder.compile(verbose=True) 60 61# ------------------------------------------------------------------------------ 62