Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python-c-interface
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hendriks, David D Dr (PG/R - Maths & Physics)
python-c-interface
Commits
b617bec4
Commit
b617bec4
authored
5 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
shared Library generation works now
parent
50bbcde1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
binaryc/custom_logging.c
+2
-4
2 additions, 4 deletions
binaryc/custom_logging.c
binaryc/functions.py
+14
-8
14 additions, 8 deletions
binaryc/functions.py
binaryc/lib_custom_logging.so
+0
-0
0 additions, 0 deletions
binaryc/lib_custom_logging.so
with
16 additions
and
12 deletions
binaryc/custom_logging.c
+
2
−
4
View file @
b617bec4
...
...
@@ -8,10 +8,8 @@ void custom_output_function(struct stardata_t * stardata);
void
custom_output_function
(
struct
stardata_t
*
stardata
)
{
// struct stardata_t * stardata = (struct stardata_t *)x;
PRINTF
(
"MY_STELLAR_DATA %g %g
"
,((
double
)
stardata
->
model
.
time
),((
double
)
stardata
->
star
[
0
].
mass
));
PRINTF
(
"my_sss2 %g %g
"
,((
double
)
stardata
->
model
.
time
),((
double
)
stardata
->
star
[
1
].
mass
));;
PRINTF
(
"MY_STELLAR_DATA %g %g
\n
"
,((
double
)
stardata
->
model
.
time
),((
double
)
stardata
->
star
[
0
].
mass
));
PRINTF
(
"my_sss2 %g %g
\n
"
,((
double
)
stardata
->
model
.
time
),((
double
)
stardata
->
star
[
1
].
mass
));;
}
#undef MAX
...
...
This diff is collapsed.
Click to expand it.
binaryc/functions.py
+
14
−
8
View file @
b617bec4
...
...
@@ -39,7 +39,7 @@ def autogen_C_logging_code(logging_dict):
code
+=
'
PRINTF(
"
{}
'
.
format
(
key
)
code
+=
'
{}
'
.
format
(
'
%g
'
*
len
(
logging_dict_entry
))
code
=
code
.
strip
()
code
+=
'
\n
"'
code
+=
'
\
\
n
"'
# Add format keys
for
param
in
logging_dict_entry
:
...
...
@@ -118,7 +118,9 @@ def return_compilation_dict():
inspired by binary_c_inline_config command in perl
TODO: this function still has some cleaning up to do wrt default values for the compile command
# https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
returns:
- string containing the command to build the shared library
"""
...
...
@@ -171,7 +173,7 @@ def return_compilation_dict():
ccflags
=
defaults
[
'
ccflags
'
]
# = $ENV{BINARY_GRID2_CCFLAGS} // ($defaults{ccflags}) . ($ENV{BINARY_GRID2_EXTRACCFLAGS} // '');
# you must define _SEARCH_H to prevent it being loaded twice
ccflags
+=
'
-D_SEARCH_H
'
ccflags
+=
'
-shared
-D_SEARCH_H
'
# ensure library paths to the front of the libs:
libs_content
=
libs
.
split
(
'
'
)
...
...
@@ -204,6 +206,7 @@ def compile_shared_lib(code, sourcefile_name, outfile_name):
# create compilation command
compilation_dict
=
return_compilation_dict
()
# Construct full command
command
=
"
{cc} {ccflags} {libs} -o {outfile_name} {sourcefile_name} {inc}
"
.
format
(
cc
=
compilation_dict
[
'
cc
'
],
ccflags
=
compilation_dict
[
'
ccflags
'
],
...
...
@@ -216,13 +219,12 @@ def compile_shared_lib(code, sourcefile_name, outfile_name):
command
=
'
'
.
join
(
command
.
split
())
# Execute compilation
print
(
'
Executing following command:
\n
{command}
'
.
format
(
command
=
command
))
res
=
subprocess
.
check_output
(
'
{command}
'
.
format
(
command
=
command
),
shell
=
True
,
stderr
=
subprocess
.
STDOUT
)
print
(
res
)
shell
=
True
)
# return command
if
res
:
print
(
'
Output of compilation command:
\n
{}
'
.
format
(
res
))
# generate logging lines
logging_line
=
autogen_C_logging_code
(
...
...
@@ -235,4 +237,8 @@ logging_line = autogen_C_logging_code(
# Generate code around logging lines
created_code
=
binary_c_log_code
(
logging_line
)
# print(created_code)
# quit()
compile_shared_lib
(
created_code
,
sourcefile_name
=
'
custom_logging.c
'
,
outfile_name
=
'
lib_custom_logging.so
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
binaryc/lib_custom_logging.so
0 → 100755
+
0
−
0
View file @
b617bec4
File added
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