Skip to content
Snippets Groups Projects
Commit b617bec4 authored by David Hendriks's avatar David Hendriks
Browse files

shared Library generation works now

parent 50bbcde1
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment