Skip to content
Snippets Groups Projects
Commit 6543ddee authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

add help_all function in API

update meson.build to try to fix for MacOSX
parent 6d57fb0d
No related branches found
No related tags found
No related merge requests found
############################################################ ###########################################################
# meson build file for binary_c # meson build file for binary_c
# #
# (c) Robert Izzard 07/12/2019 # (c) Robert Izzard 07/12/2019
...@@ -46,6 +46,13 @@ project( ...@@ -46,6 +46,13 @@ project(
version : '2.1.6', # should agree with binary_c_version.h version : '2.1.6', # should agree with binary_c_version.h
) )
############################################################
# variables for later
#
binary_c_subdir_objects = []
binary_c_subdir_deps = []
dependencies = [ ]
############################################################ ############################################################
# require Meson 0.52.0 or later # require Meson 0.52.0 or later
# #
...@@ -409,10 +416,6 @@ if svn_url != '' ...@@ -409,10 +416,6 @@ if svn_url != ''
cflags += _flag cflags += _flag
endif endif
############################################################
# dependencies are put in the list called dependencies
#
dependencies = [ ]
############################################################ ############################################################
# dependencies that usually have no pkg-config # dependencies that usually have no pkg-config
...@@ -668,30 +671,7 @@ endif ...@@ -668,30 +671,7 @@ endif
# #
run_command('meson/make_version_macros.pl') run_command('meson/make_version_macros.pl')
############################################################
# data objects
#
# list and build them
if os != 'darwin'
message('Checking and building data objects')
data_objects_compilation = run_command('meson/data_object_list_and_build.sh')
if data_objects_compilation.returncode() != 0
error('There was a problem building the data objects. Please check that you have objcopy installed, and try running meson/data_object_list_and_build.sh from the binary_c root directory manually to check for errors')
endif
data_objects = data_objects_compilation.stdout().strip().split(' ')
if get_option('clean_data_objects') == true
run_command('meson/clean_data_objects.sh')
endif
else
data_objects = []
endif
############################################################
# data objects V2
#
############################################################ ############################################################
...@@ -870,6 +850,67 @@ else ...@@ -870,6 +850,67 @@ else
endif endif
############################################################
# data objects
#
# list and build them
#if os != 'darwin'
if 1 == 1
message('Checking and building data objects')
data_objects_compilation = run_command('meson/data_object_list_and_build.sh')
if data_objects_compilation.returncode() != 0
error('There was a problem building the data objects. Please check that you have objcopy installed, and try running meson/data_object_list_and_build.sh from the binary_c root directory manually to check for errors')
endif
data_objects = data_objects_compilation.stdout().strip().split(' ')
if get_option('clean_data_objects') == true
run_command('meson/clean_data_objects.sh')
endif
else
data_object_sourcefiles = run_command('meson/data_object_list_files.sh')
if data_object_sourcefiles.returncode() != 0
error('There was a problem identifying the data object source file.')
endif
# get data objects source (.h) files
data_objects_source = run_command('meson/data_object_list_files.sh').stdout().strip().split(' ')
# list data objects (.o) files
data_objects_files = run_command('meson/make_data_object.sh',
'dummy',
data_objects_source).stdout().strip().split(' ')
# build data objects
data_objects = custom_target(
'binary_c_data_objects',
input: [
data_objects_source,
],
command: [
'meson/make_data_object.sh',
'build',
'@INPUT@',
],
output: [
],
)
binary_c_subdir_deps += declare_dependency(
sources: data_objects
)
data_objects = []
endif
############################################################ ############################################################
# command to install binary_c in its 'legacy' locations # command to install binary_c in its 'legacy' locations
# (required for binary_grid2) # (required for binary_grid2)
...@@ -952,8 +993,6 @@ endif ...@@ -952,8 +993,6 @@ endif
# many .o files and this makes the command line too long # many .o files and this makes the command line too long
# (even in Linux) which means the linking fails. # (even in Linux) which means the linking fails.
# #
binary_c_subdir_objects = []
binary_c_subdir_deps = []
src_subdirs = run_command('meson/source_directories.sh').stdout().strip().split('\n') src_subdirs = run_command('meson/source_directories.sh').stdout().strip().split('\n')
src_root_sourcefiles = run_command('meson/source_files.sh','./src').stdout().strip().split('\n') src_root_sourcefiles = run_command('meson/source_files.sh','./src').stdout().strip().split('\n')
......
#!/bin/bash
# list of source files associated with data objects
meson/data_object_list.sh | sed 's/.o\ /.h\ /g' | sed 's/.o$/.h/'
#!/bin/bash
#!/bin/bash
# make generic data objects for binary_c
# http://gareus.org/wiki/embedding_resources_in_executables
: "${CC:="gcc"}"
: "${OBJCOPY_ARCH:=$(objdump -f /bin/bash |grep architecture | gawk "{print \$2}" | sed s/,//)}"
: "${OBJCOPY_TARGET:=$(objdump -f /bin/bash | grep format | gawk "{print \$4}")}"
: "${OBJCOPY_OPTS:="-I binary -B $OBJCOPY_ARCH -O $OBJCOPY_TARGET"}"
#: "${OBJCOPY_SUBOPTS:="--rename-section .data=.rodata,alloc,load,readonly,data,contents "}"
OBJCOPY_SUBOPTS=""
DBUILT="false"
COMMAND=$1
shift
for HFILE in "$@"; do
TMPFILE=$(printf "%s" "$HFILE" | sed s/\.h$/.tmp/)
OBJFILE=$(printf "%s/%s" "${MESON_BUILD_ROOT}" "$HFILE" | sed s/\.h$/.o/ | sed s/\\//_/g)
#echo "H $HFILE"
#echo "T $TMPFILE"
#echo "O $OBJFILE"
if [ "$COMMAND" = "build" ] ; then
if [ "$HFILE" -nt "$OBJFILE" ] ; then
if [ "$DBUILT" = true ]; then
# first time, build double2bin
$CC double2bin.c -o ./double2bin
fi
tr , ' ' < "$HFILE" | sed s/\\\\// | grep -v define |grep -v "\\*" | ./double2bin > "$TMPFILE"
objcopy $OBJCOPY_OPTS $OBJCOPY_SUBOPTS "$TMPFILE" "$OBJFILE"
rm "$TMPFILE"
DBUILT=true
fi
fi
echo -n "$OBJFILE "
#ls -l $OBJFILE
#echo
done
echo
#include "../binary_c.h"
#ifdef BINARY_C_API
void binary_c_API_function binary_c_help_all(struct stardata_t * RESTRICT const stardata)
{
/*
* API function to put help associated arguments into the
* buffer. stardata must be non-NULL for this to work,
* because the buffer must be defined.
*/
if(stardata != NULL)
{
struct tmpstore_t * tmpstore = stardata->tmpstore;
if(tmpstore == NULL)
{
build_tmpstore_contents(tmpstore);
stardata->tmpstore = tmpstore;
}
binary_c_help_all_from_arg(
tmpstore->cmd_line_args,
stardata, // required for the buffer
NULL, // dummy pointer
0, // dummy var
tmpstore->arg_count, // arg_count
NULL, // dummy pointer
-1 // must be negative
);
}
}
#endif//BINARY_C_API
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