Skip to content
Snippets Groups Projects
Commit 6b710b96 authored by Simon McVittie's avatar Simon McVittie
Browse files

init-project: Generate a separate shim per library


This makes examples/shim/ and tests/gl-shim.pl match what
Vivek outlined in doc/Quick-Start.txt, except that the proxies are
all one big Autotools project.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 263ad9cc
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
Showing
with 1608 additions and 2982 deletions
......@@ -158,6 +158,34 @@ nobase_dist_insttests_DATA += examples/shim/libGL.so.1.excluded \
examples/shim/libGL.so.1.shared \
examples/shim/libGL.so.1.symbols \
examples/shim/libGL.so.1.symbols.updated-for \
examples/shim/libX11.so.6.excluded \
examples/shim/libX11.so.6.shared \
examples/shim/libX11.so.6.symbols \
examples/shim/libX11.so.6.symbols.updated-for \
examples/shim/libXext.so.6.excluded \
examples/shim/libXext.so.6.shared \
examples/shim/libXext.so.6.symbols \
examples/shim/libXext.so.6.symbols.updated-for \
examples/shim/libxcb-dri2.so.0.excluded \
examples/shim/libxcb-dri2.so.0.shared \
examples/shim/libxcb-dri2.so.0.symbols \
examples/shim/libxcb-dri2.so.0.symbols.updated-for \
examples/shim/libxcb-glx.so.0.excluded \
examples/shim/libxcb-glx.so.0.shared \
examples/shim/libxcb-glx.so.0.symbols \
examples/shim/libxcb-glx.so.0.symbols.updated-for \
examples/shim/libxcb-present.so.0.excluded \
examples/shim/libxcb-present.so.0.shared \
examples/shim/libxcb-present.so.0.symbols \
examples/shim/libxcb-present.so.0.symbols.updated-for \
examples/shim/libxcb-sync.so.1.excluded \
examples/shim/libxcb-sync.so.1.shared \
examples/shim/libxcb-sync.so.1.symbols \
examples/shim/libxcb-sync.so.1.symbols.updated-for \
examples/shim/libxcb.so.1.excluded \
examples/shim/libxcb.so.1.shared \
examples/shim/libxcb.so.1.symbols \
examples/shim/libxcb.so.1.symbols.updated-for \
tests/notgl.h \
tests/notgl-green.c \
tests/notgl-red.c \
......
......@@ -9,7 +9,7 @@ me=$(basename $0);
usage ()
{
cat << EOF
Usage: $me [OPTIONS] TARGET [TREE [PROJECT-NAME]]
Usage: $me [OPTIONS] TARGET...
Options:
--capsule-pkgdatadir=PATH
Use supporting files from PATH
......@@ -22,31 +22,35 @@ Usage: $me [OPTIONS] TARGET [TREE [PROJECT-NAME]]
[default: ${CAPSULE_VERSION_TOOL:-ask pkg-config}]
--search-tree=PATH Find libraries to be proxied in this
chroot, sysroot or container now
[default: TREE or /]
[default: /]
--set-version=VERSION Use this as the library's version number
(major, major.minor or major.minor.micro)
instead of running capsule-version
--symbols-from=PATH Use symbols from this file instead of
running capsule-symbols(1)
[default: based on first TARGET]
--symbols-from-dir=PATH Use symbols from files in this directory
instead of running capsule-symbols(1)
--runtime-tree=PATH Generated code will find proxied
libraries in this chroot, sysroot or
container at runtime if CAPSULE_PREFIX
is unset [default: TREE or /host]
Positional parameters:
TARGET SONAME of the library to be proxied
TREE Default for both --search-tree and
--runtime-tree [default: /host]
PROJECT-NAME Project to create [default: libfoo-proxy]
is unset [default: /host]
--package-name=PACKAGE Use this name for the generated package
[default: based on name of first TARGET]
--destination=PATH Create the project here
[default: ./PACKAGE]
TARGET... SONAMEs of the libraries to be proxied
(libfoo.so.2), or libfoo.so.2/2.1.3
to force a version
EOF
exit "${1:-0}"
}
getopt_temp="$(getopt -o 'h' \
-l 'autoreconf,no-autoreconf,capsule-pkgdatadir,capsule-symbols-tool,capsule-version-tool,search-tree:,set-version:,symbols-from:,runtime-tree:,help' \
-l 'autoreconf,no-autoreconf,capsule-pkgdatadir,capsule-symbols-tool,capsule-version-tool,destination:,package-name:,search-tree:,set-version:,symbols-from-dir:,runtime-tree:,help' \
-n "$me" -- "$@")"
eval set -- "$getopt_temp"
autoreconf=yes
dest=
package_name=
runtime_tree=
search_tree=
symbols_from=
......@@ -85,6 +89,18 @@ do
continue;
;;
(--destination)
dest="$2"
shift 2;
continue;
;;
(--package-name)
package_name="$2"
shift 2;
continue;
;;
(--runtime-tree)
runtime_tree="$2"
shift 2;
......@@ -103,7 +119,7 @@ do
continue;
;;
(--symbols-from)
(--symbols-from-dir)
symbols_from="$2"
shift 2;
continue;
......@@ -120,80 +136,68 @@ do
esac
done
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ];
if [ "$#" -lt 1 ];
then
usage 2 >&2;
fi;
target=$1;
tree=${2:-/host};
first_target_maybe_ver="$1";
first_target="${first_target_maybe_ver%%/*}";
base=${target%%.so.*};
base=${base%.so};
name=${base#lib};
lcbase=${base,,};
amname=${name//-/_};
if [ -z "$package_name" ];
then
package_name="${first_target%%.so.*}";
package_name="${package_name%%.so}-proxy";
fi;
if [ -z "$dest" ];
then
dest="$package_name";
fi;
dest=${3:-$base-proxy};
maj=0;
if [ -z "$ver" ];
then
if [ "x$first_target" != "x$first_target_maybe_ver" ];
then
ver="${first_target_maybe_ver#*/}";
else
read x x ver x < <("$CAPSULE_VERSION_TOOL" "$first_target" "$search_tree");
fi;
fi;
: "${PKG_CONFIG:=pkg-config}"
: "${CAPSULE_MKINC:="$($PKG_CONFIG --variable=makeinc capsule)"}"
: "${CAPSULE_SYMBOLS_TOOL:="$($PKG_CONFIG --variable=CAPSULE_SYMBOLS_TOOL capsule)"}"
: "${CAPSULE_VERSION_TOOL:="$($PKG_CONFIG --variable=CAPSULE_VERSION_TOOL capsule)"}"
: "${runtime_tree:="$tree"}"
: "${search_tree:="$tree"}"
if [ -z "$ver" ]; then
read x x ver x < <("$CAPSULE_VERSION_TOOL" "$target" "$search_tree");
fi
: "${runtime_tree:="/host"}"
: "${search_tree:="/"}"
maj=${ver%%.*};
echo "Generating project for $package_name, shims for $runtime_tree libraries: $*";
echo Generating project for $runtime_tree : $target $ver proxy;
echo Creating project directory $dest;
echo "Creating project directory $dest";
mkdir -p "$dest";
cd $dest;
mkdir -p shim;
echo Working in $PWD;
echo "Working in $PWD";
escaped_target="$(echo "$target" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
automake_target="${escaped_target//-/_}"
escaped_lib="$(echo "$name" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
automake_lib="$(echo "$amname" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
escaped_target="$(echo "$first_target" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
escaped_search_tree="$(echo "$search_tree" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
escaped_runtime_tree="$(echo "$runtime_tree" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
sed \
-e "1,/^\$/d" \
-e "s,@TARGET@,$escaped_target," \
-e "s,@LIB@,$escaped_lib," \
< "$CAPSULE_MKINC/shim-README.in" \
> README;
if [ -z "$symbols_from" ]; then
echo Extracting dynamic symbols from $search_tree : $target;
"$CAPSULE_SYMBOLS_TOOL" "$target" "$search_tree" > "shim/$target.symbols.tmp";
LC_ALL=C sort -u "shim/$target.symbols.tmp" > "shim/$target.symbols";
rm -f "shim/$target.symbols.tmp";
else
LC_ALL=C sort -u "$symbols_from" > "shim/$target.symbols";
fi
touch "shim/$target.symbols.updated-for";
echo Preparing proxy source files
touch shim/$target.{shared,excluded};
echo Initialising configure.ac;
sed \
-e "1,/^\$/d" \
-e "s,@RUNTIME_TREE@,$escaped_runtime_tree," \
-e "s,@SEARCH_TREE@,$escaped_search_tree," \
-e "s,@PACKAGE@,${lcbase}-proxy," \
-e "s,@PACKAGE@,$package_name," \
-e "s,@VER@,$ver," \
< "$CAPSULE_MKINC/shim-configure.ac.in" \
> configure.ac;
......@@ -204,23 +208,60 @@ sed \
-e "1,/^\$/d" \
-e "s,@RUNTIME_TREE@,$escaped_runtime_tree," \
-e "s,@SEARCH_TREE@,$escaped_search_tree," \
-e "s,@PACKAGE@,${lcbase}-proxy," \
-e "s,@PACKAGE@,$package_name," \
-e "s,@VER@,$ver," \
< "$CAPSULE_MKINC/shim-Makefile.am" \
> Makefile.am;
sed \
-e "1,/^\$/d" \
-e "s,@TARGET@,$escaped_target," \
-e "s,@AMTARGET@,$automake_target," \
-e "s,@LIB@,$escaped_lib," \
-e "s,@AMLIB@,$automake_lib," \
-e "s,@RUNTIME_TREE@,$escaped_runtime_tree," \
-e "s,@SEARCH_TREE@,$escaped_search_tree," \
-e "s,@PACKAGE@,${lcbase}-proxy," \
-e "s,@VER@,$ver," \
< "$CAPSULE_MKINC/shim-target-Makefile.am" \
>> Makefile.am;
for target_maybe_ver in "$@"; do
target="${target_maybe_ver%%/*}";
if [ "x$target" != "x$target_maybe_ver" ];
then
target_ver="${target_maybe_ver#*/}";
else
read x x target_ver x < <("$CAPSULE_VERSION_TOOL" "$target" "$search_tree");
fi;
base=${target%%.so.*};
base=${base%.so};
name=${base#lib};
lcbase=${base,,};
amname=${name//-/_};
escaped_target="$(echo "$target" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
automake_target="${escaped_target//-/_}"
escaped_lib="$(echo "$name" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
automake_lib="$(echo "$amname" | sed -e 's/\\/\\\\/g' -e 's/,/\\,/g')"
maj=${ver%%.*};
echo "Preparing proxy source files: $target"
touch shim/$target.{shared,excluded};
if [ -z "$symbols_from" ]; then
echo Extracting dynamic symbols from $search_tree : $target;
"$CAPSULE_SYMBOLS_TOOL" "$target" "$search_tree" > "shim/$target.symbols.tmp";
LC_ALL=C sort -u "shim/$target.symbols.tmp" > "shim/$target.symbols";
rm -f "shim/$target.symbols.tmp";
else
LC_ALL=C sort -u "$symbols_from/$target.symbols" > "shim/$target.symbols";
fi
touch "shim/$target.symbols.updated-for";
sed \
-e "1,/^\$/d" \
-e "s,@TARGET@,$escaped_target," \
-e "s,@AMTARGET@,$automake_target," \
-e "s,@LIB@,$escaped_lib," \
-e "s,@AMLIB@,$automake_lib," \
-e "s,@RUNTIME_TREE@,$escaped_runtime_tree," \
-e "s,@SEARCH_TREE@,$escaped_search_tree," \
-e "s,@PACKAGE@,$package_name," \
-e "s,@TARGET_VER@,$target_ver," \
< "$CAPSULE_MKINC/shim-target-Makefile.am" \
>> Makefile.am;
done
cp "$CAPSULE_MKINC/shim-.gitignore" .gitignore
......@@ -238,8 +279,15 @@ control system:
Makefile.am
README
configure.ac
EOF
for target_maybe_ver in "$@"; do
target="${target_maybe_ver%%/*}";
cat - <<EOF
shim/$target.excluded
shim/$target.shared
shim/$target.symbols
shim/$target.symbols.updated-for
EOF
done
......@@ -10,12 +10,12 @@ program using it.
You can export the symbols of more than one library via the proxy:
To do so, add a line containing the SONAME (libFOO.so.X)
of each extra library to shim/lib@LIB@.so.c.shared and rebuild.
of each extra library to shim/@TARGET@.c.shared and rebuild.
You can also prevent a library from the foreign tree from being loaded
at all (at least as a result of being a dependency of @TARGET@).
To achieve this, add a line containing the SONAME (libFOO.so.X)
of the excluded library to shim/lib@LIB@.so.c.excluded and rebuild.
of the excluded library to shim/@TARGET@.c.excluded and rebuild.
The generated library will have the same name as the main proxy target
(@TARGET@). You can control the exact version number (cf libfoo.x.y.z)
......
......@@ -7,7 +7,7 @@
# -------- @TARGET@ --------
CAPSULE_SONAMES += @TARGET@
CAPSULE_VERSION_@AMTARGET@ := @VER@
CAPSULE_VERSION_@AMTARGET@ := @TARGET_VER@
lib_LTLIBRARIES += lib@LIB@.la
nodist_lib@AMLIB@_la_SOURCES = shim/@TARGET@.c
......
......@@ -51,11 +51,7 @@ License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
<cmdsynopsis>
<command>capsule-init-project</command>
<arg choice="opt">OPTIONS</arg>
<arg choice="plain">TARGET</arg>
<arg choice="opt">
FOREIGN-TREE
<arg choice="opt">PROJECT-DIR</arg>
</arg>
<arg choice="req" rep="repeat">TARGET</arg>
</cmdsynopsis>
</refsynopsisdiv>
......@@ -76,35 +72,13 @@ License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
<term><option>TARGET</option></term>
<listitem>
<para>
The base name of the target, of the form libFOO.so.X (eg libz.so.1)
The base name of the target, of the form libFOO.so.X (eg libz.so.1).
It can optionally be combined with a version number in the
form libFOO.so.X/VERSION (e.g. libz.so.1/1.2.3).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>FOREIGN-TREE</option></term>
<listitem>
<para>
Mount point of the filesystem tree which contains the target.
</para>
<para>
For example a container could mount a different root filesystem
at /host in order to make its libraries available.
</para>
<para>
FOREIGN-TREE defaults to /host if unset or empty.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>PROJECT-DIR</option></term>
<listitem>
<para>The directory in which the new project will be created.</para>
<para>Defaults to ./libFOO-proxy (if TARGET is libFOO.so.X)</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
......@@ -140,7 +114,7 @@ License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
Find libraries to be proxied in this chroot,
sysroot or container at compile-time.
</para>
<para>default: TREE or / if unset</para>
<para>default: TREE or /host if unset</para>
</listitem>
</varlistentry>
......@@ -148,18 +122,20 @@ License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
<term><option>--set-version=VERSION</option></term>
<listitem>
<para>
Use this as the library version
Use this as the package version
(major, major.minor or major.minor.micro)
instead of using capsule-version(1)
instead of using capsule-version(1) on the first
<option>TARGET</option>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--symbols-from=PATH</option></term>
<term><option>--symbols-from-dir=PATH</option></term>
<listitem>
<para>
Use this symbols file instead of the output of capsule-symbols(1)
Use symbols files in this directory instead of the
output of capsule-symbols(1)
</para>
</listitem>
</varlistentry>
......@@ -176,6 +152,27 @@ License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
</listitem>
</varlistentry>
<varlistentry>
<term><option>--package-name=PACKAGE</option></term>
<listitem>
<para>
Use this name for the generated Autotools package,
instead of libFOO-proxy
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--destination=PATH</option></term>
<listitem>
<para>
Use this name for the generated directory,
instead of libFOO-proxy or the argument of
<option>--package-name</option>
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
......
libX11-xcb.so.1
libX11.so.6
libXau.so.6
libXdamage.so.1
libXdmcp.so.6
libXext.so.6
libXfixes.so.3
libXxf86vm.so.1
libxcb-dri2.so.0
libxcb-dri3.so.0
libxcb-glx.so.0
libxcb-present.so.0
libxcb-sync.so.1
libxcb-xfixes.so.0
libxcb.so.1
This diff is collapsed.
libX11-xcb.so.1
libX11.so.6
libXau.so.6
libXdamage.so.1
libXdmcp.so.6
libXext.so.6
libXfixes.so.3
libXxf86vm.so.1
libxcb-dri2.so.0
libxcb-dri3.so.0
libxcb-glx.so.0
libxcb-present.so.0
libxcb-sync.so.1
libxcb-xfixes.so.0
libxcb.so.1
This diff is collapsed.
DPMSCapable
DPMSDisable
DPMSEnable
DPMSForceLevel
DPMSGetTimeouts
DPMSGetVersion
DPMSInfo
DPMSQueryExtension
DPMSSetTimeouts
XGEQueryExtension
XGEQueryVersion
XLbxGetEventBase
XLbxQueryExtension
XLbxQueryVersion
XMITMiscGetBugMode
XMITMiscQueryExtension
XMITMiscSetBugMode
XMissingExtension
XSecurityAllocXauth
XSecurityFreeXauth
XSecurityGenerateAuthorization
XSecurityQueryExtension
XSecurityRevokeAuthorization
XSetExtensionErrorHandler
XShapeCombineMask
XShapeCombineRectangles
XShapeCombineRegion
XShapeCombineShape
XShapeGetRectangles
XShapeInputSelected
XShapeOffsetShape
XShapeQueryExtension
XShapeQueryExtents
XShapeQueryVersion
XShapeSelectInput
XShmAttach
XShmCreateImage
XShmCreatePixmap
XShmDetach
XShmGetEventBase
XShmGetImage
XShmPixmapFormat
XShmPutImage
XShmQueryExtension
XShmQueryVersion
XSyncAwait
XSyncAwaitFence
XSyncChangeAlarm
XSyncChangeCounter
XSyncCreateAlarm
XSyncCreateCounter
XSyncCreateFence
XSyncDestroyAlarm
XSyncDestroyCounter
XSyncDestroyFence
XSyncFreeSystemCounterList
XSyncGetPriority
XSyncInitialize
XSyncIntToValue
XSyncIntsToValue
XSyncListSystemCounters
XSyncMaxValue
XSyncMinValue
XSyncQueryAlarm
XSyncQueryCounter
XSyncQueryExtension
XSyncQueryFence
XSyncResetFence
XSyncSetCounter
XSyncSetPriority
XSyncTriggerFence
XSyncValueAdd
XSyncValueEqual
XSyncValueGreaterOrEqual
XSyncValueGreaterThan
XSyncValueHigh32
XSyncValueIsNegative
XSyncValueIsPositive
XSyncValueIsZero
XSyncValueLessOrEqual
XSyncValueLessThan
XSyncValueLow32
XSyncValueSubtract
XTestFakeAckType
XTestFakeInput
XTestFlush
XTestGetInput
XTestInputActionType
XTestMovePointer
XTestPressButton
XTestPressKey
XTestQueryInputSize
XTestReset
XTestStopInput
XagCreateAssociation
XagCreateEmbeddedApplicationGroup
XagCreateNonembeddedApplicationGroup
XagDestroyApplicationGroup
XagDestroyAssociation
XagGetApplicationGroupAttributes
XagQueryApplicationGroup
XagQueryVersion
XcupGetReservedColormapEntries
XcupQueryVersion
XcupStoreColors
XdbeAllocateBackBufferName
XdbeBeginIdiom
XdbeDeallocateBackBufferName
XdbeEndIdiom
XdbeFreeVisualInfo
XdbeGetBackBufferAttributes
XdbeGetVisualInfo
XdbeQueryExtension
XdbeSwapBuffers
XeviGetVisualInfo
XeviQueryExtension
XeviQueryVersion
XextAddDisplay
XextCreateExtension
XextDestroyExtension
XextFindDisplay
XextRemoveDisplay
XmbufChangeBufferAttributes
XmbufChangeWindowAttributes
XmbufClearBufferArea
XmbufCreateBuffers
XmbufCreateStereoWindow
XmbufDestroyBuffers
XmbufDisplayBuffers
XmbufGetBufferAttributes
XmbufGetScreenInfo
XmbufGetVersion
XmbufGetWindowAttributes
XmbufQueryExtension
_XExtensionErrorFunction
xcb_dri2_attach_format_end
xcb_dri2_attach_format_next
xcb_dri2_authenticate
xcb_dri2_authenticate_reply
xcb_dri2_authenticate_unchecked
xcb_dri2_connect
xcb_dri2_connect_alignment_pad
xcb_dri2_connect_alignment_pad_end
xcb_dri2_connect_alignment_pad_length
xcb_dri2_connect_device_name
xcb_dri2_connect_device_name_end
xcb_dri2_connect_device_name_length
xcb_dri2_connect_driver_name
xcb_dri2_connect_driver_name_end
xcb_dri2_connect_driver_name_length
xcb_dri2_connect_reply
xcb_dri2_connect_sizeof
xcb_dri2_connect_unchecked
xcb_dri2_copy_region
xcb_dri2_copy_region_reply
xcb_dri2_copy_region_unchecked
xcb_dri2_create_drawable
xcb_dri2_create_drawable_checked
xcb_dri2_destroy_drawable
xcb_dri2_destroy_drawable_checked
xcb_dri2_dri2_buffer_end
xcb_dri2_dri2_buffer_next
xcb_dri2_get_buffers
xcb_dri2_get_buffers_buffers
xcb_dri2_get_buffers_buffers_iterator
xcb_dri2_get_buffers_buffers_length
xcb_dri2_get_buffers_reply
xcb_dri2_get_buffers_sizeof
xcb_dri2_get_buffers_unchecked
xcb_dri2_get_buffers_with_format
xcb_dri2_get_buffers_with_format_buffers
xcb_dri2_get_buffers_with_format_buffers_iterator
xcb_dri2_get_buffers_with_format_buffers_length
xcb_dri2_get_buffers_with_format_reply
xcb_dri2_get_buffers_with_format_sizeof
xcb_dri2_get_buffers_with_format_unchecked
xcb_dri2_get_msc
xcb_dri2_get_msc_reply
xcb_dri2_get_msc_unchecked
xcb_dri2_get_param
xcb_dri2_get_param_reply
xcb_dri2_get_param_unchecked
xcb_dri2_id
xcb_dri2_query_version
xcb_dri2_query_version_reply
xcb_dri2_query_version_unchecked
xcb_dri2_swap_buffers
xcb_dri2_swap_buffers_reply
xcb_dri2_swap_buffers_unchecked
xcb_dri2_swap_interval
xcb_dri2_swap_interval_checked
xcb_dri2_wait_msc
xcb_dri2_wait_msc_reply
xcb_dri2_wait_msc_unchecked
xcb_dri2_wait_sbc
xcb_dri2_wait_sbc_reply
xcb_dri2_wait_sbc_unchecked
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