summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:47:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:47:37 +0000
commit00e2eb4fd0266c5be01e3a527a66aaad5ab4b634 (patch)
treea6a58bd544eb0b76b9d3acc678ea88791acca045 /bin
parentInitial commit. (diff)
downloadlibixion-00e2eb4fd0266c5be01e3a527a66aaad5ab4b634.tar.xz
libixion-00e2eb4fd0266c5be01e3a527a66aaad5ab4b634.zip
Adding upstream version 0.19.0.upstream/0.19.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin')
-rw-r--r--bin/env.sh.in2
-rwxr-xr-xbin/gen-gfm-release-table.sh30
-rwxr-xr-xbin/gen-spirv-shader-arrays.py87
-rwxr-xr-xbin/run-python-test-osx.sh36
-rwxr-xr-xbin/run-python.sh51
5 files changed, 206 insertions, 0 deletions
diff --git a/bin/env.sh.in b/bin/env.sh.in
new file mode 100644
index 0000000..4b56d5f
--- /dev/null
+++ b/bin/env.sh.in
@@ -0,0 +1,2 @@
+export IXION_LIBNAME=libixion-@IXION_API_VERSION@.0
+export IXION_INSTLIBDIR=@prefix@`echo "@libdir@" | sed -e 's/{.*}//g'`
diff --git a/bin/gen-gfm-release-table.sh b/bin/gen-gfm-release-table.sh
new file mode 100755
index 0000000..f7ee681
--- /dev/null
+++ b/bin/gen-gfm-release-table.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+PROJ_PREFIX=ixion
+PKG_PREFIX=lib$PROJ_PREFIX
+
+# Pick up the version number string from configure.ac.
+VER_MAJOR=$(cat ./configure.ac | grep -E "ixion_major_version.*[0-9]" | sed -e "s/.*\[\([0-9][0-9]*\).*/\1/g")
+VER_MINOR=$(cat ./configure.ac | grep -E "ixion_minor_version.*[0-9]" | sed -e "s/.*\[\([0-9][0-9]*\).*/\1/g")
+VER_MICRO=$(cat ./configure.ac | grep -E "ixion_micro_version.*[0-9]" | sed -e "s/.*\[\([0-9][0-9]*\).*/\1/g")
+VER="$VER_MAJOR.$VER_MINOR.$VER_MICRO"
+
+PKGS=$(ls $PKG_PREFIX-$VER.tar.*)
+
+echo "## Release Notes"
+echo ""
+echo "* add item"
+echo ""
+echo "## Source packages for distribution"
+echo ""
+
+echo "| URL | sha256sum | size |"
+echo "|-----|-----------|------|"
+
+for _PKG in $PKGS; do
+ _URL="[$_PKG](https://kohei.us/files/$PROJ_PREFIX/src/$_PKG)"
+ _HASH=$(sha256sum $_PKG | sed -e "s/^\(.*\)$PKG_PREFIX.*/\1/g" | tr -d "[:space:]")
+ _SIZE=$(stat -c "%s" $_PKG)
+ echo "| $_URL | $_HASH | $_SIZE |"
+done
+
diff --git a/bin/gen-spirv-shader-arrays.py b/bin/gen-spirv-shader-arrays.py
new file mode 100755
index 0000000..33fcfc9
--- /dev/null
+++ b/bin/gen-spirv-shader-arrays.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python3
+"""Generate SPIR-V blob arrays as C++ inline file.
+
+Install shaderc from https://github.com/google/shaderc/, and run:
+
+./bin/gen-spirv-shader-arrays.py -d src/libixion/shaders -o src/libixion/vulkan_spirv_blobs.inl
+"""
+
+import argparse
+import os
+import shutil
+import sys
+import subprocess
+import tempfile
+from pathlib import Path
+
+
+def _write_cpp_byte_array(array_name, bytes, file):
+ print("// This file has been auto-generated. DO NOT EDIT THIS FILE BY HAND!", file=file)
+ print(file=file)
+ print(f"uint8_t {array_name}_spirv[] = {{", file=file)
+
+ bytes_per_line = 8
+
+ for i, b in enumerate(bytes):
+
+ if i % bytes_per_line == 0:
+ print(" ", end="", file=file)
+
+ print(f"0x{b:02X}, ", end="", file=file)
+
+ if (i + 1) % bytes_per_line == 0:
+ print(file=file)
+
+ print(file=file)
+ print("};", file=file)
+ print(file=file)
+
+
+def _scan_shader_dir(dirpath, output):
+ # Detect glslc command.
+ glslc_exec = shutil.which("glslc")
+
+ if not glslc_exec:
+ print("glslc command not found in your PATH.", file=sys.stderr)
+ sys.exit(1)
+
+ print(f"glslc command: {glslc_exec}")
+
+ temp = tempfile.NamedTemporaryFile(delete=False)
+ print(f"temp file name: {temp.name}")
+
+ for f in os.listdir(dirpath):
+ filepath = dirpath / f
+ if filepath.suffix != ".comp":
+ continue
+
+ print(f"parsing {filepath}")
+ cmd = [glslc_exec, filepath, "-o", temp.name]
+ subprocess.run(cmd)
+ spirv_file = Path(temp.name)
+ bs = spirv_file.read_bytes()
+ _write_cpp_byte_array(filepath.stem, bs, output)
+
+ os.unlink(temp.name)
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="Generate C++ inline file containing SPIR-V representations of GLSL shaders.")
+ parser.add_argument(
+ "--shader-dir", "-d", type=Path,
+ required=True,
+ help="Path to directory where glsl shader files are.")
+ parser.add_argument(
+ "--output", "-o", type=Path,
+ required=True,
+ help="Path to output C++ inline file.")
+ args = parser.parse_args()
+
+ with args.output.open(mode="w") as output:
+ _scan_shader_dir(args.shader_dir, output)
+
+
+if __name__ == "__main__":
+ main()
+
diff --git a/bin/run-python-test-osx.sh b/bin/run-python-test-osx.sh
new file mode 100755
index 0000000..d2d40b8
--- /dev/null
+++ b/bin/run-python-test-osx.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# I have to write this wrapper for OSX because ixion.so module is hardcoded to
+# find libixion-<version>.dylib to the installed location, and the only way to
+# have it use libixion-<version>.dylib in src/libixion/.libs is to physically
+# re-write the path in ixion.so.
+
+PROGDIR=$(dirname $0)
+source $PROGDIR/env.sh
+
+TESTPYTHONPATH=$PROGDIR/../src/python/.test
+PYTESTFILEDIR=$PROGDIR/../test/python
+
+# Copy ixion.so into the special test directory.
+mkdir -p $TESTPYTHONPATH
+cp $PROGDIR/../src/python/.libs/ixion.so $TESTPYTHONPATH/
+
+echo "library installation directory: $IXION_INSTLIBDIR"
+echo "library base name: $IXION_LIBNAME"
+
+# Re-write the path to libixion.dylib in ixion.so.
+install_name_tool -change \
+ $IXION_INSTLIBDIR/$IXION_LIBNAME.dylib \
+ $PROGDIR/../src/libixion/.libs/$IXION_LIBNAME.dylib \
+ $TESTPYTHONPATH/ixion.so
+
+# Use that ixion.so module to run the tests.
+export PYTHONPATH=$TESTPYTHONPATH
+
+TESTS=$(ls $PYTESTFILEDIR/*.py)
+
+for _file in $TESTS; do
+ echo running $_file...
+ $_file
+done
+
diff --git a/bin/run-python.sh b/bin/run-python.sh
new file mode 100755
index 0000000..ae8a53e
--- /dev/null
+++ b/bin/run-python.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+PYTHON=$(which python3)
+PROGDIR=`dirname $0`
+_PYTHONPATH="$PROGDIR/../src/python/.libs:$PROGDIR/../src/python"
+
+export PYTHONPATH=$_PYTHONPATH
+export LD_LIBRARY_PATH="$PROGDIR/../src/libixion/.libs"
+export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
+
+if [ "$1" == "" ]; then
+ # No input file. Just invoke the interpreter.
+ $PYTHON
+ exit 0
+fi
+
+RUNMODE=
+
+if [ "$1" == "gdb" ]; then
+ RUNMODE=gdb
+ shift
+elif [ "$1" == "valgrind" ]; then
+ RUNMODE=valgrind
+ shift
+fi
+
+if [ ! -e "$1" ]; then
+ echo "file '$1' does not exist"
+ exit 1
+fi
+
+EXEC="$1"
+shift
+
+case $RUNMODE in
+ gdb)
+ gdb --args $PYTHON "$PWD/$EXEC" "$@"
+ ;;
+ valgrind)
+ valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes $PYTHON "$PWD/$EXEC" "$@"
+ ;;
+ *)
+ exec "$PWD/$EXEC" "$@"
+ ;;
+esac
+
+#CMD="$1"
+#shift
+#exec $PWD/$CMD "$@"
+
+