26 Commits

Author SHA1 Message Date
hayodea 53583e5735 SenseApiLib, SenseApiDesc improvements, new Sense API Mgmt Lib Ops role
SenseApiDesc:
* Use a number count for num exported implexor APIs instead of
  NULL-terminated list.
* Add sanity checker functions for structs.

SenseApiLib:
* Invoke the new sanity checkers on new Lib objects.
* SenseApiDesc is now a member object instead of being
  pointed to.

SenseApiManager:
* loadSenseApiLib now calls the SenseApiDesc getter function.
* loadSenseApiLib now fills out the SenseApiLib class object.

New Sense API Mgmt Sub-API:

This sub-api (metalanguage, some might call it) is used to initialize
the lib's connection to the provider. After this call, the lib should
be ready to attach new devices to its provider on behalf of Hk.
2025-01-09 06:03:43 -04:00
hayodea 2a397ae064 Build: Check for libXCB when building XcbXorg sense API 2025-01-08 18:36:34 -04:00
hayodea 88df316013 build: Conditionally compile senseApis 2025-01-08 18:27:40 -04:00
hayodea 396bcefbf4 XcbXorg: Fill in correct placeholder implexor algo name 2025-01-08 18:00:07 -04:00
hayodea 62db724246 senseApiMgr: Fix formatting 2025-01-08 17:58:08 -04:00
hayodea bbbd6c36cd Release: Tagging v0.00.002:
* Loadable sense API libraries.
2025-01-08 17:34:33 -04:00
hayodea d14cef5328 Move senseApi libs into their own outer subdir 2025-01-08 17:28:21 -04:00
hayodea 988e84a545 Pretty up exception message 2025-01-08 15:09:18 -04:00
hayodea 4f2fbaa255 Fix NULL ptr use from dlerror() 2025-01-08 15:08:51 -04:00
hayodea 01ddb6d842 Only search in senseApiLibPath if it's actually set 2025-01-08 15:08:23 -04:00
hayodea 1178970728 cmd:opts: Now set OptionParser::argv0 to argv[0] 2025-01-08 15:07:42 -04:00
hayodea 090f0d3b02 senseApiMgr: new method: loadAllSenseApisFromOptions
This method dlopens() all senseApi libs that were referenced by
device specs.
2025-01-08 15:06:31 -04:00
hayodea 04db7bf76c Fix build warning about decltype(dlclose) 2025-01-08 15:05:56 -04:00
hayodea 2dc3083cdb whitespace 2025-01-08 13:47:16 -04:00
hayodea bffa2b837c Opts: Make singleton; senseApi: check senseApiLibPath, get senseApiDescFn pointer.
* OptionsParser now has a singleton.
* We now use the cmdline opt -p <senseApiLibPath>, and search for
  the specified library in:
  * senseApiLibPath, then CWD, then the place where our executable
    is running from, and then finally we let the hosting OS do
    its own search.
* We now call dlsym() on dlopen()'d libs to to get the senseApiDescFn
  pointer.
2025-01-08 13:43:44 -04:00
hayodea b40790ee4a Whitespace 2025-01-08 11:50:16 -04:00
hayodea c864bcfdd2 SenseApis: Define descriptors exported by libs 2025-01-08 11:49:28 -04:00
hayodea f5e3986644 DeviceSpec:parser: improve exception messages 2025-01-08 11:46:59 -04:00
hayodea 5a5e2fa25f Fix const_cast and rearrange logic in senseApi method 2025-01-08 07:56:10 -04:00
hayodea b9aa53822f Indentation 2025-01-08 07:27:48 -04:00
hayodea 376b29871b Change version to 0.00.001. 2025-01-08 06:35:34 -04:00
hayodea fe3f911db4 SenseApis: New senseApiManager and X11XcbApi
Still fleshing these out but ultimately senseApiMgr will manage
sense apis, and the X11XcbApi is where we'll connect to Xcb and
read the screen.
2025-01-08 06:26:36 -04:00
hayodea f594d29a2d DevMgr: Add sensorDevSpecs list and make intero/extro lists use unique_ptr 2025-01-08 06:23:34 -04:00
hayodea 6a494f7ff7 cmd:opts: New -a (sense-api shlibs) and -p (api shlib search dir) opts 2025-01-08 06:19:46 -04:00
hayodea 36acbdfc36 cmd:opts: Add senseApiPath in prep for new cmd opts 2025-01-08 00:32:07 -04:00
hayodea dd7a75d9b5 devSpec: Update preprocessor error message 2025-01-07 20:21:15 -04:00
26 changed files with 9770 additions and 28 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
SUBDIRS = hcore
SUBDIRS = hcore senseApis
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include"
bin_PROGRAMS = harikoff
harikoff_SOURCES = main.cpp
harikoff_LDADD = hcore/libhcore.a hcore/deviceManager/libdeviceManager.a
harikoff_LDADD = hcore/libhcore.a hcore/deviceManager/libdeviceManager.a \
hcore/senseApis/libsenseApis.a
+14 -2
View File
@@ -1,4 +1,4 @@
AC_INIT([Harriman-Peikoff Project], [0.00.000],
AC_INIT([Harriman-Peikoff Project], [0.00.002],
[latentprion@gmail.com],
[harikoff],
[github.com/latentprion/harikoff])
@@ -35,24 +35,34 @@ m4_include([m4/ac_prog_flex.m4])
m4_include([m4/ac_prog_bison.m4])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AM_PROG_AR
LT_INIT([shared])
AC_PROG_LEX(noyywrap)
AC_PROG_YACC
AS_IF([test -z "${LEX}" || test -z "${YACC}"], [
AC_MSG_ERROR([LEX and YACC must both be available in PATH.])
])
AC_SEARCH_LIBS([dlopen], [dl ldl], [], [
AC_MSG_ERROR([dlopen() not found in libdl or libldl.])
])
AM_CPPFLAGS=m4_normalize(["-I\"\$(top_srcdir)/include\""])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([YACC])
AC_SUBST([LEX])
m4_include([m4/senseApis.m4])
AC_SUBST([SENSEAPIS_ENABLED])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_FILES([
Makefile hcore/Makefile
hcore/deviceManager/Makefile
hcore/senseApis/Makefile
senseApis/Makefile
senseApis/xcbXorg/Makefile
])
AC_CONFIG_COMMANDS_POST([
@@ -60,6 +70,8 @@ AC_CONFIG_COMMANDS_POST([
AC_MSG_NOTICE(m4_normalize([* MIND_VOSCILLATOR_PERIOD_MS:
${MIND_VOSCILLATOR_PERIOD_MS} ms
(freq: ${MIND_VOSCILLATOR_FREQ_MS} Hz)]))
AC_MSG_NOTICE(m4_normalize(
[* SenseAPI backends enabled: ${SENSEAPIS_ENABLED}]))
])
AC_OUTPUT
+1 -1
View File
@@ -1,4 +1,4 @@
SUBDIRS = deviceManager
SUBDIRS = deviceManager senseApis
AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include"
noinst_LIBRARIES = libhcore.a
+7 -5
View File
@@ -4,14 +4,16 @@
#include <string>
#include <vector>
#include <sstream>
#include <memory>
#include <opts.h>
#include <deviceManager/deviceManager.h>
std::vector<DeviceManager::InteroceptorDeviceSpec>
std::vector<std::unique_ptr<DeviceManager::InteroceptorDeviceSpec>>
DeviceManager::interoceptorDeviceSpecs;
std::vector<DeviceManager::ExtrospectorDeviceSpec>
std::vector<std::unique_ptr<DeviceManager::ExtrospectorDeviceSpec>>
DeviceManager::extrospectorDeviceSpecs;
std::vector<std::reference_wrapper<DeviceManager::SensorDeviceSpec>>
DeviceManager::sensorDeviceSpecs;
std::ostream& operator<<(
std::ostream& os, const DeviceManager::SensorDeviceSpec& spec)
@@ -35,11 +37,11 @@ const std::string DeviceManager::printDeviceSpecs(void)
std::ostringstream oss;
for (const auto& spec : DeviceManager::interoceptorDeviceSpecs) {
oss << "Interoceptor " << spec;
oss << "Interoceptor " << *spec;
}
for (const auto& spec : DeviceManager::extrospectorDeviceSpecs) {
oss << "Extrospector " << spec;
oss << "Extrospector " << *spec;
}
return oss.str();
+9 -3
View File
@@ -14,7 +14,9 @@ std::string DeviceManager::readDeviceFile(const std::string& filename)
{
std::ifstream file(filename);
if (!file.is_open()) {
throw std::runtime_error("Could not open file: " + filename);
throw std::runtime_error(
std::string(__func__) + ": Couldn't open deviceSpec file: "
+ filename);
}
std::string content(
@@ -46,11 +48,15 @@ void DeviceManager::parseAllDeviceSpecs(void)
&fclose);
if (!input) {
throw std::runtime_error("Failed to open memory as file");
throw std::runtime_error(
std::string(__func__) + ": Failed to fmemopen() a FILE* for "
"parsing device specs");
}
deviceSpeclin = input.get();
if (deviceSpecpparse()) {
throw std::runtime_error("Failed to parse device specs");
throw std::runtime_error(
std::string(__func__) + ": Failed to parse device specs. "
"Check specs for errors");
}
}
+13 -9
View File
@@ -5,6 +5,8 @@
#include <cstring>
#include <cstdlib>
#include <stdexcept>
#include <memory>
#include <functional>
#include <deviceManager/deviceManager.h>
#ifndef yylex
@@ -17,7 +19,7 @@
* lexer must have the same prefix as the parser they generate. So we just use
* this #define below to override yacc/bison's presumed prefix for the lexer.
*/
#error "Yacc should have defined yylex, and we need to override it to tell yacc the name of our lex function."
#error "Yacc should have defined yylex as a preprocessor token, and we need to override it to tell yacc the name of our lex function."
#endif
#undef yylex
#define yylex deviceSpecllex
@@ -70,23 +72,25 @@ sensor_spec:
interoceptor_spec:
KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body {
DeviceManager::InteroceptorDeviceSpec *spec =
static_cast<DeviceManager::InteroceptorDeviceSpec *>($3);
auto spec = std::make_unique<DeviceManager::InteroceptorDeviceSpec>(
*static_cast<DeviceManager::InteroceptorDeviceSpec *>($3));
spec->sensorType = $1;
DeviceManager::interoceptorDeviceSpecs.push_back(*spec);
delete spec;
DeviceManager::interoceptorDeviceSpecs.push_back(std::move(spec));
DeviceManager::sensorDeviceSpecs.push_back(*spec);
delete $3;
}
;
extrospector_spec:
KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body {
DeviceManager::ExtrospectorDeviceSpec *spec =
static_cast<DeviceManager::ExtrospectorDeviceSpec *>($3);
auto spec = std::make_unique<DeviceManager::ExtrospectorDeviceSpec>(
*static_cast<DeviceManager::ExtrospectorDeviceSpec *>($3));
spec->sensorType = $1;
DeviceManager::extrospectorDeviceSpecs.push_back(*spec);
delete spec;
DeviceManager::extrospectorDeviceSpecs.push_back(std::move(spec));
DeviceManager::sensorDeviceSpecs.push_back(*spec);
delete $3;
}
;
+7 -2
View File
@@ -3,6 +3,7 @@
#include <vector>
#include <string>
#include <memory>
#include <opts.h>
#include <utility>
#include <iostream>
@@ -51,8 +52,12 @@ private:
public:
std::string allDeviceSpecs;
static std::vector<InteroceptorDeviceSpec> interoceptorDeviceSpecs;
static std::vector<ExtrospectorDeviceSpec> extrospectorDeviceSpecs;
static std::vector<std::unique_ptr<InteroceptorDeviceSpec>>
interoceptorDeviceSpecs;
static std::vector<std::unique_ptr<ExtrospectorDeviceSpec>>
extrospectorDeviceSpecs;
static std::vector<std::reference_wrapper<SensorDeviceSpec>>
sensorDeviceSpecs;
};
#endif // DEVICEMANAGER_H
+9
View File
@@ -16,7 +16,16 @@ public:
void dumpOptions() const;
std::string getUsage() const;
static OptionParser &getOptions(void)
{
static OptionParser options;
return options;
}
public:
std::string argv0;
std::string senseApiLibPath;
std::vector<std::string> senseApiLibs;
std::string deviceSpecs;
std::vector<std::string> deviceSpecFiles;
bool verbose, printUsage;
+119
View File
@@ -0,0 +1,119 @@
#ifndef SENSE_API_PROVIDER_DESC_H
#define SENSE_API_PROVIDER_DESC_H
#include <string>
#include <memory>
#include <vector>
#include <dlfcn.h>
#include <functional>
#include <user/senseApiDesc.h>
namespace hk {
namespace sense_api {
/* C++ version of the C struct above, which Harikoff uses to manage the
* lib and connect implexors to it.
*/
class SenseApiDesc
{
public:
class ExportedImplexorApiDesc
{
public:
ExportedImplexorApiDesc(const CExportedImplexorApiDesc& cDesc)
// The caller should sanity check before calling this constructor.
: name(cDesc.name)
{}
const std::string name;
};
public:
SenseApiDesc() = default;
SenseApiDesc(const CSenseApiDesc& cDesc)
// The caller should sanity check before calling this constructor.
: name(cDesc.name)
{
for (uint32_t i = 0; i < cDesc.numExportedImplexorApis; ++i)
{
if (!CExportedImplexorApiDesc_sanityCheck(
&cDesc.exportedImplexorApis[i]))
{
throw std::runtime_error(
"Sanity check failed for exported implexor API descriptor");
}
exportedImplexorApis.push_back(
ExportedImplexorApiDesc(cDesc.exportedImplexorApis[i]));
}
}
std::string name;
// These are the implexors whose APIs this lib exports.
std::vector<ExportedImplexorApiDesc> exportedImplexorApis;
};
class SenseApiLib
{
public:
SenseApiLib(
const std::string& path, void *_dlopen_handle, getSenseApiDescFn *descFn)
: libraryPath(path),
dlopen_handle(
_dlopen_handle, reinterpret_cast<void(*)(void*)>(&dlclose)),
HK_GET_SENSE_API_DESC_FN_NAME(descFn)
{}
void setSenseApiDesc(const CSenseApiDesc* desc)
{
if (!CSenseApiDesc_sanityCheck(desc) ||
!Csal_libMgmtOps_sanityCheck(desc->sal_libMgmtOps))
{
throw std::runtime_error(
std::string(__func__) + ": Sanity check failed for sense API "
"descriptor in library '" + libraryPath + "'");
}
for (uint32_t i = 0; i < desc->numExportedImplexorApis; ++i)
{
if (!CExportedImplexorApiDesc_sanityCheck(
&desc->exportedImplexorApis[i]))
{
throw std::runtime_error(
std::string(__func__) + ": Sanity check failed for "
"exported implexor API descriptor in library '"
+ libraryPath + "'");
}
}
new (&senseApiDesc) SenseApiDesc(*desc); // Placement new
}
public:
std::string libraryPath;
std::unique_ptr<void, void(*)(void*)> dlopen_handle;
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
* sense api lib's behaviour globally.
*/
std::vector<std::string> options;
/**
* @brief Every sense API lib is required to provide a function that returns
* a CSenseApiDesc struct. This struct states which API the lib uses to
* connect Harikoff to the sense provider it supports.
*
* This getter function should be visible to dlsym() so that Harikoff can
* find it in the lib after loading it, and call it.
*/
std::function<getSenseApiDescFn> HK_GET_SENSE_API_DESC_FN_NAME;
/**
* @brief Harikoff will call the `HK_GET_SENSE_API_DESC_FN_NAME` getter
* function and use the data it provides in order to fill out this
* descriptor.
*/
SenseApiDesc senseApiDesc;
};
} // namespace sense_api
} // namespace hk
#endif // SENSE_API_PROVIDER_DESC_H
+42
View File
@@ -0,0 +1,42 @@
#ifndef SENSE_API_MANAGER_H
#define SENSE_API_MANAGER_H
#include <config.h>
#include <memory>
#include <vector>
#include <string>
#include <optional>
#include <functional>
#include <senseApis/senseApiLib.h>
namespace hk {
namespace sense_api {
class SenseApiManager {
public:
static SenseApiManager& getInstance()
{
static SenseApiManager instance;
return instance;
}
SenseApiLib& loadSenseApiLib(const std::string& libraryPath);
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLib(
const std::string& libraryPath);
void unloadSenseApiLib(const std::string& libraryPath);
void loadAllSenseApiLibsFromOptions(void);
private:
SenseApiManager() = default;
~SenseApiManager() = default;
SenseApiManager(const SenseApiManager&) = delete;
SenseApiManager& operator=(const SenseApiManager&) = delete;
std::vector<std::unique_ptr<SenseApiLib>> senseApiLibs;
};
} // namespace sense_api
} // namespace hk
#endif // SENSE_API_MANAGER_H
+46 -3
View File
@@ -4,6 +4,8 @@
#include <getopt.h>
#include <string>
#include <vector>
#include <sys/stat.h>
struct option OptionParser::longOptions[] = {
{"devicespec", required_argument, 0, 's'},
@@ -11,6 +13,9 @@ struct option OptionParser::longOptions[] = {
{"devspec", required_argument, 0, 's'},
{"devfile", required_argument, 0, 'd'},
{"devicefile", required_argument, 0, 'd'},
{"sense-api-lib", required_argument, 0, 'a'},
{"senseapi", required_argument, 0, 'a'},
{"sense-api-path", required_argument, 0, 'p'},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'},
{0, 0, 0, 0}
@@ -20,9 +25,12 @@ void OptionParser::parseArguments(int argc, char *argv[])
{
int opt;
int optionIndex = 0;
argv0 = argv[0];
optind = 1; // Reset optind to 1 before parsing
while ((opt = getopt_long(
argc, argv, "s:d:v?", longOptions, &optionIndex)) != -1)
argc, argv, "s:d:a:p:v?", longOptions, &optionIndex)) != -1)
{
switch (opt)
{
@@ -35,6 +43,30 @@ void OptionParser::parseArguments(int argc, char *argv[])
case 'd':
deviceSpecFiles.push_back(optarg);
break;
case 'a':
senseApiLibs.push_back(optarg);
break;
case 'p':
{
struct stat info;
if (!senseApiLibPath.empty())
{
std::cerr << std::string(__func__)
+ " - Overwriting previous sense-api-path with: " << optarg
<< '\n';
}
if (stat(optarg, &info) != 0 || !(info.st_mode & S_IFDIR))
{
throw std::invalid_argument(
std::string(__func__) + " - The specified path is not a "
"directory: " + optarg);
}
senseApiLibPath = optarg;
break;
}
case 'v':
verbose = true;
break;
@@ -42,15 +74,19 @@ void OptionParser::parseArguments(int argc, char *argv[])
printUsage = true;
return;
default:
throw std::invalid_argument("Invalid argument encountered: " + std::string(argv[optind - 1]));
throw std::invalid_argument(
std::string(__func__) + " - Invalid argument encountered: "
+ std::string(argv[optind - 1]));
}
}
}
std::string OptionParser::getUsage() const
{
return "Usage: program [-s|--devicespec|--spec|--devspec <device_spec>] "
return "Usage: " + argv0 + " [-s|--devicespec|--spec|--devspec <device_spec>] "
"[-d|--devfile|--devicefile <filename>] "
"[-a|--sense-api-lib|--senseapi <filename>] "
"[-p|--sense-api-path <directory>] "
"[-v|--verbose] "
"[-?|--help]";
}
@@ -68,4 +104,11 @@ void OptionParser::dumpOptions() const
std::cout << file << " ";
}
std::cout << std::endl;
std::cout << "Sense API Library Path: " << senseApiLibPath << std::endl;
std::cout << "Sense API Libraries: ";
for (const auto& lib : senseApiLibs) {
std::cout << lib << " ";
}
std::cout << std::endl;
}
+4
View File
@@ -0,0 +1,4 @@
AM_CPPFLAGS+= -I"$(top_srcdir)/hcore/include"
noinst_LIBRARIES=libsenseApis.a
libsenseApis_a_SOURCES=senseApiManager.cpp
+155
View File
@@ -0,0 +1,155 @@
#include <iostream>
#include <stdexcept>
#include <optional>
#include <filesystem>
#include <senseApis/senseApiManager.h>
#include <senseApis/senseApiLib.h>
#include <opts.h>
#include <user/senseApiDesc.h>
namespace fs = std::filesystem;
namespace hk {
namespace sense_api {
struct DlCloser {
void operator()(void* handle) const {
if (handle) {
dlclose(handle);
}
}
};
static std::optional<std::string> findLibraryPath(
const std::string& libraryPath)
{
std::vector<std::string> searchPaths = {
fs::current_path().string(),
fs::path("/proc/self/exe").parent_path().string()
};
if (!OptionParser::getOptions().senseApiLibPath.empty())
{
searchPaths.insert(
searchPaths.begin(), OptionParser::getOptions().senseApiLibPath);
}
for (const auto& path : searchPaths)
{
fs::path fullPath = fs::path(path) / libraryPath;
if (fs::exists(fullPath))
{
return fullPath.string();
}
}
std::cerr << std::string(__func__) + ": library '"
+ libraryPath + "' isn't in search bespoke search paths: ";
for (const auto& path : searchPaths)
{
std::cerr << path << " ";
}
std::cerr << std::endl;
std::cerr << "Trying to load " + libraryPath + " from system default search "
"paths\n";
return std::nullopt;
}
SenseApiLib& SenseApiManager::loadSenseApiLib(const std::string& libraryPath)
{
const CSenseApiDesc *libApiDesc;
std::optional<std::string> fullPath = findLibraryPath(libraryPath);
std::string resolvedPath = fullPath.value_or(libraryPath);
// Clear any existing error
dlerror();
auto dlopen_handle = std::unique_ptr<void, DlCloser>(
dlopen(resolvedPath.c_str(), RTLD_LAZY));
if (!dlopen_handle && fullPath.has_value())
{
// Fallback to using the supplied libraryPath
dlerror();
dlopen_handle.reset(dlopen(libraryPath.c_str(), RTLD_LAZY));
}
if (!dlopen_handle)
{
const char *dlerr = dlerror();
std::string error = (dlerr
? dlerr
: "Unknown error while opening shlib");
throw std::runtime_error(
std::string(__func__) + ": Cannot load library '"
+ libraryPath + "': "
+ error);
}
// Initialize getSenseApiDescriptor
auto func = reinterpret_cast<getSenseApiDescFn *>(
dlsym(dlopen_handle.get(), HK_GET_SENSE_API_DESC_FN_NAME_STR));
if (!func)
{
throw std::runtime_error(
std::string(__func__) + ": dlsym('"
HK_GET_SENSE_API_DESC_FN_NAME_STR "') failed for library '"
+ libraryPath + "'");
}
libApiDesc = func();
if (!libApiDesc)
{
throw std::runtime_error(
std::string(__func__) + ": getSenseApiDesc() returned NULL for "
"library '" + libraryPath + "'");
}
auto lib = std::make_unique<SenseApiLib>(
libraryPath, dlopen_handle.release(), func);
lib->setSenseApiDesc(libApiDesc);
senseApiLibs.push_back(std::move(lib));
return *senseApiLibs.back();
}
std::optional<std::reference_wrapper<SenseApiLib>>
SenseApiManager::getSenseApiLib(const std::string& libraryPath)
{
auto it = std::find_if(senseApiLibs.begin(), senseApiLibs.end(),
[&libPath = libraryPath](const std::unique_ptr<SenseApiLib>& lib) {
return lib->libraryPath == libPath;
}
);
if (it != senseApiLibs.end()) { return **it; }
return std::nullopt;
}
void SenseApiManager::unloadSenseApiLib(const std::string& libraryPath)
{
auto it = std::find_if(senseApiLibs.begin(), senseApiLibs.end(),
[&lpath = libraryPath](const std::unique_ptr<SenseApiLib>& lib) {
return lib->libraryPath == lpath;
}
);
if (it != senseApiLibs.end())
{
senseApiLibs.erase(it);
return;
}
std::cerr << std::string(__func__) + ": Library not found: "
<< libraryPath << '\n';
}
void SenseApiManager::loadAllSenseApiLibsFromOptions()
{
const auto& options = OptionParser::getOptions();
for (const auto& libPath : options.senseApiLibs) {
loadSenseApiLib(libPath);
}
}
} // namespace sense_api
} // namespace hk
+9
View File
@@ -0,0 +1,9 @@
#ifndef HK_PREPROCESSOR_H
#define HK_PREPROCESSOR_H
#define HK_Q(x) #x
#define HK_QUOTE(x) HK_Q(x)
#define HK_UNMANGLED "C"
#endif // HK_PREPROCESSOR_H
+100
View File
@@ -0,0 +1,100 @@
#ifndef __USER_SENSE_API_LIB_H__
#define __USER_SENSE_API_LIB_H__
#include <preprocessor.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Exported by all sense API Libraries to tell Harikoff what API the lib uses
* to connect to providers; and also to state which implexor APIs it exports.
*/
struct CExportedImplexorApiDesc
{
const char *name;
};
typedef int (sal_lmo_initializeIndFn)(void);
typedef int (sal_lmo_finalizeIndFn)(void);
typedef int (sal_lmo_attachDeviceReqFn)(void);
typedef int (sal_lmo_detachDeviceReqFn)(void);
struct Csal_libMgmtOps
{
/* When Harikoff loads a sense API lib, it calls this function to initialize
* the lib. When this returns, the lib should be ready to attach devices.
*/
sal_lmo_initializeIndFn *initializeInd;
/* Harikoff calls this to finalize the lib and free its internal
* resources. When this returns, the lib should be ready to be unloaded.
*/
sal_lmo_finalizeIndFn *finalizeInd;
/* Harikoff calls this to attach a device to the lib. When it returns, the
* device should be attached and ready to be implexed.
*/
sal_lmo_attachDeviceReqFn *attachDeviceReq;
// When this returns, the device should be detached.
sal_lmo_detachDeviceReqFn *detachDeviceReq;
};
struct CSenseApiDesc
{
/* Shortname that identifies the API used by this lib to talk to the sense
* provider.
*/
const char *name;
/* These are the implexors whose APIs this lib exports.
*/
uint32_t numExportedImplexorApis;
CExportedImplexorApiDesc *exportedImplexorApis;
/* Sub-API for managing the lib. Library role within the API.
*/
Csal_libMgmtOps *sal_libMgmtOps;
};
static bool CSenseApiDesc_sanityCheck(const CSenseApiDesc *desc)
{
if (!desc || !desc->name || desc->numExportedImplexorApis < 1
||!desc->exportedImplexorApis || !desc->sal_libMgmtOps)
{
return false;
}
return true;
}
static bool CExportedImplexorApiDesc_sanityCheck(
const CExportedImplexorApiDesc *desc)
{
if (!desc || !desc->name)
{
return false;
}
return true;
}
static bool Csal_libMgmtOps_sanityCheck(const Csal_libMgmtOps *ops)
{
if (!ops || !ops->initializeInd || !ops->finalizeInd
|| !ops->attachDeviceReq || !ops->detachDeviceReq)
{
return false;
}
return true;
}
#define HK_GET_SENSE_API_DESC_FN_NAME getSenseApiDesc
#define HK_GET_SENSE_API_DESC_FN_NAME_STR \
HK_QUOTE(HK_GET_SENSE_API_DESC_FN_NAME)
typedef const CSenseApiDesc *(getSenseApiDescFn)(void);
#ifdef __cplusplus
}
#endif
#endif // __USER_SENSE_API_LIB_H__
+8427
View File
File diff suppressed because it is too large Load Diff
+437
View File
@@ -0,0 +1,437 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free
# Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option '$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the 'shared' and
# 'disable-shared' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the 'static' and
# 'disable-static' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the 'fast-install'
# and 'disable-fast-install' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])
+124
View File
@@ -0,0 +1,124 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])
+24
View File
@@ -0,0 +1,24 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation,
# Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 4245 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.7])
m4_define([LT_PACKAGE_REVISION], [2.4.7])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.7'
macro_revision='2.4.7'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
+99
View File
@@ -0,0 +1,99 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free
# Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
+20
View File
@@ -0,0 +1,20 @@
SENSEAPIS_ENABLED=
AC_ARG_ENABLE([senseapi-xcbxorg],
[AS_HELP_STRING([--enable-senseapi-xcbxorg],
[Enable XCB/Xorg SenseAPI backend])],
[AS_CASE([$enableval],
[no], [enable_senseapi_xcbxorg=no],
[yes|*], [
enable_senseapi_xcbxorg=yes
AC_DEFINE([XCBXORG_ENABLED], [1],
[Define to 1 if you have XCB/Xorg SenseAPI backend])
SENSEAPIS_ENABLED="${SENSEAPIS_ENABLED} xcbXorg"
PKG_CHECK_MODULES([XCB], [xcb], [], [
AC_MSG_ERROR(m4_normalize([XCB library not found. Sense API
XCB/Xorg requires the XCB dev headers and shlib.]))
])
]
)],
[enable_senseapi_xcbxorg=no]
)
+6 -1
View File
@@ -3,11 +3,15 @@
#include <opts.h>
#include <mind.h>
#include <deviceManager/deviceManager.h>
#include <senseApis/senseApiManager.h>
int main(int argc, char **argv)
{
using namespace hk;
try {
OptionParser options;
OptionParser &options = OptionParser::getOptions();
hk::Mind mind;
std::cout << PACKAGE_NAME << " " << PACKAGE_VERSION << std::endl;
@@ -29,6 +33,7 @@ try {
DeviceManager::getInstance().collateAllDeviceSpecs(options);
DeviceManager::getInstance().parseAllDeviceSpecs();
std::cout << DeviceManager::printDeviceSpecs() << std::endl;
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
}
catch (const std::exception& e) {
std::cerr << "Exception occurred: " << e.what() << std::endl;
+1
View File
@@ -0,0 +1 @@
SUBDIRS = @SENSEAPIS_ENABLED@
+2
View File
@@ -0,0 +1,2 @@
pkglib_LTLIBRARIES=libxcbXorg.la
libxcbXorg_la_SOURCES=xcbXorg.cpp
+69
View File
@@ -0,0 +1,69 @@
#include <iostream>
#include <algorithm>
#include <stdexcept>
#include "xcbXorg.h"
static CExportedImplexorApiDesc xcbXorgExportedImplexorApis[] =
{
{
.name = "video-implexor"
}
};
static sal_lmo_initializeIndFn xcbXorg_initializeInd;
static sal_lmo_finalizeIndFn xcbXorg_finalizeInd;
static sal_lmo_attachDeviceReqFn xcbXorg_attachDeviceReq;
static sal_lmo_detachDeviceReqFn xcbXorg_detachDeviceReq;
static Csal_libMgmtOps xcbXorgSalLibMgmtOps =
{
.initializeInd = xcbXorg_initializeInd,
.finalizeInd = xcbXorg_finalizeInd,
.attachDeviceReq = xcbXorg_attachDeviceReq,
.detachDeviceReq = xcbXorg_detachDeviceReq
};
static CSenseApiDesc xcbXorgApiDesc =
{
.name = "XcbXorg",
.numExportedImplexorApis = sizeof(xcbXorgExportedImplexorApis) /
sizeof(*xcbXorgExportedImplexorApis),
.exportedImplexorApis = xcbXorgExportedImplexorApis,
.sal_libMgmtOps = &xcbXorgSalLibMgmtOps
};
extern HK_UNMANGLED getSenseApiDescFn HK_GET_SENSE_API_DESC_FN_NAME;
const CSenseApiDesc *HK_GET_SENSE_API_DESC_FN_NAME(void)
{
return &xcbXorgApiDesc;
}
static sal_lmo_initializeIndFn xcbXorg_initializeInd;
int xcbXorg_initializeInd(void)
{
std::cerr << "XcbXorg::sal_lmo_initializeInd\n";
return 0;
}
static sal_lmo_finalizeIndFn xcbXorg_finalizeInd;
int xcbXorg_finalizeInd(void)
{
std::cerr << "XcbXorg::sal_lmo_finalizeInd\n";
return 0;
}
static sal_lmo_attachDeviceReqFn xcbXorg_attachDeviceReq;
int xcbXorg_attachDeviceReq(void)
{
std::cerr << "XcbXorg::sal_lmo_attachDeviceReq\n";
return 0;
}
static sal_lmo_detachDeviceReqFn xcbXorg_detachDeviceReq;
int xcbXorg_detachDeviceReq(void)
{
std::cerr << "XcbXorg::sal_lmo_detachDeviceReq\n";
return 0;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef X11_XCB_API_H
#define X11_XCB_API_H
#include <string>
#include <vector>
#include <memory>
#include <user/senseApiDesc.h>
class Xcb_XorgApi
{
public:
Xcb_XorgApi(const std::string& _displayName)
: displayName(_displayName)
{}
~Xcb_XorgApi() = default;
private:
std::string displayName;
};
#endif // X11_XCB_API_H