Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
552861d3
Commit
552861d3
authored
4 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Load correct runtime library in linux
parent
711447d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#33793
passed
4 years ago
Stage: all
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SDK/CPP/CMakeLists.txt
+18
-0
18 additions, 0 deletions
SDK/CPP/CMakeLists.txt
SDK/CPP/public/voltu.cpp
+34
-1
34 additions, 1 deletion
SDK/CPP/public/voltu.cpp
with
52 additions
and
1 deletion
SDK/CPP/CMakeLists.txt
+
18
−
0
View file @
552861d3
...
@@ -11,6 +11,24 @@ add_library(voltu SHARED
...
@@ -11,6 +11,24 @@ add_library(voltu SHARED
private/property_impl.cpp
private/property_impl.cpp
)
)
file
(
READ
"public/include/voltu/voltu.hpp"
VOLVER
)
string
(
REGEX MATCH
"VOLTU_VERSION_MAJOR ([0-9]*)"
_
${
VOLVER
}
)
set
(
VOLTU_MAJOR
${
CMAKE_MATCH_1
}
)
string
(
REGEX MATCH
"VOLTU_VERSION_MINOR ([0-9]*)"
_
${
VOLVER
}
)
set
(
VOLTU_MINOR
${
CMAKE_MATCH_1
}
)
string
(
REGEX MATCH
"VOLTU_VERSION_PATCH ([0-9]*)"
_
${
VOLVER
}
)
set
(
VOLTU_PATCH
${
CMAKE_MATCH_1
}
)
message
(
"VolTu SDK version:
${
VOLTU_MAJOR
}
.
${
VOLTU_MINOR
}
.
${
VOLTU_PATCH
}
"
)
set_target_properties
(
voltu PROPERTIES
VERSION
"
${
VOLTU_MAJOR
}
.
${
VOLTU_MINOR
}
"
SOVERSION
"
${
VOLTU_MAJOR
}
.
${
VOLTU_MINOR
}
"
)
target_include_directories
(
voltu
target_include_directories
(
voltu
PUBLIC public/include
PUBLIC public/include
PRIVATE src
)
PRIVATE src
)
...
...
This diff is collapsed.
Click to expand it.
SDK/CPP/public/voltu.cpp
+
34
−
1
View file @
552861d3
...
@@ -10,10 +10,16 @@
...
@@ -10,10 +10,16 @@
#if defined(WIN32)
#if defined(WIN32)
#include
<windows.h>
#include
<windows.h>
#pragma comment(lib, "User32.lib")
#else
#else
#include
<dlfcn.h>
#include
<dlfcn.h>
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<unistd.h>
#endif
#endif
#include
<iostream>
static
bool
g_init
=
false
;
static
bool
g_init
=
false
;
typedef
void
*
Library
;
typedef
void
*
Library
;
...
@@ -48,13 +54,39 @@ static void unloadLibrary(Library lib)
...
@@ -48,13 +54,39 @@ static void unloadLibrary(Library lib)
#endif
#endif
}
}
static
bool
is_file
(
const
std
::
string
&
path
)
{
#ifdef WIN32
WIN32_FIND_DATA
ffd
;
HANDLE
hFind
=
FindFirstFile
(
path
.
c_str
(),
&
ffd
);
if
(
hFind
==
INVALID_HANDLE_VALUE
)
return
false
;
FindClose
(
hFind
);
return
true
;
#else
struct
stat
s
;
if
(
::
stat
(
path
.
c_str
(),
&
s
)
==
0
)
{
return
true
;
}
else
{
return
false
;
}
#endif
}
static
std
::
string
locateLibrary
()
static
std
::
string
locateLibrary
()
{
{
// TODO: Use full paths and find correct versions
// TODO: Use full paths and find correct versions
#if defined(WIN32)
#if defined(WIN32)
return
"voltu.dll"
;
return
"voltu.dll"
;
#else
#else
return
"libvoltu.so"
;
std
::
string
name
=
"libvoltu.so"
;
std
::
string
vname
=
name
+
std
::
string
(
"."
)
+
std
::
to_string
(
VOLTU_VERSION_MAJOR
)
+
std
::
string
(
"."
)
+
std
::
to_string
(
VOLTU_VERSION_MINOR
);
if
(
is_file
(
std
::
string
(
"./"
)
+
vname
))
return
std
::
string
(
"./"
)
+
vname
;
else
if
(
is_file
(
std
::
string
(
"./"
)
+
name
))
return
std
::
string
(
"./"
)
+
name
;
else
if
(
is_file
(
std
::
string
(
"../"
)
+
vname
))
return
std
::
string
(
"../"
)
+
vname
;
else
if
(
is_file
(
std
::
string
(
"../"
)
+
name
))
return
std
::
string
(
"../"
)
+
name
;
else
if
(
is_file
(
std
::
string
(
"/usr/local/lib/"
)
+
vname
))
return
std
::
string
(
"/usr/local/lib/"
)
+
vname
;
else
if
(
is_file
(
std
::
string
(
"/usr/local/lib/"
)
+
name
))
return
std
::
string
(
"/usr/local/lib/"
)
+
name
;
return
name
;
#endif
#endif
}
}
...
@@ -63,6 +95,7 @@ std::shared_ptr<voltu::System> voltu::instance()
...
@@ -63,6 +95,7 @@ std::shared_ptr<voltu::System> voltu::instance()
if
(
g_init
)
return
nullptr
;
if
(
g_init
)
return
nullptr
;
std
::
string
name
=
locateLibrary
();
std
::
string
name
=
locateLibrary
();
std
::
cout
<<
"Loading VolTu Runtime: "
<<
name
<<
std
::
endl
;
Library
handle
=
loadLibrary
(
name
.
c_str
());
Library
handle
=
loadLibrary
(
name
.
c_str
());
if
(
handle
)
if
(
handle
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment