include not found fixed

This commit is contained in:
2025-02-11 21:32:07 +08:00
parent c2248b9a74
commit 99594e4241
49 changed files with 0 additions and 29322 deletions

View File

@ -1,11 +0,0 @@
{
"recommendations": [
"cheshirekow.cmake-format",
"donjayamanne.githistory",
"editorconfig.editorconfig",
"ms-vscode.cmake-tools",
"redhat.vscode-yaml",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
]
}

View File

@ -1,18 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppvsdbg",
"request": "launch",
"name": "cryptest",
"program": "${workspaceFolder}/build/cryptopp/cryptest",
"args": [
"v"
],
"cwd": "${workspaceFolder}/build"
}
]
}

View File

@ -1,37 +0,0 @@
{
"editor.rulers": [
80,
100
],
"rewrap.wrappingColumn": 80,
"rewrap.autoWrap.enabled": true,
"editor.detectIndentation": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"editor.bracketPairColorization.enabled": true,
"workbench.colorCustomizations": {
"[Default Dark+]": {
"editorBracketHighlight.foreground3": "#9CDCFE"
}
},
"cmake.configureOnOpen": true,
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.configureArgs": [
"-DCMAKE_INSTALL_PREFIX=${workspaceFolder}/build/install",
"-DCMAKE_VERBOSE_MAKEFILE=ON"
],
"rewrap.reformat": true,
"search.exclude": {
"**/.idea": true,
"**/out": true
},
"cSpell.words": [
"cmake",
"pkgconfig"
],
}

View File

@ -1,39 +0,0 @@
# Copyright (C) 2020 The Khronos Group Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of The Khronos Group Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
declare_args() {
build_with_chromium = false
linux_use_bundled_binutils_override = true
ignore_elf32_limitations = true
use_system_xcode = true
}

View File

@ -1,37 +0,0 @@
# Copyright (C) 2018 Google, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# These are variables that are overridable by projects that include glslang.
# The path to glslang dependencies.
glslang_spirv_tools_dir = "//External/spirv-tools"

View File

@ -1,38 +0,0 @@
# Copyright (C) 2020 The Khronos Group Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of The Khronos Group Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# We are building inside glslang
spirv_tools_standalone = false
# Paths to SPIRV-Tools dependencies
spirv_tools_spirv_headers_dir = "//External/spirv-tools/external/spirv-headers"

View File

@ -1,60 +0,0 @@
# Copyright 2016 The LibYuv Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# Variable that can be used to support multiple build scenarios, like having
# Chromium specific targets in a client project's GN file etc.
build_with_chromium = false
# Some non-Chromium builds don't support building java targets.
enable_java_templates = true
# Allow using custom suppressions files (currently not used by libyuv).
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
msan_blacklist_path =
rebase_path("//tools_libyuv/msan/blacklist.txt", root_build_dir)
ubsan_blacklist_path =
rebase_path("//tools_libyuv/ubsan/blacklist.txt", root_build_dir)
ubsan_vptr_blacklist_path =
rebase_path("//tools_libyuv/ubsan/vptr_blacklist.txt", root_build_dir)
# For Chromium, Android 32-bit non-component, non-clang builds hit a 4GiB size
# limit, making them requiring symbol_level=2. WebRTC doesn't hit that problem
# so we just ignore that assert. See https://crbug.com/648948 for more info.
ignore_elf32_limitations = true
# Use bundled hermetic Xcode installation maintained by Chromium,
# except for local iOS builds where it is unsupported.
if (host_os == "mac") {
_result = exec_script("//build/mac/should_use_hermetic_xcode.py",
[ target_os ],
"value")
assert(_result != 2,
"Do not allow building targets with the default" +
"hermetic toolchain if the minimum OS version is not met.")
use_system_xcode = _result == 0
}
declare_args() {
# Tracing support requires //third_party/perfetto.
enable_base_tracing = false
use_perfetto_client_library = false
# Limits the defined //third_party/android_deps targets to only "buildCompile"
# and "buildCompileNoDeps" targets. This is useful for third-party
# repositories which do not use JUnit tests. For instance,
# limit_android_deps == true removes "gn gen" requirement for
# //third_party/robolectric .
limit_android_deps = false
# Allows googletest to pretty-print various absl types.
# Defined here rather than in gtest.gni to match chromium.
gtest_enable_absl_printers = true
}

View File

@ -1,19 +0,0 @@
# Copyright (c) 2016 The LibYuv project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# Include support for registering main function in multi-process tests.
gtest_include_multiprocess = true
# Include support for platform-specific operations across unit tests.
gtest_include_platform_test = true
# Exclude support for testing Objective C code on OS X and iOS.
gtest_include_objc_support = true
# Exclude support for flushing coverage files on iOS.
gtest_include_ios_coverage = true

View File

@ -1,351 +0,0 @@
#!/bin/bash
set -e
if ! [ "x$ANDROID_NDK_HOME" != "x" -a -d "$ANDROID_NDK_HOME" ]; then
echo "ANDROID_NDK_HOME environment variable is not set"
exit 1
fi
if ! [ "x$ANDROID_HOME" != "x" -a -d "$ANDROID_HOME" ]; then
echo "ANDROID_HOME environment variable is not set"
exit 1
fi
if [ "x$ANDROID_API" = "x" ]; then
ANDROID_API="$(ls "$ANDROID_HOME/platforms" | grep -E "^android-[0-9]+$" | sed 's/android-//' | sort -n -r | head -1)"
if [ "x$ANDROID_API" = "x" ]; then
echo "No Android platform found in $ANDROID_HOME/platforms"
exit 1
fi
else
if ! [ -d "$ANDROID_HOME/platforms/android-$ANDROID_API" ]; then
echo "Android api version $ANDROID_API is not available ($ANDROID_HOME/platforms/android-$ANDROID_API does not exist)" >2
exit 1
fi
fi
android_platformdir="$ANDROID_HOME/platforms/android-$ANDROID_API"
echo "Building for android api version $ANDROID_API"
echo "android_platformdir=$android_platformdir"
scriptdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
sdl_root=$(cd -P -- "$(dirname -- "$0")/.." && printf '%s\n' "$(pwd -P)")
build_root="${sdl_root}/build-android-prefab"
android_abis="armeabi-v7a arm64-v8a x86 x86_64"
android_api=19
android_ndk=21
android_stl="c++_shared"
sdl_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' "${sdl_root}/include/SDL_version.h")
sdl_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' "${sdl_root}/include/SDL_version.h")
sdl_patch=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' "${sdl_root}/include/SDL_version.h")
sdl_version="${sdl_major}.${sdl_minor}.${sdl_patch}"
echo "Building Android prefab package for SDL version $sdl_version"
prefabhome="${build_root}/prefab-${sdl_version}"
rm -rf "$prefabhome"
mkdir -p "${prefabhome}"
build_cmake_projects() {
for android_abi in $android_abis; do
echo "Configuring CMake project for $android_abi"
cmake -S "$sdl_root" -B "${build_root}/build_${android_abi}" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
-DANDROID_PLATFORM=${android_platform} \
-DANDROID_ABI=${android_abi} \
-DSDL_SHARED=ON \
-DSDL_STATIC=ON \
-DSDL_STATIC_PIC=ON \
-DSDL_TEST=ON \
-DSDL2_DISABLE_SDL2MAIN=OFF \
-DSDL2_DISABLE_INSTALL=OFF \
-DCMAKE_INSTALL_PREFIX="${build_root}/build_${android_abi}/prefix" \
-DCMAKE_INSTALL_INCLUDEDIR=include \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-GNinja
rm -rf "${build_root}/build_${android_abi}/prefix"
echo "Building CMake project for $android_abi"
cmake --build "${build_root}/build_${android_abi}"
echo "Installing CMake project for $android_abi"
cmake --install "${build_root}/build_${android_abi}"
done
}
classes_sources_jar_path="${prefabhome}/classes-sources.jar"
classes_jar_path="${prefabhome}/classes.jar"
compile_java() {
classes_sources_root="${prefabhome}/classes-sources"
rm -rf "${classes_sources_root}"
mkdir -p "${classes_sources_root}/META-INF"
echo "Copying LICENSE.txt to java build folder"
cp "$sdl_root/LICENSE.txt" "${classes_sources_root}/META-INF"
echo "Copy JAVA sources to java build folder"
cp -r "$sdl_root/android-project/app/src/main/java/org" "${classes_sources_root}"
java_sourceslist_path="${prefabhome}/java_sources.txt"
pushd "${classes_sources_root}"
echo "Collecting sources for classes-sources.jar"
find "." -name "*.java" >"${java_sourceslist_path}"
find "META-INF" -name "*" >>"${java_sourceslist_path}"
echo "Creating classes-sources.jar"
jar -cf "${classes_sources_jar_path}" "@${java_sourceslist_path}"
popd
classes_root="${prefabhome}/classes"
mkdir -p "${classes_root}/META-INF"
cp "$sdl_root/LICENSE.txt" "${classes_root}/META-INF"
java_sourceslist_path="${prefabhome}/java_sources.txt"
echo "Collecting sources for classes.jar"
find "$sdl_root/android-project/app/src/main/java" -name "*.java" >"${java_sourceslist_path}"
echo "Compiling classes"
javac -encoding utf-8 -classpath "$android_platformdir/android.jar" -d "${classes_root}" "@${java_sourceslist_path}"
java_classeslist_path="${prefabhome}/java_classes.txt"
pushd "${classes_root}"
find "." -name "*.class" >"${java_classeslist_path}"
find "META-INF" -name "*" >>"${java_classeslist_path}"
echo "Creating classes.jar"
jar -cf "${classes_jar_path}" "@${java_classeslist_path}"
popd
}
pom_filename="SDL${sdl_major}-${sdl_version}.pom"
pom_filepath="${prefabhome}/${pom_filename}"
create_pom_xml() {
echo "Creating ${pom_filename}"
cat >"${pom_filepath}" <<EOF
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.libsdl.android</groupId>
<artifactId>SDL${sdl_major}</artifactId>
<version>${sdl_version}</version>
<packaging>aar</packaging>
<name>SDL${sdl_major}</name>
<description>The AAR for SDL${sdl_major}</description>
<url>https://libsdl.org/</url>
<licenses>
<license>
<name>zlib License</name>
<url>https://github.com/libsdl-org/SDL/blob/main/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/libsdl-org/SDL</connection>
<url>https://github.com/libsdl-org/SDL</url>
</scm>
</project>
EOF
}
create_aar_androidmanifest() {
echo "Creating AndroidManifest.xml"
cat >"${aar_root}/AndroidManifest.xml" <<EOF
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libsdl.android" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="16"
android:targetSdkVersion="29"/>
</manifest>
EOF
}
echo "Creating AAR root directory"
aar_root="${prefabhome}/SDL${sdl_major}-${sdl_version}"
mkdir -p "${aar_root}"
aar_metainfdir_path=${aar_root}/META-INF
mkdir -p "${aar_metainfdir_path}"
cp "${sdl_root}/LICENSE.txt" "${aar_metainfdir_path}"
prefabworkdir="${aar_root}/prefab"
mkdir -p "${prefabworkdir}"
cat >"${prefabworkdir}/prefab.json" <<EOF
{
"schema_version": 2,
"name": "SDL$sdl_major",
"version": "$sdl_version",
"dependencies": []
}
EOF
modulesworkdir="${prefabworkdir}/modules"
mkdir -p "${modulesworkdir}"
create_shared_sdl_module() {
echo "Creating SDL${sdl_major} prefab module"
for android_abi in $android_abis; do
sdl_moduleworkdir="${modulesworkdir}/SDL${sdl_major}"
mkdir -p "${sdl_moduleworkdir}"
abi_build_prefix="${build_root}/build_${android_abi}/prefix"
cat >"${sdl_moduleworkdir}/module.json" <<EOF
{
"export_libraries": [],
"library_name": "libSDL${sdl_major}"
}
EOF
mkdir -p "${sdl_moduleworkdir}/include"
cp -r "${abi_build_prefix}/include/SDL${sdl_major}/"* "${sdl_moduleworkdir}/include/"
rm "${sdl_moduleworkdir}/include/SDL_config.h"
cp "$sdl_root/include/SDL_config.h" "$sdl_root/include/SDL_config_android.h" "${sdl_moduleworkdir}/include/"
abi_sdllibdir="${sdl_moduleworkdir}/libs/android.${android_abi}"
mkdir -p "${abi_sdllibdir}"
cat >"${abi_sdllibdir}/abi.json" <<EOF
{
"abi": "${android_abi}",
"api": ${android_api},
"ndk": ${android_ndk},
"stl": "${android_stl}",
"static": false
}
EOF
cp "${abi_build_prefix}/lib/libSDL${sdl_major}.so" "${abi_sdllibdir}"
done
}
create_static_sdl_module() {
echo "Creating SDL${sdl_major}-static prefab module"
for android_abi in $android_abis; do
sdl_moduleworkdir="${modulesworkdir}/SDL${sdl_major}-static"
mkdir -p "${sdl_moduleworkdir}"
abi_build_prefix="${build_root}/build_${android_abi}/prefix"
cat >"${sdl_moduleworkdir}/module.json" <<EOF
{
"export_libraries": ["-ldl", "-lGLESv1_CM", "-lGLESv2", "-llog", "-landroid", "-lOpenSLES"]
"library_name": "libSDL${sdl_major}"
}
EOF
mkdir -p "${sdl_moduleworkdir}/include"
cp -r "${abi_build_prefix}/include/SDL${sdl_major}/"* "${sdl_moduleworkdir}/include"
rm "${sdl_moduleworkdir}/include/SDL_config.h"
cp "$sdl_root/include/SDL_config.h" "$sdl_root/include/SDL_config_android.h" "${sdl_moduleworkdir}/include/"
abi_sdllibdir="${sdl_moduleworkdir}/libs/android.${android_abi}"
mkdir -p "${abi_sdllibdir}"
cat >"${abi_sdllibdir}/abi.json" <<EOF
{
"abi": "${android_abi}",
"api": ${android_api},
"ndk": ${android_ndk},
"stl": "${android_stl}",
"static": true
}
EOF
cp "${abi_build_prefix}/lib/libSDL${sdl_major}.a" "${abi_sdllibdir}"
done
}
create_sdlmain_module() {
echo "Creating SDL${sdl_major}main prefab module"
for android_abi in $android_abis; do
sdl_moduleworkdir="${modulesworkdir}/SDL${sdl_major}main"
mkdir -p "${sdl_moduleworkdir}"
abi_build_prefix="${build_root}/build_${android_abi}/prefix"
cat >"${sdl_moduleworkdir}/module.json" <<EOF
{
"export_libraries": [],
"library_name": "libSDL${sdl_major}main"
}
EOF
abi_sdllibdir="${sdl_moduleworkdir}/libs/android.${android_abi}"
mkdir -p "${abi_sdllibdir}"
cat >"${abi_sdllibdir}/abi.json" <<EOF
{
"abi": "${android_abi}",
"api": ${android_api},
"ndk": ${android_ndk},
"stl": "${android_stl}",
"static": true
}
EOF
cp "${abi_build_prefix}/lib/libSDL${sdl_major}main.a" "${abi_sdllibdir}"
done
}
create_sdltest_module() {
echo "Creating SDL${sdl_major}test prefab module"
for android_abi in $android_abis; do
sdl_moduleworkdir="${modulesworkdir}/SDL${sdl_major}test"
mkdir -p "${sdl_moduleworkdir}"
abi_build_prefix="${build_root}/build_${android_abi}/prefix"
cat >"${sdl_moduleworkdir}/module.json" <<EOF
{
"export_libraries": [],
"library_name": "libSDL${sdl_major}_test"
}
EOF
abi_sdllibdir="${sdl_moduleworkdir}/libs/android.${android_abi}"
mkdir -p "${abi_sdllibdir}"
cat >"${abi_sdllibdir}/abi.json" <<EOF
{
"abi": "${android_abi}",
"api": ${android_api},
"ndk": ${android_ndk},
"stl": "${android_stl}",
"static": true
}
EOF
cp "${abi_build_prefix}/lib/libSDL${sdl_major}_test.a" "${abi_sdllibdir}"
done
}
build_cmake_projects
compile_java
create_pom_xml
create_aar_androidmanifest
create_shared_sdl_module
create_static_sdl_module
create_sdlmain_module
create_sdltest_module
pushd "${aar_root}"
aar_filename="SDL${sdl_major}-${sdl_version}.aar"
cp "${classes_jar_path}" ./classes.jar
cp "${classes_sources_jar_path}" ./classes-sources.jar
zip -r "${aar_filename}" AndroidManifest.xml classes.jar classes-sources.jar prefab META-INF
zip -Tv "${aar_filename}" 2>/dev/null ;
mv "${aar_filename}" "${prefabhome}"
popd
maven_filename="SDL${sdl_major}-${sdl_version}.zip"
pushd "${prefabhome}"
zip_filename="SDL${sdl_major}-${sdl_version}.zip"
zip "${maven_filename}" "${aar_filename}" "${pom_filename}" 2>/dev/null;
zip -Tv "${zip_filename}" 2>/dev/null;
popd
echo "Prefab zip is ready at ${prefabhome}/${aar_filename}"
echo "Maven archive is ready at ${prefabhome}/${zip_filename}"

View File

@ -1,100 +0,0 @@
#!/bin/bash
SOURCES=()
MKSOURCES=""
CURDIR=`pwd -P`
# Fetch sources
if [[ $# -ge 2 ]]; then
for src in ${@:2}
do
SOURCES+=($src)
MKSOURCES="$MKSOURCES $(basename $src)"
done
else
if [ -n "$1" ]; then
while read src
do
SOURCES+=($src)
MKSOURCES="$MKSOURCES $(basename $src)"
done
fi
fi
if [ -z "$1" ] || [ -z "$SOURCES" ]; then
echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list"
echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c"
echo "To copy SDL source instead of symlinking: COPYSOURCE=1 androidbuild.sh ... "
exit 1
fi
SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
if [ -z "$ANDROID_HOME" ];then
echo "Please set the ANDROID_HOME directory to the path of the Android SDK"
exit 1
fi
if [ ! -d "$ANDROID_HOME/ndk-bundle" -a -z "$ANDROID_NDK_HOME" ]; then
echo "Please set the ANDROID_NDK_HOME directory to the path of the Android NDK"
exit 1
fi
APP="$1"
APPARR=(${APP//./ })
BUILDPATH="$SDLPATH/build/$APP"
# Start Building
rm -rf $BUILDPATH
mkdir -p $BUILDPATH
cp -r $SDLPATH/android-project/* $BUILDPATH
# Copy SDL sources
mkdir -p $BUILDPATH/app/jni/SDL
if [ -z "$COPYSOURCE" ]; then
ln -s $SDLPATH/src $BUILDPATH/app/jni/SDL
ln -s $SDLPATH/include $BUILDPATH/app/jni/SDL
else
cp -r $SDLPATH/src $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/include $BUILDPATH/app/jni/SDL
fi
cp -r $SDLPATH/Android.mk $BUILDPATH/app/jni/SDL
sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/app/jni/src/Android.mk
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/build.gradle
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/src/main/AndroidManifest.xml
# Copy user sources
for src in "${SOURCES[@]}"
do
cp $src $BUILDPATH/app/jni/src
done
# Create an inherited Activity
cd $BUILDPATH/app/src/main/java
for folder in "${APPARR[@]}"
do
mkdir -p $folder
cd $folder
done
ACTIVITY="${folder}Activity"
sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" $BUILDPATH/app/src/main/AndroidManifest.xml
# Fill in a default Activity
cat >"$ACTIVITY.java" <<__EOF__
package $APP;
import org.libsdl.app.SDLActivity;
public class $ACTIVITY extends SDLActivity
{
}
__EOF__
# Update project and build
echo "To build and install to a device for testing, run the following:"
echo "cd $BUILDPATH"
echo "./gradlew installDebug"

View File

@ -1,73 +0,0 @@
#!/bin/sh
#
# Build the Android libraries without needing a project
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
#
# Usage: androidbuildlibs.sh [arg for ndk-build ...]"
#
# Useful NDK arguments:
#
# NDK_DEBUG=1 - build debug version
# NDK_LIBS_OUT=<dest> - specify alternate destination for installable
# modules.
#
# Note that SDLmain is not an installable module (.so) so libSDLmain.a
# can be found in $obj/local/<abi> along with the unstripped libSDL.so.
#
# Android.mk is in srcdir
srcdir=`dirname $0`/..
srcdir=`cd $srcdir && pwd`
cd $srcdir
#
# Create the build directories
#
build=build
buildandroid=$build/android
obj=
lib=
ndk_args=
# Allow an external caller to specify locations.
for arg in $*; do
if [ "${arg:0:8}" == "NDK_OUT=" ]; then
obj=${arg#NDK_OUT=}
elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
lib=${arg#NDK_LIBS_OUT=}
else
ndk_args="$ndk_args $arg"
fi
done
if [ -z $obj ]; then
obj=$buildandroid/obj
fi
if [ -z $lib ]; then
lib=$buildandroid/lib
fi
for dir in $build $buildandroid $obj $lib; do
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
# APP_* variables set in the environment here will not be seen by the
# ndk-build makefile segments that use them, e.g., default-application.mk.
# For consistency, pass all values on the command line.
ndk-build \
NDK_PROJECT_PATH=null \
NDK_OUT=$obj \
NDK_LIBS_OUT=$lib \
APP_BUILD_SCRIPT=Android.mk \
APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" \
APP_PLATFORM=android-16 \
APP_MODULES="SDL2 SDL2_main" \
$ndk_args

View File

@ -1,62 +0,0 @@
#!/bin/bash
# This is a script used by some Buildbot buildslaves to push the project
# through Clang's static analyzer and prepare the output to be uploaded
# back to the buildmaster. You might find it useful too.
# Install Clang (you already have it on Mac OS X, apt-get install clang
# on Ubuntu, etc), and make sure scan-build is in your $PATH.
FINALDIR="$1"
set -x
set -e
cd `dirname "$0"`
cd ..
rm -rf checker-buildbot analysis
if [ ! -z "$FINALDIR" ]; then
rm -rf "$FINALDIR"
fi
mkdir checker-buildbot
cd checker-buildbot
# We turn off deprecated declarations, because we don't care about these warnings during static analysis.
# The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
# You might want to do this for CMake-backed builds instead...
scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
# ...or run configure without the scan-build wrapper...
#CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
rm -rf analysis
scan-build -o analysis ninja
if [ `ls -A analysis |wc -l` == 0 ] ; then
mkdir analysis/zarro
echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
fi
mv analysis/* ../analysis
rmdir analysis # Make sure this is empty.
cd ..
chmod -R a+r analysis
chmod -R go-w analysis
find analysis -type d -exec chmod a+x {} \;
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
if [ ! -z "$FINALDIR" ]; then
mv analysis "$FINALDIR"
else
FINALDIR=analysis
fi
rm -rf checker-buildbot
echo "Done. Final output is in '$FINALDIR' ..."
# end of checker-buildbot.sh ...

View File

@ -1,102 +0,0 @@
#!/bin/sh
#
# Build Universal binaries on Mac OS X, thanks Ryan!
#
# Usage: ./configure CXX="sh clang++-fat.sh" && make && rm -rf arm64 x64
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
# Intel 64-bit compiler flags (10.7 runtime compatibility)
CLANG_COMPILE_X64="clang++ -arch x86_64 -mmacosx-version-min=10.7 \
-I/usr/local/include"
CLANG_LINK_X64="-mmacosx-version-min=10.7"
# ARM 64-bit compiler flags (11.0 runtime compatibility)
CLANG_COMPILE_ARM64="clang++ -arch arm64 -mmacosx-version-min=11.0 \
-I/usr/local/include"
CLANG_LINK_ARM64="-mmacosx-version-min=11.0"
# Output both Intel and ARM object files
args="$*"
compile=yes
link=yes
while test x$1 != x; do
case $1 in
--version) exec clang++ $1;;
-v) exec clang++ $1;;
-V) exec clang++ $1;;
-print-prog-name=*) exec clang++ $1;;
-print-search-dirs) exec clang++ $1;;
-E) CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
compile=no; link=no;;
-c) link=no;;
-o) output=$2;;
*.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
esac
shift
done
if test x$link = xyes; then
CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
fi
if test x"$output" = x; then
if test x$link = xyes; then
output=a.out
elif test x$compile = xyes; then
output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
fi
fi
# Compile ARM 64-bit
if test x"$output" != x; then
dir=arm64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "arm64/$1" && test "$1" != "$output"; then
arm64_args="$arm64_args arm64/$1"
else
arm64_args="$arm64_args $1"
fi
shift
done
$CLANG_COMPILE_ARM64 $arm64_args || exit $?
if test x"$output" != x; then
cp $output arm64/$output
fi
# Compile Intel 64-bit
if test x"$output" != x; then
dir=x64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "x64/$1" && test "$1" != "$output"; then
x64_args="$x64_args x64/$1"
else
x64_args="$x64_args $1"
fi
shift
done
$CLANG_COMPILE_X64 $x64_args || exit $?
if test x"$output" != x; then
cp $output x64/$output
fi
if test x"$output" != x; then
lipo -create -o $output arm64/$output x64/$output
fi

View File

@ -1,105 +0,0 @@
#!/bin/sh
#
# Build Universal binaries on Mac OS X, thanks Ryan!
#
# Usage: ./configure CC="sh clang-fat.sh" && make && rm -rf arm64 x64
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
# Intel 64-bit compiler flags (10.9 runtime compatibility)
CLANG_COMPILE_X64="clang -arch x86_64 -mmacosx-version-min=10.9 \
-DMAC_OS_X_VERSION_MIN_REQUIRED=1070 \
-I/usr/local/include"
CLANG_LINK_X64="-mmacosx-version-min=10.9"
# ARM 64-bit compiler flags (11.0 runtime compatibility)
CLANG_COMPILE_ARM64="clang -arch arm64 -mmacosx-version-min=11.0 \
-I/usr/local/include"
CLANG_LINK_ARM64="-mmacosx-version-min=11.0"
# Output both Intel and ARM object files
args="$*"
compile=yes
link=yes
while test x$1 != x; do
case $1 in
--version) exec clang $1;;
-v) exec clang $1;;
-V) exec clang $1;;
-print-prog-name=*) exec clang $1;;
-print-search-dirs) exec clang $1;;
-E) CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
compile=no; link=no;;
-c) link=no;;
-o) output=$2;;
*.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
esac
shift
done
if test x$link = xyes; then
CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
fi
if test x"$output" = x; then
if test x$link = xyes; then
output=a.out
elif test x$compile = xyes; then
output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
fi
fi
# Compile Intel 64-bit
if test x"$output" != x; then
dir=x64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "x64/$1" && test "$1" != "$output"; then
x64_args="$x64_args x64/$1"
else
x64_args="$x64_args $1"
fi
shift
done
$CLANG_COMPILE_X64 $x64_args || exit $?
if test x"$output" != x; then
cp $output x64/$output
fi
# Compile ARM 64-bit
if test x"$output" != x; then
dir=arm64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "arm64/$1" && test "$1" != "$output"; then
arm64_args="$arm64_args arm64/$1"
else
arm64_args="$arm64_args $1"
fi
shift
done
$CLANG_COMPILE_ARM64 $arm64_args || exit $?
if test x"$output" != x; then
cp $output arm64/$output
fi
if test x"$output" != x; then
lipo -create -o $output arm64/$output x64/$output
fi

View File

@ -1,59 +0,0 @@
#!/bin/bash
# This is a script used by some Buildbot build workers to push the project
# through Clang's static analyzer and prepare the output to be uploaded
# back to the buildmaster. You might find it useful too.
# Install Clang (you already have it on macOS, apt-get install clang
# on Ubuntu, etc), install CMake, and pip3 install codechecker.
FINALDIR="$1"
set -x
set -e
cd `dirname "$0"`
cd ..
rm -rf codechecker-buildbot
if [ ! -z "$FINALDIR" ]; then
rm -rf "$FINALDIR"
fi
mkdir codechecker-buildbot
cd codechecker-buildbot
# We turn off deprecated declarations, because we don't care about these warnings during static analysis.
cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
# CMake on macOS adds "-arch arm64" or whatever is appropriate, but this confuses CodeChecker, so strip it out.
perl -w -pi -e 's/\-arch\s+.*?\s+//g;' compile_commands.json
rm -rf ../analysis
CodeChecker analyze compile_commands.json -o ./reports
# "parse" returns 2 if there was a static analysis issue to report, but this
# does not signify an error in the parsing (that would be error code 1). Turn
# off the abort-on-error flag.
set +e
CodeChecker parse ./reports -e html -o ../analysis
set -e
cd ..
chmod -R a+r analysis
chmod -R go-w analysis
find analysis -type d -exec chmod a+x {} \;
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
if [ ! -z "$FINALDIR" ]; then
mv analysis "$FINALDIR"
else
FINALDIR=analysis
fi
rm -rf codechecker-buildbot
echo "Done. Final output is in '$FINALDIR' ..."
# end of codechecker-buildbot.sh ...

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
#!/bin/bash
if [ -z "$SDKDIR" ]; then
SDKDIR="/emsdk"
fi
ENVSCRIPT="$SDKDIR/emsdk_env.sh"
if [ ! -f "$ENVSCRIPT" ]; then
echo "ERROR: This script expects the Emscripten SDK to be in '$SDKDIR'." 1>&2
echo "ERROR: Set the \$SDKDIR environment variable to override this." 1>&2
exit 1
fi
TARBALL="$1"
if [ -z $1 ]; then
TARBALL=sdl-emscripten.tar.xz
fi
cd `dirname "$0"`
cd ..
SDLBASE=`pwd`
if [ -z "$MAKE" ]; then
OSTYPE=`uname -s`
if [ "$OSTYPE" == "Linux" ]; then
NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
let NCPU=$NCPU+1
elif [ "$OSTYPE" = "Darwin" ]; then
NCPU=`sysctl -n hw.ncpu`
elif [ "$OSTYPE" = "SunOS" ]; then
NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
else
NCPU=1
fi
if [ -z "$NCPU" ]; then
NCPU=1
elif [ "$NCPU" = "0" ]; then
NCPU=1
fi
MAKE="make -j$NCPU"
fi
echo "\$MAKE is '$MAKE'"
echo "Setting up Emscripten SDK environment..."
source "$ENVSCRIPT"
echo "Setting up..."
set -x
cd "$SDLBASE"
rm -rf buildbot
mkdir buildbot
pushd buildbot
echo "Configuring..."
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-s USE_SDL=0 -O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
echo "Building..."
emmake $MAKE || exit $?
echo "Moving things around..."
emmake $MAKE install || exit $?
# Fix up a few things to a real install path
perl -w -pi -e "s#$PWD/emscripten-sdl2-installed#/usr/local#g;" ./emscripten-sdl2-installed/lib/libSDL2.la ./emscripten-sdl2-installed/lib/pkgconfig/sdl2.pc ./emscripten-sdl2-installed/bin/sdl2-config
mkdir -p ./usr
mv ./emscripten-sdl2-installed ./usr/local
tar -cJvvf $TARBALL usr
popd
exit 0
# end of emscripten-buildbot.sh ...

View File

@ -1,188 +0,0 @@
#!/usr/bin/perl -w
use warnings;
use strict;
use File::Basename;
use Cwd qw(abs_path);
my $wikipath = undef;
foreach (@ARGV) {
$wikipath = abs_path($_), next if not defined $wikipath;
}
chdir(dirname(__FILE__));
chdir('..');
my @unsorted_releases = ();
open(PIPEFH, '-|', 'git tag -l') or die "Failed to read git release tags: $!\n";
while (<PIPEFH>) {
chomp;
if (/\Arelease\-(.*?)\Z/) {
# After 2.24.x, ignore anything that isn't a x.y.0 release.
# We moved to bugfix-only point releases there, so make sure new APIs
# are assigned to the next minor version and ignore the patch versions.
my $ver = $1;
my @versplit = split /\./, $ver;
next if (scalar(@versplit) > 2) && (($versplit[0] > 2) || (($versplit[0] == 2) && ($versplit[1] >= 24))) && ($versplit[2] != 0);
# Consider this release version.
push @unsorted_releases, $ver;
}
}
close(PIPEFH);
#print("\n\nUNSORTED\n");
#foreach (@unsorted_releases) {
# print "$_\n";
#}
my @releases = sort {
my @asplit = split /\./, $a;
my @bsplit = split /\./, $b;
my $rc;
for (my $i = 0; $i < scalar(@asplit); $i++) {
return 1 if (scalar(@bsplit) <= $i); # a is "2.0.1" and b is "2.0", or whatever.
my $aseg = $asplit[$i];
my $bseg = $bsplit[$i];
$rc = int($aseg) <=> int($bseg);
return $rc if ($rc != 0); # found the difference.
}
return 0; # still here? They matched completely?!
} @unsorted_releases;
# this happens to work for how SDL versions things at the moment.
my $current_release = $releases[-1];
my $next_release;
if ($current_release eq '2.0.22') { # Hack for our jump from 2.0.22 to 2.24.0...
$next_release = '2.24.0';
} else {
my @current_release_segments = split /\./, $current_release;
@current_release_segments[1] = '' . ($current_release_segments[1] + 2);
$next_release = join('.', @current_release_segments);
}
#print("\n\nSORTED\n");
#foreach (@releases) {
# print "$_\n";
#}
#print("\nCURRENT RELEASE: $current_release\n");
#print("NEXT RELEASE: $next_release\n\n");
push @releases, 'HEAD';
my %funcs = ();
foreach my $release (@releases) {
#print("Checking $release...\n");
next if ($release eq '2.0.0') || ($release eq '2.0.1'); # no dynapi before 2.0.2
my $assigned_release = ($release eq '2.0.2') ? '2.0.0' : $release; # assume everything in 2.0.2--first with dynapi--was there since 2.0.0. We'll fix it up later.
my $tag = ($release eq 'HEAD') ? $release : "release-$release";
my $blobname = "$tag:src/dynapi/SDL_dynapi_overrides.h";
open(PIPEFH, '-|', "git show '$blobname'") or die "Failed to read git blob '$blobname': $!\n";
while (<PIPEFH>) {
chomp;
if (/\A\#define\s+(SDL_.*?)\s+SDL_.*?_REAL\Z/) {
my $fn = $1;
$funcs{$fn} = $assigned_release if not defined $funcs{$fn};
}
}
close(PIPEFH);
}
# Fixup the handful of functions that were added in 2.0.1 and 2.0.2 that we
# didn't have dynapi revision data about...
$funcs{'SDL_GetSystemRAM'} = '2.0.1';
$funcs{'SDL_GetBasePath'} = '2.0.1';
$funcs{'SDL_GetPrefPath'} = '2.0.1';
$funcs{'SDL_UpdateYUVTexture'} = '2.0.1';
$funcs{'SDL_GL_GetDrawableSize'} = '2.0.1';
$funcs{'SDL_Direct3D9GetAdapterIndex'} = '2.0.1';
$funcs{'SDL_RenderGetD3D9Device'} = '2.0.1';
$funcs{'SDL_RegisterApp'} = '2.0.2';
$funcs{'SDL_UnregisterApp'} = '2.0.2';
$funcs{'SDL_GetAssertionHandler'} = '2.0.2';
$funcs{'SDL_GetDefaultAssertionHandler'} = '2.0.2';
$funcs{'SDL_AtomicAdd'} = '2.0.2';
$funcs{'SDL_AtomicGet'} = '2.0.2';
$funcs{'SDL_AtomicGetPtr'} = '2.0.2';
$funcs{'SDL_AtomicSet'} = '2.0.2';
$funcs{'SDL_AtomicSetPtr'} = '2.0.2';
$funcs{'SDL_HasAVX'} = '2.0.2';
$funcs{'SDL_GameControllerAddMappingsFromRW'} = '2.0.2';
$funcs{'SDL_acos'} = '2.0.2';
$funcs{'SDL_asin'} = '2.0.2';
$funcs{'SDL_vsscanf'} = '2.0.2';
$funcs{'SDL_DetachThread'} = '2.0.2';
$funcs{'SDL_GL_ResetAttributes'} = '2.0.2';
$funcs{'SDL_DXGIGetOutputInfo'} = '2.0.2';
# these are incorrect in the dynapi header, because we forgot to add them
# until a later release, but are available in the older release.
$funcs{'SDL_WinRTGetFSPathUNICODE'} = '2.0.3';
$funcs{'SDL_WinRTGetFSPathUTF8'} = '2.0.3';
$funcs{'SDL_WinRTRunApp'} = '2.0.3';
if (not defined $wikipath) {
foreach my $release (@releases) {
foreach my $fn (sort keys %funcs) {
print("$fn: $funcs{$fn}\n") if $funcs{$fn} eq $release;
}
}
} else {
if (defined $wikipath) {
chdir($wikipath);
foreach my $fn (keys %funcs) {
my $revision = $funcs{$fn};
$revision = $next_release if $revision eq 'HEAD';
my $fname = "$fn.mediawiki";
if ( ! -f $fname ) {
#print STDERR "No such file: $fname\n";
next;
}
my @lines = ();
open(FH, '<', $fname) or die("Can't open $fname for read: $!\n");
my $added = 0;
while (<FH>) {
chomp;
if ((/\A\-\-\-\-/) && (!$added)) {
push @lines, "== Version ==";
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
$added = 1;
}
push @lines, $_;
next if not /\A\=\=\s+Version\s+\=\=/;
$added = 1;
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
while (<FH>) {
chomp;
next if not (/\A\=\=\s+/ || /\A\-\-\-\-/);
push @lines, $_;
last;
}
}
close(FH);
if (!$added) {
push @lines, "== Version ==";
push @lines, "";
push @lines, "This function is available since SDL $revision.";
push @lines, "";
}
open(FH, '>', $fname) or die("Can't open $fname for write: $!\n");
foreach (@lines) {
print FH "$_\n";
}
close(FH);
}
}
}

View File

@ -1,450 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
/*
Built with:
gcc -o genchancvt build-scripts/gen_audio_channel_conversion.c -lm && ./genchancvt > src/audio/SDL_audio_channel_converters.h
*/
#define NUM_CHANNELS 8
static const char *layout_names[NUM_CHANNELS] = {
"Mono", "Stereo", "2.1", "Quad", "4.1", "5.1", "6.1", "7.1"
};
static const char *channel_names[NUM_CHANNELS][NUM_CHANNELS] = {
/* mono */ { "FC" },
/* stereo */ { "FL", "FR" },
/* 2.1 */ { "FL", "FR", "LFE" },
/* quad */ { "FL", "FR", "BL", "BR" },
/* 4.1 */ { "FL", "FR", "LFE", "BL", "BR" },
/* 5.1 */ { "FL", "FR", "FC", "LFE", "BL", "BR" },
/* 6.1 */ { "FL", "FR", "FC", "LFE", "BC", "SL", "SR" },
/* 7.1 */ { "FL", "FR", "FC", "LFE", "BL", "BR", "SL", "SR" },
};
/*
* This table is from FAudio:
*
* https://raw.githubusercontent.com/FNA-XNA/FAudio/master/src/matrix_defaults.inl
*/
static const float channel_conversion_matrix[8][8][64] = {
{
/* 1 x 1 */
{ 1.000000000f },
/* 1 x 2 */
{ 1.000000000f, 1.000000000f },
/* 1 x 3 */
{ 1.000000000f, 1.000000000f, 0.000000000f },
/* 1 x 4 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 5 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 6 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 7 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 1 x 8 */
{ 1.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 2 x 1 */
{ 0.500000000f, 0.500000000f },
/* 2 x 2 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 2 x 3 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 4 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 2 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 3 x 1 */
{ 0.333333343f, 0.333333343f, 0.333333343f },
/* 3 x 2 */
{ 0.800000012f, 0.000000000f, 0.200000003f, 0.000000000f, 0.800000012f, 0.200000003f },
/* 3 x 3 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 3 x 4 */
{ 0.888888896f, 0.000000000f, 0.111111112f, 0.000000000f, 0.888888896f, 0.111111112f, 0.000000000f, 0.000000000f, 0.111111112f, 0.000000000f, 0.000000000f, 0.111111112f },
/* 3 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 3 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 4 x 1 */
{ 0.250000000f, 0.250000000f, 0.250000000f, 0.250000000f },
/* 4 x 2 */
{ 0.421000004f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.219999999f, 0.358999997f },
/* 4 x 3 */
{ 0.421000004f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.219999999f, 0.358999997f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 4 x 4 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 4 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 4 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 5 x 1 */
{ 0.200000003f, 0.200000003f, 0.200000003f, 0.200000003f, 0.200000003f },
/* 5 x 2 */
{ 0.374222219f, 0.000000000f, 0.111111112f, 0.319111109f, 0.195555553f, 0.000000000f, 0.374222219f, 0.111111112f, 0.195555553f, 0.319111109f },
/* 5 x 3 */
{ 0.421000004f, 0.000000000f, 0.000000000f, 0.358999997f, 0.219999999f, 0.000000000f, 0.421000004f, 0.000000000f, 0.219999999f, 0.358999997f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 5 x 4 */
{ 0.941176474f, 0.000000000f, 0.058823530f, 0.000000000f, 0.000000000f, 0.000000000f, 0.941176474f, 0.058823530f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.058823530f, 0.941176474f, 0.000000000f, 0.000000000f, 0.000000000f, 0.058823530f, 0.000000000f, 0.941176474f },
/* 5 x 5 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 5 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 5 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 5 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 6 x 1 */
{ 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f, 0.166666672f },
/* 6 x 2 */
{ 0.294545442f, 0.000000000f, 0.208181813f, 0.090909094f, 0.251818180f, 0.154545456f, 0.000000000f, 0.294545442f, 0.208181813f, 0.090909094f, 0.154545456f, 0.251818180f },
/* 6 x 3 */
{ 0.324000001f, 0.000000000f, 0.229000002f, 0.000000000f, 0.277000010f, 0.170000002f, 0.000000000f, 0.324000001f, 0.229000002f, 0.000000000f, 0.170000002f, 0.277000010f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f },
/* 6 x 4 */
{ 0.558095276f, 0.000000000f, 0.394285709f, 0.047619049f, 0.000000000f, 0.000000000f, 0.000000000f, 0.558095276f, 0.394285709f, 0.047619049f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.047619049f, 0.558095276f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.047619049f, 0.000000000f, 0.558095276f },
/* 6 x 5 */
{ 0.586000025f, 0.000000000f, 0.414000005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f, 0.414000005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.586000025f },
/* 6 x 6 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 6 x 7 */
{ 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.939999998f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.500000000f, 0.500000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.796000004f },
/* 6 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f }
},
{
/* 7 x 1 */
{ 0.143142849f, 0.143142849f, 0.143142849f, 0.142857149f, 0.143142849f, 0.143142849f, 0.143142849f },
/* 7 x 2 */
{ 0.247384623f, 0.000000000f, 0.174461529f, 0.076923080f, 0.174461529f, 0.226153851f, 0.100615382f, 0.000000000f, 0.247384623f, 0.174461529f, 0.076923080f, 0.174461529f, 0.100615382f, 0.226153851f },
/* 7 x 3 */
{ 0.268000007f, 0.000000000f, 0.188999996f, 0.000000000f, 0.188999996f, 0.245000005f, 0.108999997f, 0.000000000f, 0.268000007f, 0.188999996f, 0.000000000f, 0.188999996f, 0.108999997f, 0.245000005f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 7 x 4 */
{ 0.463679999f, 0.000000000f, 0.327360004f, 0.040000003f, 0.000000000f, 0.168960005f, 0.000000000f, 0.000000000f, 0.463679999f, 0.327360004f, 0.040000003f, 0.000000000f, 0.000000000f, 0.168960005f, 0.000000000f, 0.000000000f, 0.000000000f, 0.040000003f, 0.327360004f, 0.431039989f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.040000003f, 0.327360004f, 0.000000000f, 0.431039989f },
/* 7 x 5 */
{ 0.483000010f, 0.000000000f, 0.340999991f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.483000010f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.340999991f, 0.449000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.340999991f, 0.000000000f, 0.449000001f },
/* 7 x 6 */
{ 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.223000005f, 0.000000000f, 0.000000000f, 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.223000005f, 0.000000000f, 0.000000000f, 0.611000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.432000011f, 0.568000019f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.432000011f, 0.000000000f, 0.568000019f },
/* 7 x 7 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f },
/* 7 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.707000017f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.707000017f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f }
},
{
/* 8 x 1 */
{ 0.125125006f, 0.125125006f, 0.125125006f, 0.125000000f, 0.125125006f, 0.125125006f, 0.125125006f, 0.125125006f },
/* 8 x 2 */
{ 0.211866662f, 0.000000000f, 0.150266662f, 0.066666670f, 0.181066677f, 0.111066669f, 0.194133341f, 0.085866667f, 0.000000000f, 0.211866662f, 0.150266662f, 0.066666670f, 0.111066669f, 0.181066677f, 0.085866667f, 0.194133341f },
/* 8 x 3 */
{ 0.226999998f, 0.000000000f, 0.160999998f, 0.000000000f, 0.194000006f, 0.119000003f, 0.208000004f, 0.092000000f, 0.000000000f, 0.226999998f, 0.160999998f, 0.000000000f, 0.119000003f, 0.194000006f, 0.092000000f, 0.208000004f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f },
/* 8 x 4 */
{ 0.466344833f, 0.000000000f, 0.329241365f, 0.034482758f, 0.000000000f, 0.000000000f, 0.169931039f, 0.000000000f, 0.000000000f, 0.466344833f, 0.329241365f, 0.034482758f, 0.000000000f, 0.000000000f, 0.000000000f, 0.169931039f, 0.000000000f, 0.000000000f, 0.000000000f, 0.034482758f, 0.466344833f, 0.000000000f, 0.433517247f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.034482758f, 0.000000000f, 0.466344833f, 0.000000000f, 0.433517247f },
/* 8 x 5 */
{ 0.483000010f, 0.000000000f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.483000010f, 0.340999991f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.175999999f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.483000010f, 0.000000000f, 0.449000001f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.483000010f, 0.000000000f, 0.449000001f },
/* 8 x 6 */
{ 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.188999996f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.188999996f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.481999993f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.518000007f, 0.000000000f, 0.481999993f },
/* 8 x 7 */
{ 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.287999988f, 0.287999988f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.458999991f, 0.000000000f, 0.541000009f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.458999991f, 0.000000000f, 0.541000009f },
/* 8 x 8 */
{ 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 0.000000000f, 1.000000000f }
}
};
static char *remove_dots(const char *str) /* this is NOT robust. */
{
static char retval1[32];
static char retval2[32];
static int idx = 0;
char *retval = (idx++ & 1) ? retval1 : retval2;
char *ptr = retval;
while (*str) {
if (*str != '.') {
*(ptr++) = *str;
}
str++;
}
*ptr = '\0';
return retval;
}
static char *lowercase(const char *str) /* this is NOT robust. */
{
static char retval1[32];
static char retval2[32];
static int idx = 0;
char *retval = (idx++ & 1) ? retval1 : retval2;
char *ptr = retval;
while (*str) {
const char ch = *(str++);
*(ptr++) = ((ch >= 'A') && (ch <= 'Z')) ? (ch - ('A' - 'a')) : ch;
}
*ptr = '\0';
return retval;
}
static void write_converter(const int fromchans, const int tochans)
{
const char *fromstr = layout_names[fromchans-1];
const char *tostr = layout_names[tochans-1];
const float *cvtmatrix = channel_conversion_matrix[fromchans-1][tochans-1];
const float *fptr;
const int convert_backwards = (tochans > fromchans);
int input_channel_used[NUM_CHANNELS];
int i, j;
if (tochans == fromchans) {
return; /* nothing to convert, don't generate a converter. */
}
for (i = 0; i < fromchans; i++) {
input_channel_used[i] = 0;
}
fptr = cvtmatrix;
for (j = 0; j < tochans; j++) {
for (i = 0; i < fromchans; i++) {
#if 0
printf("to=%d, from=%d, coeff=%f\n", j, i, *fptr);
#endif
if (*(fptr++) != 0.0f) {
input_channel_used[i]++;
}
}
}
printf("static void SDLCALL\n"
"SDL_Convert%sTo%s(SDL_AudioCVT *cvt, SDL_AudioFormat format)\n"
"{\n", remove_dots(fromstr), remove_dots(tostr));
if (convert_backwards) { /* must convert backwards when growing the output in-place. */
printf(" float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / %d) * %d))) - %d;\n", fromchans, tochans, tochans);
printf(" const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - %d;\n", fromchans);
} else {
printf(" float *dst = (float *) cvt->buf;\n");
printf(" const float *src = dst;\n");
}
printf(" int i;\n"
"\n"
" LOG_DEBUG_CONVERT(\"%s\", \"%s\");\n"
" SDL_assert(format == AUDIO_F32SYS);\n"
"\n", lowercase(fromstr), lowercase(tostr));
if (convert_backwards) {
printf(" /* convert backwards, since output is growing in-place. */\n");
printf(" for (i = cvt->len_cvt / (sizeof (float) * %d); i; i--, src -= %d, dst -= %d) {\n", fromchans, fromchans, tochans);
fptr = cvtmatrix;
for (i = 0; i < fromchans; i++) {
if (input_channel_used[i] > 1) { /* don't read it from src more than once. */
printf(" const float src%s = src[%d];\n", channel_names[fromchans-1][i], i);
}
}
for (j = tochans - 1; j >= 0; j--) {
int has_input = 0;
fptr = cvtmatrix + (fromchans * j);
printf(" dst[%d] /* %s */ =", j, channel_names[tochans-1][j]);
for (i = fromchans - 1; i >= 0; i--) {
const float coefficient = fptr[i];
char srcname[32];
if (coefficient == 0.0f) {
continue;
} else if (input_channel_used[i] > 1) {
snprintf(srcname, sizeof (srcname), "src%s", channel_names[fromchans-1][i]);
} else {
snprintf(srcname, sizeof (srcname), "src[%d]", i);
}
if (has_input) {
printf(" +");
}
has_input = 1;
if (coefficient == 1.0f) {
printf(" %s", srcname);
} else {
printf(" (%s * %.9ff)", srcname, coefficient);
}
}
if (!has_input) {
printf(" 0.0f");
}
printf(";\n");
}
printf(" }\n");
} else {
printf(" for (i = cvt->len_cvt / (sizeof (float) * %d); i; i--, src += %d, dst += %d) {\n", fromchans, fromchans, tochans);
fptr = cvtmatrix;
for (i = 0; i < fromchans; i++) {
if (input_channel_used[i] > 1) { /* don't read it from src more than once. */
printf(" const float src%s = src[%d];\n", channel_names[fromchans-1][i], i);
}
}
for (j = 0; j < tochans; j++) {
int has_input = 0;
fptr = cvtmatrix + (fromchans * j);
printf(" dst[%d] /* %s */ =", j, channel_names[tochans-1][j]);
for (i = 0; i < fromchans; i++) {
const float coefficient = fptr[i];
char srcname[32];
if (coefficient == 0.0f) {
continue;
} else if (input_channel_used[i] > 1) {
snprintf(srcname, sizeof (srcname), "src%s", channel_names[fromchans-1][i]);
} else {
snprintf(srcname, sizeof (srcname), "src[%d]", i);
}
if (has_input) {
printf(" +");
}
has_input = 1;
if (coefficient == 1.0f) {
printf(" %s", srcname);
} else {
printf(" (%s * %.9ff)", srcname, coefficient);
}
}
if (!has_input) {
printf(" 0.0f");
}
printf(";\n");
}
printf(" }\n");
}
printf("\n");
if ((fromchans > 1) && (tochans > 1)) {
printf(" cvt->len_cvt = (cvt->len_cvt / %d) * %d;\n", fromchans, tochans);
} else if (tochans == 1) {
printf(" cvt->len_cvt = cvt->len_cvt / %d;\n", fromchans);
} else /* if (fromchans == 1) */ {
printf(" cvt->len_cvt = cvt->len_cvt * %d;\n", tochans);
}
printf(" if (cvt->filters[++cvt->filter_index]) {\n"
" cvt->filters[cvt->filter_index] (cvt, format);\n"
" }\n"
"}\n\n");
}
int main(void)
{
int ini, outi;
printf(
"/*\n"
" Simple DirectMedia Layer\n"
" Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>\n"
"\n"
" This software is provided 'as-is', without any express or implied\n"
" warranty. In no event will the authors be held liable for any damages\n"
" arising from the use of this software.\n"
"\n"
" Permission is granted to anyone to use this software for any purpose,\n"
" including commercial applications, and to alter it and redistribute it\n"
" freely, subject to the following restrictions:\n"
"\n"
" 1. The origin of this software must not be misrepresented; you must not\n"
" claim that you wrote the original software. If you use this software\n"
" in a product, an acknowledgment in the product documentation would be\n"
" appreciated but is not required.\n"
" 2. Altered source versions must be plainly marked as such, and must not be\n"
" misrepresented as being the original software.\n"
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
"/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */\n"
"\n"
);
for (ini = 1; ini <= NUM_CHANNELS; ini++) {
for (outi = 1; outi <= NUM_CHANNELS; outi++) {
write_converter(ini, outi);
}
}
printf("static const SDL_AudioFilter channel_converters[%d][%d] = { /* [from][to] */\n", NUM_CHANNELS, NUM_CHANNELS);
for (ini = 1; ini <= NUM_CHANNELS; ini++) {
const char *comma = "";
printf(" {");
for (outi = 1; outi <= NUM_CHANNELS; outi++) {
const char *fromstr = layout_names[ini-1];
const char *tostr = layout_names[outi-1];
if (ini == outi) {
printf("%s NULL", comma);
} else {
printf("%s SDL_Convert%sTo%s", comma, remove_dots(fromstr), remove_dots(tostr));
}
comma = ",";
}
printf(" }%s\n", (ini == NUM_CHANNELS) ? "" : ",");
}
printf("};\n\n");
printf("/* vi: set ts=4 sw=4 expandtab: */\n\n");
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,163 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Built with:
gcc -o genfilter build-scripts/gen_audio_resampler_filter.c -lm && ./genfilter > src/audio/SDL_audio_resampler_filter.h
*/
/*
SDL's resampler uses a "bandlimited interpolation" algorithm:
https://ccrma.stanford.edu/~jos/resample/
This code pre-generates the kaiser tables so we don't have to do this at
run time, at a cost of about 20 kilobytes of static data in SDL. This code
used to be part of SDL itself and generated the tables on the first use,
but that was expensive to produce on platforms without floating point
hardware.
*/
#include <stdio.h>
#include <math.h>
#define RESAMPLER_ZERO_CROSSINGS 5
#define RESAMPLER_BITS_PER_SAMPLE 16
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))
#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)
/* This is a "modified" bessel function, so you can't use POSIX j0() */
static double
bessel(const double x)
{
const double xdiv2 = x / 2.0;
double i0 = 1.0f;
double f = 1.0f;
int i = 1;
while (1) {
const double diff = pow(xdiv2, i * 2) / pow(f, 2);
if (diff < 1.0e-21f) {
break;
}
i0 += diff;
i++;
f *= (double) i;
}
return i0;
}
/* build kaiser table with cardinal sine applied to it, and array of differences between elements. */
static void
kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
{
const int lenm1 = tablelen - 1;
const int lenm1div2 = lenm1 / 2;
const double bessel_beta = bessel(beta);
int i;
table[0] = 1.0f;
for (i = 1; i < tablelen; i++) {
const double kaiser = bessel(beta * sqrt(1.0 - pow(((i - lenm1) / 2.0) / lenm1div2, 2.0))) / bessel_beta;
table[tablelen - i] = (float) kaiser;
}
for (i = 1; i < tablelen; i++) {
const float x = (((float) i) / ((float) RESAMPLER_SAMPLES_PER_ZERO_CROSSING)) * ((float) M_PI);
table[i] *= sinf(x) / x;
diffs[i - 1] = table[i] - table[i - 1];
}
diffs[lenm1] = 0.0f;
}
static float ResamplerFilter[RESAMPLER_FILTER_SIZE];
static float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE];
static void
PrepareResampleFilter(void)
{
/* if dB > 50, beta=(0.1102 * (dB - 8.7)), according to Matlab. */
const double dB = 80.0;
const double beta = 0.1102 * (dB - 8.7);
kaiser_and_sinc(ResamplerFilter, ResamplerFilterDifference, RESAMPLER_FILTER_SIZE, beta);
}
int main(void)
{
int i;
PrepareResampleFilter();
printf(
"/*\n"
" Simple DirectMedia Layer\n"
" Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>\n"
"\n"
" This software is provided 'as-is', without any express or implied\n"
" warranty. In no event will the authors be held liable for any damages\n"
" arising from the use of this software.\n"
"\n"
" Permission is granted to anyone to use this software for any purpose,\n"
" including commercial applications, and to alter it and redistribute it\n"
" freely, subject to the following restrictions:\n"
"\n"
" 1. The origin of this software must not be misrepresented; you must not\n"
" claim that you wrote the original software. If you use this software\n"
" in a product, an acknowledgment in the product documentation would be\n"
" appreciated but is not required.\n"
" 2. Altered source versions must be plainly marked as such, and must not be\n"
" misrepresented as being the original software.\n"
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
"/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c */\n"
"\n"
"#define RESAMPLER_ZERO_CROSSINGS %d\n"
"#define RESAMPLER_BITS_PER_SAMPLE %d\n"
"#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))\n"
"#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)\n"
"\n", RESAMPLER_ZERO_CROSSINGS, RESAMPLER_BITS_PER_SAMPLE
);
printf("static const float ResamplerFilter[RESAMPLER_FILTER_SIZE] = {\n");
printf(" %.9ff", ResamplerFilter[0]);
for (i = 0; i < RESAMPLER_FILTER_SIZE-1; i++) {
printf("%s%.9ff", ((i % 5) == 4) ? ",\n " : ", ", ResamplerFilter[i+1]);
}
printf("\n};\n\n");
printf("static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = {\n");
printf(" %.9ff", ResamplerFilterDifference[0]);
for (i = 0; i < RESAMPLER_FILTER_SIZE-1; i++) {
printf("%s%.9ff", ((i % 5) == 4) ? ",\n " : ", ", ResamplerFilterDifference[i+1]);
}
printf("\n};\n\n");
printf("/* vi: set ts=4 sw=4 expandtab: */\n\n");
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,80 +0,0 @@
#!/usr/bin/perl -w
# To use this script: symlink it to .git/hooks/pre-push, then "git push"
#
# This script is called by "git push" after it has checked the remote status,
# but before anything has been pushed. If this script exits with a non-zero
# status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
use warnings;
use strict;
my $remote = $ARGV[0];
my $url = $ARGV[1];
#print("remote: $remote\n");
#print("url: $url\n");
$url =~ s/\.git$//; # change myorg/myproject.git to myorg/myproject
$url =~ s#^git\@github\.com\:#https://github.com/#i;
my $commiturl = $url =~ /\Ahttps?:\/\/github.com\// ? "$url/commit/" : '';
my $z40 = '0000000000000000000000000000000000000000';
my $reported = 0;
while (<STDIN>) {
chomp;
my ($local_ref, $local_sha, $remote_ref, $remote_sha) = split / /;
#print("local_ref: $local_ref\n");
#print("local_sha: $local_sha\n");
#print("remote_ref: $remote_ref\n");
#print("remote_sha: $remote_sha\n");
my $range = '';
if ($remote_sha eq $z40) { # New branch, examine all commits
$range = $local_sha;
} else { # Update to existing branch, examine new commits
$range = "$remote_sha..$local_sha";
}
my $gitcmd = "git log --reverse --oneline --no-abbrev-commit '$range'";
open(GITPIPE, '-|', $gitcmd) or die("\n\n$0: Failed to run '$gitcmd': $!\n\nAbort push!\n\n");
while (<GITPIPE>) {
chomp;
if (/\A([a-fA-F0-9]+)\s+(.*?)\Z/) {
my $hash = $1;
my $msg = $2;
if (!$reported) {
print("\nCommits expected to be pushed:\n");
$reported = 1;
}
#print("hash: $hash\n");
#print("msg: $msg\n");
print("$commiturl$hash -- $msg\n");
} else {
die("$0: Unexpected output from '$gitcmd'!\n\nAbort push!\n\n");
}
}
die("\n\n$0: Failing exit code from running '$gitcmd'!\n\nAbort push!\n\n") if !close(GITPIPE);
}
print("\n") if $reported;
exit(0); # Let the push go forward.
# vi: set ts=4 sw=4 expandtab:

View File

@ -1,541 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2020-11-14.01; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-p) cpprog="$cpprog -p";;
-s) stripcmd=$stripprog;;
-S) backupsuffix="$2"
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

File diff suppressed because it is too large Load Diff

View File

@ -1,162 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2020-07-26.22; # UTC
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
IFS=" "" $nl"
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the 'mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because '.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "umask 22"
umask 22
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
echo "umask 22"
umask 22
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp=$pathcomp/
done
if test ! -z "$dirmode"; then
echo "chmod $dirmode $file"
chmod "$dirmode" "$file" || errstatus=$?
fi
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@ -1,61 +0,0 @@
#!/bin/bash
# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from
# amd64 Linux to NaCl.
# PLEASE NOTE that we have reports that SDL built with pepper_49 (current
# stable release as of November 10th, 2016) is broken. Please retest
# when something newer becomes stable and then decide if this was SDL's
# bug or NaCl's bug. --ryan.
export NACL_SDK_ROOT="/nacl_sdk/pepper_47"
TARBALL="$1"
if [ -z $1 ]; then
TARBALL=sdl-nacl.tar.xz
fi
OSTYPE=`uname -s`
if [ "$OSTYPE" != "Linux" ]; then
# !!! FIXME
echo "This only works on x86 or x64-64 Linux at the moment." 1>&2
exit 1
fi
if [ "x$MAKE" == "x" ]; then
NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
let NCPU=$NCPU+1
MAKE="make -j$NCPU"
fi
BUILDBOTDIR="nacl-buildbot"
PARENTDIR="$PWD"
set -e
set -x
rm -f $TARBALL
rm -rf $BUILDBOTDIR
mkdir -p $BUILDBOTDIR
pushd $BUILDBOTDIR
# !!! FIXME: ccache?
export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
../configure --host=pnacl --prefix=$PWD/nacl-sdl2-installed
$MAKE
$MAKE install
# Fix up a few things to a real install path
perl -w -pi -e "s#$PWD/nacl-sdl2-installed#/usr/local#g;" ./nacl-sdl2-installed/lib/libSDL2.la ./nacl-sdl2-installed/lib/pkgconfig/sdl2.pc ./nacl-sdl2-installed/bin/sdl2-config
mkdir -p ./usr
mv ./nacl-sdl2-installed ./usr/local
popd
tar -cJvvf $TARBALL -C $BUILDBOTDIR usr
rm -rf $BUILDBOTDIR
set +x
echo "All done. Final installable is in $TARBALL ...";

View File

@ -1,105 +0,0 @@
#!/bin/bash
if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
echo "Usage: ./naclbuild ~/nacl/pepper_35"
echo "This will build SDL for Native Client, and testgles2.c as a demo"
echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
echo "You can set env var SOURCES to select a different source file than testgles2.c"
exit 1
fi
if [ -n "$1" ]; then
NACL_SDK_ROOT="$1"
fi
CC=""
if [ -n "$2" ]; then
CC="$2"
fi
echo "Using SDK at $NACL_SDK_ROOT"
export NACL_SDK_ROOT="$NACL_SDK_ROOT"
export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
NCPUS="1"
case "$OSTYPE" in
darwin*)
NCPU=`sysctl -n hw.ncpu`
;;
linux*)
if [ -n `which nproc` ]; then
NCPUS=`nproc`
fi
;;
*);;
esac
CURDIR=`pwd -P`
SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
BUILDPATH="$SDLPATH/build/nacl"
TESTBUILDPATH="$BUILDPATH/test"
SDL2_STATIC="$BUILDPATH/build/.libs/libSDL2.a"
mkdir -p $BUILDPATH
mkdir -p $TESTBUILDPATH
if [ -z "$CC" ]; then
export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
fi
if [ -z "$AR" ]; then
export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
fi
if [ -z "$LD" ]; then
export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
fi
if [ -z "$RANLIB" ]; then
export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
fi
if [ -z "$SOURCES" ]; then
export SOURCES="$SDLPATH/test/testgles2.c"
fi
if [ ! -f "$CC" ]; then
echo "Could not find compiler at $CC"
exit 1
fi
cd $BUILDPATH
$SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
make -j$NCPUS CFLAGS="$CFLAGS -I./include"
make install
if [ ! -f "$SDL2_STATIC" ]; then
echo "Build failed! $SDL2_STATIC"
exit 1
fi
echo "Building test"
cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH
# Some tests need these resource files
cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH
cp -f $SDLPATH/test/*.wav $TESTBUILDPATH
cp -f $SDL2_STATIC $TESTBUILDPATH
# Copy user sources
_SOURCES=($SOURCES)
for src in "${_SOURCES[@]}"
do
cp $src $TESTBUILDPATH
done
export SOURCES="$SOURCES"
cd $TESTBUILDPATH
make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
echo
echo "Run the test with: "
echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
echo "Then visit http://localhost:8000 with Chrome"
cd $CURDIR

View File

@ -1,58 +0,0 @@
#!/bin/bash
# This is the script buildbot.libsdl.org uses to cross-compile SDL2 from
# x86 Linux to Raspberry Pi.
# The final tarball can be unpacked in the root directory of a RPi,
# so the SDL2 install lands in /usr/local. Run ldconfig, and then
# you should be able to build and run SDL2-based software on your
# Pi. Standard configure scripts should be able to find SDL and
# build against it, and sdl2-config should work correctly on the
# actual device.
TARBALL="$1"
if [ -z $1 ]; then
TARBALL=sdl-raspberrypi.tar.xz
fi
OSTYPE=`uname -s`
if [ "$OSTYPE" != "Linux" ]; then
# !!! FIXME
echo "This only works on x86 or x64-64 Linux at the moment." 1>&2
exit 1
fi
if [ "x$MAKE" == "x" ]; then
NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
let NCPU=$NCPU+1
MAKE="make -j$NCPU"
fi
BUILDBOTDIR="buildbot"
PARENTDIR="$PWD"
set -e
set -x
rm -f $TARBALL
rm -rf $BUILDBOTDIR
mkdir -p $BUILDBOTDIR
pushd $BUILDBOTDIR
SYSROOT="/opt/rpi-sysroot"
export CC="ccache /opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux -L$SYSROOT/opt/vc/lib"
# -L$SYSROOT/usr/lib/arm-linux-gnueabihf"
# !!! FIXME: shouldn't have to --disable-* things here.
../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd --disable-video-wayland
$MAKE
$MAKE install
# Fix up a few things to a real install path on a real Raspberry Pi...
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
mkdir -p ./usr
mv ./rpi-sdl2-installed ./usr/local
tar -cJvvf $TARBALL usr
popd
set +x
echo "All done. Final installable is in $TARBALL ...";

View File

@ -1,48 +0,0 @@
#!/bin/sh
#
# Print the current source revision, if available
SDL_ROOT=$(dirname $0)/..
cd $SDL_ROOT
if [ -e ./VERSION.txt ]; then
cat ./VERSION.txt
exit 0
fi
major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
version="${major}.${minor}.${micro}"
if [ -x "$(command -v git)" ]; then
rev="$(git describe --tags --long 2>/dev/null)"
if [ -n "$rev" ]; then
# e.g. release-2.24.0-542-g96361fc47
# or release-2.24.1-5-g36b987dab
# or prerelease-2.23.2-0-gcb46e1b3f
echo "$rev"
exit 0
fi
rev="$(git describe --always --tags --long 2>/dev/null)"
if [ -n "$rev" ]; then
# Just a truncated sha1, e.g. 96361fc47.
# Turn it into e.g. 2.25.0-g96361fc47
echo "${version}-g${rev}"
exit 0
fi
fi
if [ -x "$(command -v p4)" ]; then
rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')"
if [ $? = 0 ]; then
# e.g. 2.25.0-p7511446
echo "${version}-p${rev}"
exit 0
fi
fi
# best we can do
echo "${version}-no-vcs"
exit 0

View File

@ -1,21 +0,0 @@
#!/bin/sh
#
# libtool assumes that the compiler can handle the -fPIC flag
# This isn't always true (for example, nasm can't handle it)
command=""
while [ $# -gt 0 ]; do
case "$1" in
-?PIC)
# Ignore -fPIC and -DPIC options
;;
-fno-common)
# Ignore -fPIC and -DPIC options
;;
*)
command="$command $1"
;;
esac
shift
done
echo $command
exec $command

View File

@ -1,192 +0,0 @@
#!/bin/sh
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: Zlib
set -eu
ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"
tests=0
failed=0
ok () {
tests=$(( tests + 1 ))
echo "ok - $*"
}
not_ok () {
tests=$(( tests + 1 ))
echo "not ok - $*"
failed=1
}
major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure.ac)
minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure.ac)
micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure.ac)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "configure.ac $version"
else
not_ok "configure.ac $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure)
minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure)
micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "configure $version"
else
not_ok "configure $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^set(SDL_MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
minor=$(sed -ne 's/^set(SDL_MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
micro=$(sed -ne 's/^set(SDL_MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "CMakeLists.txt $version"
else
not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/.*SDL_MAJOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
minor=$(sed -ne 's/.*SDL_MINOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
micro=$(sed -ne 's/.*SDL_MICRO_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "SDLActivity.java $version"
else
not_ok "android-project/app/src/main/java/org/libsdl/app/SDLActivity.java $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.os2)
minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.os2)
micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.os2)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "Makefile.os2 $version"
else
not_ok "Makefile.os2 $version disagrees with SDL_version.h $ref_version"
fi
major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.w32)
minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.w32)
micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.w32)
version="${major}.${minor}.${micro}"
if [ "$ref_version" = "$version" ]; then
ok "Makefile.w32 $version"
else
not_ok "Makefile.w32 $version disagrees with SDL_version.h $ref_version"
fi
tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/main/windows/version.rc | tr -d '\r')
ref_tuple="${ref_major},${ref_minor},${ref_micro},0"
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc FILEVERSION $tuple"
else
not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple"
fi
tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/main/windows/version.rc | tr -d '\r')
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc PRODUCTVERSION $tuple"
else
not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
fi
tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc FileVersion $tuple"
else
not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple"
fi
tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
if [ "$ref_tuple" = "$tuple" ]; then
ok "version.rc ProductVersion $tuple"
else
not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
fi
version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
if [ "$ref_version" = "$version" ]; then
ok "Info-Framework.plist CFBundleShortVersionString $version"
else
not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_version.h $ref_version"
fi
version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
if [ "$ref_version" = "$version" ]; then
ok "Info-Framework.plist CFBundleVersion $version"
else
not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
fi
# For simplicity this assumes we'll never break ABI before SDL 3.
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
case "$ref_minor" in
(*[02468])
major="$(( ref_minor * 100 + 1 ))"
minor="0"
;;
(*)
major="$(( ref_minor * 100 + ref_micro + 1 ))"
minor="0"
;;
esac
ref="${major}.${minor}.0
${major}.${minor}.0
${major}.${minor}.0
${major}.${minor}.0"
if [ "$ref" = "$dylib_compat" ]; then
ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat"
fi
dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
case "$ref_minor" in
(*[02468])
major="$(( ref_minor * 100 + 1 ))"
minor="$ref_micro"
;;
(*)
major="$(( ref_minor * 100 + ref_micro + 1 ))"
minor="0"
;;
esac
ref="${major}.${minor}.0
${major}.${minor}.0
${major}.${minor}.0
${major}.${minor}.0"
if [ "$ref" = "$dylib_cur" ]; then
ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent"
else
not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur"
fi
echo "1..$tests"
exit "$failed"

View File

@ -1,7 +0,0 @@
#!/bin/sh
find . -type f -exec grep -Il "Copyright" {} \; \
| grep -v \.git \
| while read file; do \
LC_ALL=C sed -b -i "s/\(.*Copyright.*\)[0-9]\{4\}\( *Sam Lantinga\)/\1`date +%Y`\2/" "$file"; \
done

View File

@ -1,92 +0,0 @@
#!/bin/sh
#set -x
cd `dirname $0`/..
ARGSOKAY=1
if [ -z $1 ]; then
ARGSOKAY=0
fi
if [ -z $2 ]; then
ARGSOKAY=0
fi
if [ -z $3 ]; then
ARGSOKAY=0
fi
if [ "x$ARGSOKAY" = "x0" ]; then
echo "USAGE: $0 <major> <minor> <patch>" 1>&2
exit 1
fi
MAJOR="$1"
MINOR="$2"
PATCH="$3"
NEWVERSION="$MAJOR.$MINOR.$PATCH"
echo "Updating version to '$NEWVERSION' ..."
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
DYVER=`expr $MINOR \* 100 + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
# Set compat to major.minor.0 by default.
perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
# non-zero patch?
if [ "x$PATCH" != "x0" ]; then
if [ `expr $MINOR % 2` = "0" ]; then
# If patch is not zero, but minor is even, it's a bugfix release.
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.'$PATCH'.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
else
# If patch is not zero, but minor is odd, it's a development prerelease.
DYVER=`expr $MINOR \* 100 + $PATCH + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
perl -w -pi -e 's/(DYLIB_COMPATIBILITY_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
fi
fi
perl -w -pi -e 's/\A(SDL_MAJOR_VERSION=)\d+/${1}'$MAJOR'/;' configure.ac
perl -w -pi -e 's/\A(SDL_MINOR_VERSION=)\d+/${1}'$MINOR'/;' configure.ac
perl -w -pi -e 's/\A(SDL_MICRO_VERSION=)\d+/${1}'$PATCH'/;' configure.ac
perl -w -pi -e 's/\A(set\(SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' CMakeLists.txt
perl -w -pi -e 's/\A(set\(SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' CMakeLists.txt
perl -w -pi -e 's/\A(set\(SDL_MICRO_VERSION\s+)\d+/${1}'$PATCH'/;' CMakeLists.txt
perl -w -pi -e 's/\A(.* SDL_MAJOR_VERSION = )\d+/${1}'$MAJOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
perl -w -pi -e 's/\A(.* SDL_MINOR_VERSION = )\d+/${1}'$MINOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
perl -w -pi -e 's/\A(.* SDL_MICRO_VERSION = )\d+/${1}'$PATCH'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
perl -w -pi -e 's/\A(MAJOR_VERSION\s*=\s*)\d+/${1}'$MAJOR'/;' Makefile.os2
perl -w -pi -e 's/\A(MINOR_VERSION\s*=\s*)\d+/${1}'$MINOR'/;' Makefile.os2
perl -w -pi -e 's/\A(MICRO_VERSION\s*=\s*)\d+/${1}'$PATCH'/;' Makefile.os2
perl -w -pi -e 's/\A(MAJOR_VERSION\s*=\s*)\d+/${1}'$MAJOR'/;' Makefile.w32
perl -w -pi -e 's/\A(MINOR_VERSION\s*=\s*)\d+/${1}'$MINOR'/;' Makefile.w32
perl -w -pi -e 's/\A(MICRO_VERSION\s*=\s*)\d+/${1}'$PATCH'/;' Makefile.w32
perl -w -pi -e 's/(\#define SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' include/SDL_version.h
perl -w -pi -e 's/(\#define SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' include/SDL_version.h
perl -w -pi -e 's/(\#define SDL_PATCHLEVEL\s+)\d+/${1}'$PATCH'/;' include/SDL_version.h
perl -w -pi -e 's/(FILEVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(PRODUCTVERSION\s+)\d+,\d+,\d+/${1}'$MAJOR','$MINOR','$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(VALUE "FileVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/main/windows/version.rc
perl -w -pi -e 's/(VALUE "ProductVersion", ")\d+, \d+, \d+/${1}'$MAJOR', '$MINOR', '$PATCH'/;' src/main/windows/version.rc
echo "Regenerating configure script with new version..."
./autogen.sh |grep -v 'Now you are ready to run ./configure'
echo "Running build-scripts/test-versioning.sh to verify changes..."
./build-scripts/test-versioning.sh
echo "All done."
echo "Run 'git diff' and make sure this looks correct, before 'git commit'."
exit 0

View File

@ -1,49 +0,0 @@
#!/bin/sh
#
# Generate a header file with the current source revision
outdir=`pwd`
cd `dirname $0`
srcdir=..
header=$outdir/include/SDL_revision.h
dist=
vendor=
while [ "$#" -gt 0 ]; do
case "$1" in
(--dist)
dist=yes
shift
;;
(--vendor)
vendor="$2"
shift 2
;;
(*)
echo "$0: Unknown option: $1" >&2
exit 2
;;
esac
done
rev=`sh showrev.sh 2>/dev/null`
if [ "$rev" != "" ]; then
if [ -n "$dist" ]; then
echo "$rev" > "$outdir/VERSION.txt"
fi
echo "/* Generated by updaterev.sh, do not edit */" >"$header.new"
if [ -n "$vendor" ]; then
echo "#define SDL_VENDOR_INFO \"$vendor\"" >>"$header.new"
fi
echo "#ifdef SDL_VENDOR_INFO" >>"$header.new"
echo "#define SDL_REVISION \"SDL-$rev (\" SDL_VENDOR_INFO \")\"" >>"$header.new"
echo "#else" >>"$header.new"
echo "#define SDL_REVISION \"SDL-$rev\"" >>"$header.new"
echo "#endif" >>"$header.new"
echo "#define SDL_REVISION_NUMBER 0" >>"$header.new"
if diff $header $header.new >/dev/null 2>&1; then
rm "$header.new"
else
mv "$header.new" "$header"
fi
fi

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
@echo off
rem just a helper batch file for collecting up files and zipping them.
rem usage: windows-buildbot-zipper.bat <target> <slndir> <zipfilename>
rem must be run from root of SDL source tree.
IF EXIST %2\%1\Release GOTO okaydir
echo Please run from root of source tree after doing a Release build.
GOTO done
:okaydir
erase /q /f /s zipper
IF EXIST zipper GOTO zippermade
mkdir zipper
:zippermade
mkdir zipper\SDL
mkdir zipper\SDL\include
mkdir zipper\SDL\lib
copy include\*.h include\
copy %2\%1\Release\SDL2.dll zipper\SDL\lib\
copy %2\%1\Release\SDL2.lib zipper\SDL\lib\
copy %2\%1\Release\SDL2main.lib zipper\SDL\lib\
cd zipper
zip -9r ..\%3 SDL
cd ..
erase /q /f /s zipper
:done

View File

@ -1,26 +0,0 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix" FORCE)
project(buildSpvHeaders)
set(SOURCES
main.cpp
jsonToSpirv.cpp
header.cpp
jsoncpp/dist/jsoncpp.cpp)
set(HEADERS
jsonToSpirv.h
header.h
jsoncpp/dist/json/json.h)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=c++11)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-std=c++11)
endif()
add_executable(buildSpvHeaders ${SOURCES} ${HEADERS})
install(TARGETS buildSpvHeaders RUNTIME DESTINATION bin)

View File

@ -1,242 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2017-2020 Google LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and/or associated documentation files (the
# "Materials"), to deal in the Materials without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Materials, and to
# permit persons to whom the Materials are furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Materials.
#
# MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
# KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
# SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
# https://www.khronos.org/registry/
#
# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
"""Generates a C language headers from a SPIR-V JSON grammar file"""
import errno
import json
import os.path
import re
DEFAULT_COPYRIGHT="""Copyright (c) 2020 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
https://www.khronos.org/registry/
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
""".split('\n')
def make_path_to_file(f):
"""Makes all ancestor directories to the given file, if they
don't yet exist.
Arguments:
f: The file whose ancestor directories are to be created.
"""
dir = os.path.dirname(os.path.abspath(f))
try:
os.makedirs(dir)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(dir):
pass
else:
raise
class ExtInstGrammar:
"""The grammar for an extended instruction set"""
def __init__(self, name, copyright, instructions, operand_kinds, version = None, revision = None):
self.name = name
self.copyright = copyright
self.instructions = instructions
self.operand_kinds = operand_kinds
self.version = version
self.revision = revision
class LangGenerator:
"""A language-specific generator"""
def __init__(self):
self.upper_case_initial = re.compile('^[A-Z]')
pass
def comment_prefix(self):
return ""
def namespace_prefix(self):
return ""
def uses_guards(self):
return False
def cpp_guard_preamble(self):
return ""
def cpp_guard_postamble(self):
return ""
def enum_value(self, prefix, name, value):
if self.upper_case_initial.match(name):
use_name = name
else:
use_name = '_' + name
return " {}{} = {},".format(prefix, use_name, value)
def generate(self, grammar):
"""Returns a string that is the language-specific header for the given grammar"""
parts = []
if grammar.copyright:
parts.extend(["{}{}".format(self.comment_prefix(), f) for f in grammar.copyright])
parts.append('')
guard = 'SPIRV_UNIFIED1_{}_H_'.format(grammar.name)
if self.uses_guards:
parts.append('#ifndef {}'.format(guard))
parts.append('#define {}'.format(guard))
parts.append('')
parts.append(self.cpp_guard_preamble())
if grammar.version:
parts.append(self.const_definition(grammar.name, 'Version', grammar.version))
if grammar.revision is not None:
parts.append(self.const_definition(grammar.name, 'Revision', grammar.revision))
parts.append('')
if grammar.instructions:
parts.append(self.enum_prefix(grammar.name, 'Instructions'))
for inst in grammar.instructions:
parts.append(self.enum_value(grammar.name, inst['opname'], inst['opcode']))
parts.append(self.enum_end(grammar.name, 'Instructions'))
parts.append('')
if grammar.operand_kinds:
for kind in grammar.operand_kinds:
parts.append(self.enum_prefix(grammar.name, kind['kind']))
for e in kind['enumerants']:
parts.append(self.enum_value(grammar.name, e['enumerant'], e['value']))
parts.append(self.enum_end(grammar.name, kind['kind']))
parts.append('')
parts.append(self.cpp_guard_postamble())
if self.uses_guards:
parts.append('#endif // {}'.format(guard))
# Ensre the file ends in an end of line
parts.append('')
return '\n'.join(parts)
class CLikeGenerator(LangGenerator):
def uses_guards(self):
return True
def comment_prefix(self):
return "// "
def const_definition(self, prefix, var, value):
# Use an anonymous enum. Don't use a static const int variable because
# that can bloat binary size.
return 'enum {0}{1}{2}{3} = {4},{1}{2}{3}_BitWidthPadding = 0x7fffffff{5};'.format(
'{', '\n ', prefix, var, value, '\n}')
def enum_prefix(self, prefix, name):
return 'enum {}{} {}'.format(prefix, name, '{')
def enum_end(self, prefix, enum):
return ' {}{}Max = 0x7fffffff\n{};\n'.format(prefix, enum, '}')
def cpp_guard_preamble(self):
return '#ifdef __cplusplus\nextern "C" {\n#endif\n'
def cpp_guard_postamble(self):
return '#ifdef __cplusplus\n}\n#endif\n'
class CGenerator(CLikeGenerator):
pass
def main():
import argparse
parser = argparse.ArgumentParser(description='Generate language headers from a JSON grammar')
parser.add_argument('--extinst-name',
type=str, required=True,
help='The name to use in tokens')
parser.add_argument('--extinst-grammar', metavar='<path>',
type=str, required=True,
help='input JSON grammar file for extended instruction set')
parser.add_argument('--extinst-output-base', metavar='<path>',
type=str, required=True,
help='Basename of the language-specific output file.')
args = parser.parse_args()
with open(args.extinst_grammar) as json_file:
grammar_json = json.loads(json_file.read())
if 'copyright' in grammar_json:
copyright = grammar_json['copyright']
else:
copyright = DEFAULT_COPYRIGHT
if 'version' in grammar_json:
version = grammar_json['version']
else:
version = 0
if 'operand_kinds' in grammar_json:
operand_kinds = grammar_json['operand_kinds']
else:
operand_kinds = []
grammar = ExtInstGrammar(name = args.extinst_name,
copyright = copyright,
instructions = grammar_json['instructions'],
operand_kinds = operand_kinds,
version = version,
revision = grammar_json['revision'])
make_path_to_file(args.extinst_output_base)
with open(args.extinst_output_base + '.h', 'w') as f:
f.write(CGenerator().generate(grammar))
if __name__ == '__main__':
main()

View File

@ -1,28 +0,0 @@
#!/usr/bin/env python3
"""Generate C headers for certain extended instruction sets"""
import subprocess
import os
# Assume we are running from the tools/buildHeaders directory
os.chdir('../../include/spirv/unified1')
def mk_extinst(name, grammar_file):
"""Generate one C header from a grammar"""
script = '../../../tools/buildHeaders/bin/generate_language_headers.py'
subprocess.check_call(['python3',
script,
'--extinst-name=' + name,
'--extinst-grammar=' + grammar_file,
'--extinst-output-base=' + name])
subprocess.check_call(['dos2unix', name + '.h'])
mk_extinst('DebugInfo', 'extinst.debuginfo.grammar.json')
mk_extinst('OpenCLDebugInfo100', 'extinst.opencl.debuginfo.100.grammar.json')
mk_extinst('AMD_gcn_shader', 'extinst.spv-amd-gcn-shader.grammar.json')
mk_extinst('AMD_shader_ballot', 'extinst.spv-amd-shader-ballot.grammar.json')
mk_extinst('AMD_shader_explicit_vertex_parameter', 'extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json')
mk_extinst('AMD_shader_trinary_minmax', 'extinst.spv-amd-shader-trinary-minmax.grammar.json')
mk_extinst('NonSemanticDebugPrintf', 'extinst.nonsemantic.debugprintf.grammar.json')
mk_extinst('NonSemanticClspvReflection', 'extinst.nonsemantic.clspvreflection.grammar.json')

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
python3 bin/makeExtinstHeaders.py
cd ../../include/spirv/unified1
../../../tools/buildHeaders/build/install/bin/buildSpvHeaders -H spirv.core.grammar.json
dos2unix spirv.* spv.*

View File

@ -1,879 +0,0 @@
// Copyright (c) 2014-2020 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
// IN THE MATERIALS.
//
// Print headers for SPIR-V in several languages.
//
// To change the header information, change the C++-built database in doc.*.
//
// Then, use "spriv -h <language>" - e.g, spriv.{h,hpp,lua,py,etc}:
// replace the auto-generated header, or "spirv -H" to generate all
// supported language headers to predefined names in the current directory.
//
#include <string>
#include <sstream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <memory>
#include <cctype>
#include <vector>
#include <utility>
#include <set>
#include "jsoncpp/dist/json/json.h"
#include "header.h"
#include "jsonToSpirv.h"
// snprintf and _snprintf are not quite the same, but close enough
// for our use.
#ifdef _MSC_VER
#pragma warning(disable:4996)
#define snprintf _snprintf
#endif
// This file converts SPIR-V definitions to an internal JSON
// representation, and then generates language specific
// data from that single internal form.
// Initially, the internal form is created from C++ data,
// though this can be changed to a JSON master in time.
namespace {
class TPrinter {
protected:
TPrinter();
static const int DocMagicNumber = 0x07230203;
static const int DocVersion = 0x00010600;
static const int DocRevision = 1;
#define DocRevisionString "1"
static const std::string DocCopyright;
static const std::string DocComment1;
static const std::string DocComment2;
enum enumStyle_t {
enumNoMask,
enumCount,
enumShift,
enumMask,
enumHex,
};
static std::string styleStr(enumStyle_t s) {
return s == enumShift ? "Shift" :
s == enumMask ? "Mask" : "";
}
friend std::ostream& operator<<(std::ostream&, const TPrinter&);
virtual void printAll(std::ostream&) const;
virtual void printComments(std::ostream&) const;
virtual void printPrologue(std::ostream&) const { }
virtual void printDefs(std::ostream&) const;
virtual void printEpilogue(std::ostream&) const { }
virtual void printMeta(std::ostream&) const;
virtual void printTypes(std::ostream&) const { }
virtual void printHasResultType(std::ostream&) const { };
virtual std::string escapeComment(const std::string& s) const;
// Default printComments() uses these comment strings
virtual std::string commentBeg() const { return ""; }
virtual std::string commentEnd(bool isLast) const { return ""; }
virtual std::string commentBOL() const { return ""; }
virtual std::string commentEOL(bool isLast) const { return ""; }
typedef std::pair<unsigned, std::string> valpair_t;
// for printing enum values
virtual std::string enumBeg(const std::string&, enumStyle_t) const { return ""; }
virtual std::string enumEnd(const std::string&, enumStyle_t, bool isLast = false) const {
return "";
}
virtual std::string enumFmt(const std::string&, const valpair_t&,
enumStyle_t, bool isLast = false) const {
return "";
}
virtual std::string maxEnumFmt(const std::string&, const valpair_t&,
enumStyle_t) const {
return "";
}
virtual std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast = false) const {
return "";
}
std::vector<valpair_t> getSortedVals(const Json::Value&) const;
virtual std::string indent(int count = 1) const {
return std::string(count * 4, ' '); // default indent level = 4
}
static std::string fmtNum(const char* fmt, unsigned val) {
char buff[16]; // ample for 8 hex digits + 0x
snprintf(buff, sizeof(buff), fmt, val);
buff[sizeof(buff)-1] = '\0'; // MSVC doesn't promise null termination
return buff;
}
static std::string fmtStyleVal(unsigned v, enumStyle_t style);
// If the enum value name would start with a sigit, prepend the enum name.
// E.g, "3D" -> "Dim3D".
static std::string prependIfDigit(const std::string& ename, const std::string& vname) {
return (std::isdigit(vname[0]) ? ename : std::string("")) + vname;
}
void addComment(Json::Value& node, const std::string& str);
Json::Value spvRoot; // JSON SPIR-V data
};
// Format value as mask or value
std::string TPrinter::fmtStyleVal(unsigned v, enumStyle_t style)
{
switch (style) {
case enumMask:
return fmtNum("0x%08x", 1<<v);
case enumHex:
return fmtNum("0x%08x", v);
default:
return std::to_string(v);
}
}
const std::string TPrinter::DocCopyright =
"Copyright (c) 2014-2020 The Khronos Group Inc.\n"
"\n"
"Permission is hereby granted, free of charge, to any person obtaining a copy\n"
"of this software and/or associated documentation files (the \"Materials\"),\n"
"to deal in the Materials without restriction, including without limitation\n"
"the rights to use, copy, modify, merge, publish, distribute, sublicense,\n"
"and/or sell copies of the Materials, and to permit persons to whom the\n"
"Materials are furnished to do so, subject to the following conditions:\n"
"\n"
"The above copyright notice and this permission notice shall be included in\n"
"all copies or substantial portions of the Materials.\n"
"\n"
"MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS\n"
"STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND\n"
"HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ \n"
"\n"
"THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n"
"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n"
"THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n"
"FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS\n"
"IN THE MATERIALS.\n";
const std::string TPrinter::DocComment1 =
"This header is automatically generated by the same tool that creates\n"
"the Binary Section of the SPIR-V specification.\n";
const std::string TPrinter::DocComment2 =
"Enumeration tokens for SPIR-V, in various styles:\n"
" C, C++, C++11, JSON, Lua, Python, C#, D, Beef\n"
"\n"
"- C will have tokens with a \"Spv\" prefix, e.g.: SpvSourceLanguageGLSL\n"
"- C++ will have tokens in the \"spv\" name space, e.g.: spv::SourceLanguageGLSL\n"
"- C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL\n"
"- Lua will use tables, e.g.: spv.SourceLanguage.GLSL\n"
"- Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL']\n"
"- C# will use enum classes in the Specification class located in the \"Spv\" namespace,\n"
" e.g.: Spv.Specification.SourceLanguage.GLSL\n"
"- D will have tokens under the \"spv\" module, e.g: spv.SourceLanguage.GLSL\n"
"- Beef will use enum classes in the Specification class located in the \"Spv\" namespace,\n"
" e.g.: Spv.Specification.SourceLanguage.GLSL\n"
"\n"
"Some tokens act like mask values, which can be OR'd together,\n"
"while others are mutually exclusive. The mask-like ones have\n"
"\"Mask\" in their name, and a parallel enum that has the shift\n"
"amount (1 << x) for each corresponding enumerant.\n";
// Construct
TPrinter::TPrinter()
{
Json::Value& meta = spvRoot["spv"]["meta"];
Json::Value& enums = spvRoot["spv"]["enum"];
meta["MagicNumber"] = DocMagicNumber;
meta["Version"] = DocVersion;
meta["Revision"] = DocRevision;
meta["OpCodeMask"] = 0xffff;
meta["WordCountShift"] = 16;
int commentId = 0;
addComment(meta["Comment"][commentId++], DocCopyright);
addComment(meta["Comment"][commentId++], DocComment1);
addComment(meta["Comment"][commentId++], DocComment2);
for (int e = spv::OperandSource; e < spv::OperandOpcode; ++e) {
auto& enumSet = spv::OperandClassParams[e];
const bool mask = enumSet.bitmask;
const std::string enumName = enumSet.codeName;
for (auto& enumRow : enumSet) {
std::string name = enumRow.name;
enums[e - spv::OperandSource]["Values"][name] = enumRow.value;
}
enums[e - spv::OperandSource]["Type"] = mask ? "Bit" : "Value";
enums[e - spv::OperandSource]["Name"] = enumName;
}
// Instructions are in their own different table
{
auto& entry = enums[spv::OperandOpcode - spv::OperandSource];
for (auto& enumRow : spv::InstructionDesc) {
std::string name = enumRow.name;
entry["Values"][name] = enumRow.value;
}
entry["Type"] = "Value";
entry["Name"] = "Op";
}
}
// Create comment
void TPrinter::addComment(Json::Value& node, const std::string& str)
{
std::istringstream cstream(str);
std::string cline;
int line = 0;
while (std::getline(cstream, cline)) // fmt each line
node[line++] = cline;
}
// Return a list of values sorted by enum value. The std::vector
// returned by value is okay in c++11 due to move semantics.
std::vector<TPrinter::valpair_t>
TPrinter::getSortedVals(const Json::Value& p) const
{
std::vector<valpair_t> values;
for (auto e = p.begin(); e != p.end(); ++e)
values.push_back(valpair_t(e->asUInt(), e.name()));
// Use a stable sort because we might have aliases, e.g.
// SubgropuBallot (might be in future core) vs. SubgroupBallotKHR.
std::stable_sort(values.begin(), values.end());
return values;
}
// Escape comment characters if needed
std::string TPrinter::escapeComment(const std::string& s) const { return s; }
// Format comments in language specific way
void TPrinter::printComments(std::ostream& out) const
{
const int commentCount = spvRoot["spv"]["meta"]["Comment"].size();
int commentNum = 0;
for (const auto& comment : spvRoot["spv"]["meta"]["Comment"]) {
out << commentBeg();
for (int line = 0; line < int(comment.size()); ++line)
out << commentBOL() << escapeComment(comment[line].asString()) <<
commentEOL((line+1) == comment.size()) << std::endl;
out << commentEnd(++commentNum == commentCount) << std::endl;
}
}
// Format header metadata
void TPrinter::printMeta(std::ostream& out) const
{
const Json::Value& meta = spvRoot["spv"]["meta"];
const auto print = [&](const char* name, const char* fmt, bool isLast) {
out << fmtConstInt(meta[name].asUInt(), name, fmt, isLast);
};
print("MagicNumber", "0x%08lx", false);
print("Version", "0x%08lx", false);
print("Revision", "%d", false);
print("OpCodeMask", "0x%04x", false);
print("WordCountShift", "%d", true);
}
// Format value definitions in language specific way
void TPrinter::printDefs(std::ostream& out) const
{
const Json::Value& enums = spvRoot["spv"]["enum"];
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const bool isMask = (*opClass)["Type"].asString() == "Bit";
const auto opName = (*opClass)["Name"].asString();
const auto opPrefix = opName == "Op" ? "" : opName;
for (enumStyle_t style = (isMask ? enumShift : enumCount);
style <= (isMask ? enumMask : enumCount); style = enumStyle_t(int(style)+1)) {
out << enumBeg(opName, style);
if (style == enumMask)
out << enumFmt(opPrefix, valpair_t(0, "MaskNone"), enumNoMask);
const auto sorted = getSortedVals((*opClass)["Values"]);
std::string maxEnum = maxEnumFmt(opName, valpair_t(0x7FFFFFFF, "Max"), enumHex);
bool printMax = (style != enumMask && maxEnum.size() > 0);
for (const auto& v : sorted)
out << enumFmt(opPrefix, v, style, !printMax && v.second == sorted.back().second);
if (printMax)
out << maxEnum;
auto nextOpClass = opClass;
out << enumEnd(opName, style, ++nextOpClass == enums.end());
}
}
}
void TPrinter::printAll(std::ostream& out) const
{
printComments(out);
printPrologue(out);
printTypes(out);
printMeta(out);
printDefs(out);
printHasResultType(out);
printEpilogue(out);
}
// Stream entire header to output
std::ostream& operator<<(std::ostream& out, const TPrinter &p)
{
p.printAll(out);
return out;
}
// JSON printer. Rather than use the default printer, we supply our own so
// we can control the printing order within various containers.
class TPrinterJSON final : public TPrinter {
private:
void printPrologue(std::ostream& out) const override { out << "{\n" + indent() + "\"spv\":\n" + indent() + "{\n"; }
void printEpilogue(std::ostream& out) const override { out << indent() + "}\n}\n"; }
std::string escapeComment(const std::string& s) const override {
std::string newStr;
for (auto c : s) {
if (c == '"') {
newStr += '\\';
newStr += c;
} else {
newStr += c;
}
}
return newStr;
}
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override {
return indent(3) + '"' + name + "\": " + fmtNum("%d", val) + (isLast ? "\n" : ",\n");
}
void printMeta(std::ostream& out) const override
{
out << indent(2) + "\"meta\":\n" + indent(2) + "{\n";
printComments(out);
TPrinter::printMeta(out);
out << indent(2) + "},\n";
}
std::string commentBeg() const override { return indent(4) + "[\n"; }
std::string commentEnd(bool isLast) const override { return indent(4) + (isLast ? "]" : "],"); }
std::string commentBOL() const override { return indent(5) + '"'; }
std::string commentEOL(bool isLast) const override { return (isLast ? "\"" : "\","); }
void printComments(std::ostream& out) const override
{
out << indent(3) + "\"Comment\":\n" + indent(3) + "[\n";
TPrinter::printComments(out);
out << indent(3) + "],\n";
}
void printDefs(std::ostream& out) const override
{
out << indent(2) + "\"enum\":\n" + indent(2) + "[\n";
TPrinter::printDefs(out);
out << indent(2) + "]\n";
}
void printAll(std::ostream& out) const override
{
printPrologue(out);
printMeta(out);
printDefs(out);
printEpilogue(out);
}
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
if (style == enumMask)
return "";
return indent(3) + "{\n" +
indent(4) + "\"Name\": \"" + s + "\",\n" +
indent(4) + "\"Type\": " + (style == enumShift ? "\"Bit\"" : "\"Value\"") + ",\n" +
indent(4) + "\"Values\":\n" +
indent(4) + "{\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
if (style == enumMask)
return "";
return indent(4) + "}\n" +
indent(3) + "}" + (isLast ? "" : ",") + "\n";
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
if (style == enumMask || style == enumNoMask)
return "";
return indent(5) + '"' + prependIfDigit(s, v.second) + "\": " + fmtNum("%d", v.first) +
(isLast ? "\n" : ",\n");
}
};
// base for C and C++
class TPrinterCBase : public TPrinter {
protected:
virtual void printPrologue(std::ostream& out) const override {
out << "#ifndef spirv_" << headerGuardSuffix() << std::endl
<< "#define spirv_" << headerGuardSuffix() << std::endl
<< std::endl;
}
void printMeta(std::ostream& out) const override {
out << "#define SPV_VERSION 0x" << std::hex << DocVersion << std::dec << "\n";
out << "#define SPV_REVISION " << DocRevision << "\n";
out << "\n";
return TPrinter::printMeta(out);
}
virtual void printEpilogue(std::ostream& out) const override {
out << "#endif" << std::endl;
}
virtual void printTypes(std::ostream& out) const override {
out << "typedef unsigned int " << pre() << "Id;\n\n";
}
virtual std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override
{
return std::string("static const unsigned int ") + pre() + name +
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
}
virtual std::string pre() const { return ""; } // C name prefix
virtual std::string headerGuardSuffix() const = 0;
virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const { return pre() + name; }
virtual void printHasResultType(std::ostream& out) const override
{
const Json::Value& enums = spvRoot["spv"]["enum"];
std::set<unsigned> seenValues;
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const auto opName = (*opClass)["Name"].asString();
if (opName != "Op") {
continue;
}
out << "#ifdef SPV_ENABLE_UTILITY_CODE" << std::endl;
out << "#ifndef __cplusplus" << std::endl;
out << "#include <stdbool.h>" << std::endl;
out << "#endif" << std::endl;
out << "inline void " << pre() << "HasResultAndType(" << pre() << opName << " opcode, bool *hasResult, bool *hasResultType) {" << std::endl;
out << " *hasResult = *hasResultType = false;" << std::endl;
out << " switch (opcode) {" << std::endl;
out << " default: /* unknown opcode */ break;" << std::endl;
for (auto& inst : spv::InstructionDesc) {
// Filter out duplicate enum values, which would break the switch statement.
// These are probably just extension enums promoted to core.
if (seenValues.find(inst.value) != seenValues.end()) {
continue;
}
seenValues.insert(inst.value);
std::string name = inst.name;
out << " case " << fmtEnumUse("Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl;
}
out << " }" << std::endl;
out << "}" << std::endl;
out << "#endif /* SPV_ENABLE_UTILITY_CODE */" << std::endl << std::endl;
}
}
};
// C printer
class TPrinterC final : public TPrinterCBase {
private:
std::string commentBeg() const override { return "/*\n"; }
std::string commentEnd(bool isLast) const override { return "*/\n"; }
std::string commentBOL() const override { return "** "; }
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return std::string("typedef enum ") + pre() + s + styleStr(style) + "_ {\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return "} " + pre() + s + styleStr(style) + ";\n\n";
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent() + pre() + s + v.second + styleStr(style) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
std::string maxEnumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style) const override {
return enumFmt(s, v, style, true);
}
std::string pre() const override { return "Spv"; } // C name prefix
std::string headerGuardSuffix() const override { return "H"; }
};
// C++ printer
class TPrinterCPP : public TPrinterCBase {
private:
void printPrologue(std::ostream& out) const override {
TPrinterCBase::printPrologue(out);
out << "namespace spv {\n\n";
}
void printEpilogue(std::ostream& out) const override {
const Json::Value& enums = spvRoot["spv"]["enum"];
// Create overloaded operator| for mask types
out << "// Overload operator| for mask bit combining\n\n";
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const bool isMask = (*opClass)["Type"].asString() == "Bit";
const auto opName = (*opClass)["Name"].asString();
if (isMask) {
const auto typeName = opName + styleStr(enumMask);
out << "inline " + typeName + " operator|(" + typeName + " a, " + typeName + " b) { return " +
typeName + "(unsigned(a) | unsigned(b)); }\n";
}
}
out << "\n} // end namespace spv\n\n";
out << "#endif // #ifndef spirv_" << headerGuardSuffix() << std::endl;
}
std::string commentBOL() const override { return "// "; }
virtual std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return std::string("enum ") + s + styleStr(style) + " {\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return "};\n\n";
}
virtual std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent() + s + v.second + styleStr(style) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
virtual std::string maxEnumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style) const override {
return enumFmt(s, v, style, true);
}
// The C++ and C++11 headers define types with the same name. So they
// should use the same header guard.
std::string headerGuardSuffix() const override { return "HPP"; }
std::string operators;
};
// C++11 printer (uses enum classes)
class TPrinterCPP11 final : public TPrinterCPP {
private:
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return std::string("enum class ") + s + styleStr(style) + " : unsigned {\n";
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent() + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
std::string maxEnumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style) const override {
return enumFmt(s, v, style, true);
}
// Add type prefix for scoped enum
virtual std::string fmtEnumUse(const std::string& opPrefix, const std::string& name) const override { return opPrefix + "::" + name; }
std::string headerGuardSuffix() const override { return "HPP"; }
};
// LUA printer
class TPrinterLua final : public TPrinter {
private:
void printPrologue(std::ostream& out) const override { out << "spv = {\n"; }
void printEpilogue(std::ostream& out) const override { out << "}\n"; }
std::string commentBOL() const override { return "-- "; }
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return indent() + s + styleStr(style) + " = {\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return indent() + "},\n\n";
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent(2) + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
virtual std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override
{
return indent() + name + " = " + fmtNum(fmt, val) + (isLast ? ",\n\n" : ",\n");
}
};
// Python printer
class TPrinterPython final : public TPrinter {
private:
void printPrologue(std::ostream& out) const override { out << "spv = {\n"; }
void printEpilogue(std::ostream& out) const override { out << "}\n"; }
std::string commentBOL() const override { return "# "; }
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return indent() + "'" + s + styleStr(style) + "'" + " : {\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return indent() + "},\n\n";
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent(2) + "'" + prependIfDigit(s, v.second) + "'" + " : " + fmtStyleVal(v.first, style) + ",\n";
}
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override
{
return indent() + "'" + name + "'" + " : " + fmtNum(fmt, val) + (isLast ? ",\n\n" : ",\n");
}
};
// C# printer
class TPrinterCSharp final : public TPrinter {
private:
std::string commentBOL() const override { return "// "; }
void printPrologue(std::ostream& out) const override {
out << "namespace Spv\n{\n\n";
out << indent() << "public static class Specification\n";
out << indent() << "{\n";
}
void printEpilogue(std::ostream& out) const override {
out << indent() << "}\n";
out << "}\n";
}
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return indent(2) + "public enum " + s + styleStr(style) + "\n" + indent(2) + "{\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return indent(2) + "}" + + (isLast ? "\n" : "\n\n");
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent(3) + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override {
return indent(2) + std::string("public const uint ") + name +
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
}
};
// D printer
class TPrinterD final : public TPrinter {
private:
std::string commentBeg() const override { return "/+\n"; }
std::string commentBOL() const override { return " + "; }
std::string commentEnd(bool isLast) const override { return " +/\n"; }
void printPrologue(std::ostream& out) const override {
out << "module spv;\n\n";
}
void printEpilogue(std::ostream& out) const override {
}
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return "enum " + s + styleStr(style) + " : uint\n{\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return std::string("}\n\n");
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent() + prependIfDigit("_", v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override {
return std::string("enum uint ") + name +
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
}
};
// Beef printer
class TPrinterBeef final : public TPrinter {
private:
std::string commentBOL() const override { return "// "; }
void printPrologue(std::ostream& out) const override {
out << "namespace Spv\n{\n";
out << indent() << "using System;\n\n";
out << indent() << "public static class Specification\n";
out << indent() << "{\n";
}
void printEpilogue(std::ostream& out) const override {
out << indent() << "}\n";
out << "}\n";
}
std::string enumBeg(const std::string& s, enumStyle_t style) const override {
return indent(2) + "[AllowDuplicates, CRepr] public enum " + s + styleStr(style) + "\n" + indent(2) + "{\n";
}
std::string enumEnd(const std::string& s, enumStyle_t style, bool isLast) const override {
return indent(2) + "}" + +(isLast ? "\n" : "\n\n");
}
std::string enumFmt(const std::string& s, const valpair_t& v,
enumStyle_t style, bool isLast) const override {
return indent(3) + prependIfDigit(s, v.second) + " = " + fmtStyleVal(v.first, style) + ",\n";
}
std::string fmtConstInt(unsigned val, const std::string& name,
const char* fmt, bool isLast) const override {
return indent(2) + std::string("public const uint32 ") + name +
" = " + fmtNum(fmt, val) + (isLast ? ";\n\n" : ";\n");
}
};
} // namespace
namespace spv {
void PrintAllHeaders()
{
// TODO: Once MSVC 2012 is no longer a factor, use brace initializers here
std::vector<std::pair<TLanguage, std::string>> langInfo;
langInfo.push_back(std::make_pair(ELangC, "spirv.h"));
langInfo.push_back(std::make_pair(ELangCPP, "spirv.hpp"));
langInfo.push_back(std::make_pair(ELangCPP11, "spirv.hpp11"));
langInfo.push_back(std::make_pair(ELangJSON, "spirv.json"));
langInfo.push_back(std::make_pair(ELangLua, "spirv.lua"));
langInfo.push_back(std::make_pair(ELangPython, "spirv.py"));
langInfo.push_back(std::make_pair(ELangCSharp, "spirv.cs"));
langInfo.push_back(std::make_pair(ELangD, "spv.d"));
langInfo.push_back(std::make_pair(ELangBeef, "spirv.bf"));
for (const auto& lang : langInfo) {
std::ofstream out(lang.second, std::ios::out);
if ((out.rdstate() & std::ifstream::failbit)) {
std::cerr << "Unable to open file: " << lang.second << std::endl;
} else {
PrintHeader(lang.first, out);
}
}
}
// Print header for given language to given output stream
void PrintHeader(TLanguage lang, std::ostream& out)
{
typedef std::unique_ptr<TPrinter> TPrinterPtr;
TPrinterPtr p;
switch (lang) {
case ELangC: p = TPrinterPtr(new TPrinterC); break;
case ELangCPP: p = TPrinterPtr(new TPrinterCPP); break;
case ELangCPP11: p = TPrinterPtr(new TPrinterCPP11); break;
case ELangJSON: p = TPrinterPtr(new TPrinterJSON); break;
case ELangLua: p = TPrinterPtr(new TPrinterLua); break;
case ELangPython: p = TPrinterPtr(new TPrinterPython); break;
case ELangCSharp: p = TPrinterPtr(new TPrinterCSharp); break;
case ELangD: p = TPrinterPtr(new TPrinterD); break;
case ELangBeef: p = TPrinterPtr(new TPrinterBeef); break;
case ELangAll: PrintAllHeaders(); break;
default:
std::cerr << "Unknown language." << std::endl;
return;
}
// Print the data in the requested format
if (p)
out << *p << std::endl;
// object is auto-deleted
}
} // namespace spv

View File

@ -1,55 +0,0 @@
// Copyright (c) 2014-2019 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
// IN THE MATERIALS.
//
// Print headers for SPIR-V in several languages.
//
#pragma once
#ifndef header
#define header
#include <iostream>
namespace spv {
// Languages supported
enum TLanguage {
ELangC, // C
ELangCPP, // C++03
ELangCPP11, // C++11
ELangJSON, // JSON
ELangLua, // Lua
ELangPython, // Python
ELangCSharp, // CSharp
ELangD, // D
ELangBeef, // Beef
ELangAll, // print headers in all languages to files
};
// Generate header for requested language
void PrintHeader(TLanguage, std::ostream&);
} // namespace spv
#endif // header

View File

@ -1,551 +0,0 @@
// Copyright (c) 2014-2020 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
// IN THE MATERIALS.
#include <assert.h>
#include <string.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <fstream>
#include "jsoncpp/dist/json/json.h"
#include "jsonToSpirv.h"
namespace spv {
// The set of objects that hold all the instruction/operand
// parameterization information.
InstructionValues InstructionDesc;
// The ordered list (in printing order) of printing classes
// (specification subsections).
PrintingClasses InstructionPrintingClasses;
// Note: There is no entry for OperandOpcode. Use InstructionDesc instead.
EnumDefinition OperandClassParams[OperandOpcode];
EnumValues SourceLanguageParams;
EnumValues ExecutionModelParams;
EnumValues AddressingParams;
EnumValues MemoryParams;
EnumValues ExecutionModeParams;
EnumValues StorageParams;
EnumValues SamplerAddressingModeParams;
EnumValues SamplerFilterModeParams;
EnumValues ImageFormatParams;
EnumValues ImageChannelOrderParams;
EnumValues ImageChannelDataTypeParams;
EnumValues ImageOperandsParams;
EnumValues FPFastMathParams;
EnumValues FPRoundingModeParams;
EnumValues FPDenormModeParams;
EnumValues FPOperationModeParams;
EnumValues QuantizationModesParams;
EnumValues OverflowModesParams;
EnumValues LinkageTypeParams;
EnumValues DecorationParams;
EnumValues BuiltInParams;
EnumValues DimensionalityParams;
EnumValues FuncParamAttrParams;
EnumValues AccessQualifierParams;
EnumValues GroupOperationParams;
EnumValues LoopControlParams;
EnumValues SelectionControlParams;
EnumValues FunctionControlParams;
EnumValues MemorySemanticsParams;
EnumValues MemoryAccessParams;
EnumValues ScopeParams;
EnumValues KernelEnqueueFlagsParams;
EnumValues KernelProfilingInfoParams;
EnumValues CapabilityParams;
EnumValues RayFlagsParams;
EnumValues RayQueryIntersectionParams;
EnumValues RayQueryCommittedIntersectionTypeParams;
EnumValues RayQueryCandidateIntersectionTypeParams;
EnumValues FragmentShadingRateParams;
EnumValues PackedVectorFormatParams;
std::pair<bool, std::string> ReadFile(const std::string& path)
{
std::ifstream fstream(path, std::ios::in);
if (fstream) {
std::string contents;
fstream.seekg(0, std::ios::end);
contents.reserve((unsigned int)fstream.tellg());
fstream.seekg(0, std::ios::beg);
contents.assign((std::istreambuf_iterator<char>(fstream)),
std::istreambuf_iterator<char>());
return std::make_pair(true, contents);
}
return std::make_pair(false, "");
}
struct ClassOptionality {
OperandClass type;
bool optional;
};
// Converts the |operandKind| and |quantifier| pair used to describe operands
// in the JSON grammar to OperandClass and optionality used in this repo.
ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, const std::string& quantifier)
{
assert(quantifier.empty() || quantifier == "?" || quantifier == "*");
if (operandKind == "IdRef") {
if (quantifier.empty())
return {OperandId, false};
else if (quantifier == "?")
return {OperandId, true};
else
return {OperandVariableIds, false};
} else if (operandKind == "LiteralInteger") {
if (quantifier.empty())
return {OperandLiteralNumber, false};
if (quantifier == "?")
return {OperandOptionalLiteral, true};
else
return {OperandVariableLiterals, false};
} else if (operandKind == "LiteralString") {
if (quantifier.empty())
return {OperandLiteralString, false};
else if (quantifier == "?")
return {OperandLiteralString, true};
else {
return {OperandOptionalLiteralStrings, false};
}
} else if (operandKind == "PairLiteralIntegerIdRef") {
// Used by OpSwitch in the grammar
return {OperandVariableLiteralId, false};
} else if (operandKind == "PairIdRefLiteralInteger") {
// Used by OpGroupMemberDecorate in the grammar
return {OperandVariableIdLiteral, false};
} else if (operandKind == "PairIdRefIdRef") {
// Used by OpPhi in the grammar
return {OperandVariableIds, false};
} else {
OperandClass type = OperandNone;
if (operandKind == "IdMemorySemantics" || operandKind == "MemorySemantics") {
type = OperandMemorySemantics;
} else if (operandKind == "IdScope" || operandKind == "Scope") {
type = OperandScope;
} else if (operandKind == "LiteralExtInstInteger") {
type = OperandLiteralNumber;
} else if (operandKind == "LiteralSpecConstantOpInteger") {
type = OperandLiteralNumber;
} else if (operandKind == "LiteralContextDependentNumber") {
type = OperandAnySizeLiteralNumber;
} else if (operandKind == "SourceLanguage") {
type = OperandSource;
} else if (operandKind == "ExecutionModel") {
type = OperandExecutionModel;
} else if (operandKind == "AddressingModel") {
type = OperandAddressing;
} else if (operandKind == "MemoryModel") {
type = OperandMemory;
} else if (operandKind == "ExecutionMode") {
type = OperandExecutionMode;
} else if (operandKind == "StorageClass") {
type = OperandStorage;
} else if (operandKind == "Dim") {
type = OperandDimensionality;
} else if (operandKind == "SamplerAddressingMode") {
type = OperandSamplerAddressingMode;
} else if (operandKind == "SamplerFilterMode") {
type = OperandSamplerFilterMode;
} else if (operandKind == "ImageFormat") {
type = OperandSamplerImageFormat;
} else if (operandKind == "ImageChannelOrder") {
type = OperandImageChannelOrder;
} else if (operandKind == "ImageChannelDataType") {
type = OperandImageChannelDataType;
} else if (operandKind == "FPRoundingMode") {
type = OperandFPRoundingMode;
} else if (operandKind == "FPDenormMode") {
type = OperandFPDenormMode;
} else if (operandKind == "FPOperationMode") {
type = OperandFPOperationMode;
} else if (operandKind == "QuantizationModes") {
type = OperandQuantizationModes;
} else if (operandKind == "OverflowModes") {
type = OperandOverflowModes;
} else if (operandKind == "LinkageType") {
type = OperandLinkageType;
} else if (operandKind == "AccessQualifier") {
type = OperandAccessQualifier;
} else if (operandKind == "FunctionParameterAttribute") {
type = OperandFuncParamAttr;
} else if (operandKind == "Decoration") {
type = OperandDecoration;
} else if (operandKind == "BuiltIn") {
type = OperandBuiltIn;
} else if (operandKind == "GroupOperation") {
type = OperandGroupOperation;
} else if (operandKind == "KernelEnqueueFlags") {
type = OperandKernelEnqueueFlags;
} else if (operandKind == "KernelProfilingInfo") {
type = OperandKernelProfilingInfo;
} else if (operandKind == "Capability") {
type = OperandCapability;
} else if (operandKind == "ImageOperands") {
type = OperandImageOperands;
} else if (operandKind == "FPFastMathMode") {
type = OperandFPFastMath;
} else if (operandKind == "SelectionControl") {
type = OperandSelect;
} else if (operandKind == "LoopControl") {
type = OperandLoop;
} else if (operandKind == "FunctionControl") {
type = OperandFunction;
} else if (operandKind == "MemoryAccess") {
type = OperandMemoryOperands;
} else if (operandKind == "RayFlags") {
type = OperandRayFlags;
} else if (operandKind == "RayQueryIntersection") {
type = OperandRayQueryIntersection;
} else if (operandKind == "RayQueryCommittedIntersectionType") {
type = OperandRayQueryCommittedIntersectionType;
} else if (operandKind == "RayQueryCandidateIntersectionType") {
type = OperandRayQueryCandidateIntersectionType;
} else if (operandKind == "FragmentShadingRate") {
type = OperandFragmentShadingRate;
} else if (operandKind == "PackedVectorFormat") {
type = OperandPackedVectorFormat;
}
if (type == OperandNone) {
std::cerr << "Unhandled operand kind found: " << operandKind << std::endl;
exit(1);
}
return {type, !quantifier.empty()};
}
}
bool IsTypeOrResultId(const std::string& str, bool* isType, bool* isResult)
{
if (str == "IdResultType")
return *isType = true;
if (str == "IdResult")
return *isResult = true;
return false;
}
// Given a number string, returns the position of the only bits set in the number.
// So it requires the number is a power of two.
unsigned int NumberStringToBit(const std::string& str)
{
char* parseEnd;
unsigned int value = (unsigned int)std::strtol(str.c_str(), &parseEnd, 16);
assert(!(value & (value - 1)) && "input number is not a power of 2");
unsigned int bit = 0;
for (; value; value >>= 1) ++bit;
return bit;
}
void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
{
// only do this once.
static bool initialized = false;
if (initialized)
return;
initialized = true;
// Read the JSON grammar file.
bool fileReadOk = false;
std::string content;
std::tie(fileReadOk, content) = ReadFile(jsonPath);
if (!fileReadOk) {
std::cerr << "Failed to read JSON grammar file: "
<< jsonPath << std::endl;
exit(1);
}
// Decode the JSON grammar file.
Json::Reader reader;
Json::Value root;
if (!reader.parse(content, root)) {
std::cerr << "Failed to parse JSON grammar:\n"
<< reader.getFormattedErrorMessages();
exit(1);
}
// Layouts for all instructions.
// A lambda for returning capabilities from a JSON object as strings.
const auto getCaps = [](const Json::Value& object) {
EnumCaps result;
const auto& caps = object["capabilities"];
if (!caps.empty()) {
assert(caps.isArray());
for (const auto& cap : caps) {
result.emplace_back(cap.asString());
}
}
return result;
};
// A lambda for returning extensions from a JSON object as strings.
const auto getExts = [](const Json::Value& object) {
Extensions result;
const auto& exts = object["extensions"];
if (!exts.empty()) {
assert(exts.isArray());
for (const auto& ext : exts) {
result.emplace_back(ext.asString());
}
}
return result;
};
// set up the printing classes
std::unordered_set<std::string> tags; // short-lived local for error checking below
const Json::Value printingClasses = root["instruction_printing_class"];
for (const auto& printingClass : printingClasses) {
if (printingClass["tag"].asString().size() > 0)
tags.insert(printingClass["tag"].asString()); // just for error checking
else
std::cerr << "Error: each instruction_printing_class requires a non-empty \"tag\"" << std::endl;
if (buildingHeaders || printingClass["tag"].asString() != "@exclude") {
InstructionPrintingClasses.push_back({printingClass["tag"].asString(),
printingClass["heading"].asString()});
}
}
// process the instructions
const Json::Value insts = root["instructions"];
unsigned maxOpcode = 0;
bool firstOpcode = true;
for (const auto& inst : insts) {
const auto printingClass = inst["class"].asString();
if (printingClass.size() == 0) {
std::cerr << "Error: " << inst["opname"].asString()
<< " requires a non-empty printing \"class\" tag" << std::endl;
}
if (!buildingHeaders && printingClass == "@exclude")
continue;
if (tags.find(printingClass) == tags.end()) {
std::cerr << "Error: " << inst["opname"].asString()
<< " requires a \"class\" declared as a \"tag\" in \"instruction printing_class\""
<< std::endl;
}
const auto opcode = inst["opcode"].asUInt();
const std::string name = inst["opname"].asString();
if (firstOpcode) {
maxOpcode = opcode;
firstOpcode = false;
} else {
if (maxOpcode > opcode) {
std::cerr << "Error: " << name
<< " is out of order. It follows the instruction with opcode " << maxOpcode
<< std::endl;
std::exit(1);
} else {
maxOpcode = opcode;
}
}
EnumCaps caps = getCaps(inst);
std::string version = inst["version"].asString();
std::string lastVersion = inst["lastVersion"].asString();
Extensions exts = getExts(inst);
OperandParameters operands;
bool defResultId = false;
bool defTypeId = false;
for (const auto& operand : inst["operands"]) {
const std::string kind = operand["kind"].asString();
const std::string quantifier = operand.get("quantifier", "").asString();
const std::string doc = operand.get("name", "").asString();
if (!IsTypeOrResultId(kind, &defTypeId, &defResultId)) {
const auto p = ToOperandClassAndOptionality(kind, quantifier);
operands.push(p.type, doc, p.optional);
}
}
InstructionDesc.emplace_back(
std::move(EnumValue(opcode, name,
std::move(caps), std::move(version), std::move(lastVersion), std::move(exts),
std::move(operands))),
printingClass, defTypeId, defResultId);
}
// Specific additional context-dependent operands
// Populate dest with EnumValue objects constructed from source.
const auto populateEnumValues = [&getCaps,&getExts](EnumValues* dest, const Json::Value& source, bool bitEnum) {
// A lambda for determining the numeric value to be used for a given
// enumerant in JSON form, and whether that value is a 0 in a bitfield.
auto getValue = [&bitEnum](const Json::Value& enumerant) {
std::pair<unsigned, bool> result{0u,false};
if (!bitEnum) {
result.first = enumerant["value"].asUInt();
} else {
const unsigned int bit = NumberStringToBit(enumerant["value"].asString());
if (bit == 0)
result.second = true;
else
result.first = bit - 1; // This is the *shift* amount.
}
return result;
};
unsigned maxValue = 0;
bool firstValue = true;
for (const auto& enumerant : source["enumerants"]) {
unsigned value;
bool skip_zero_in_bitfield;
std::tie(value, skip_zero_in_bitfield) = getValue(enumerant);
if (skip_zero_in_bitfield)
continue;
if (firstValue) {
maxValue = value;
firstValue = false;
} else {
if (maxValue > value) {
std::cerr << "Error: " << source["kind"] << " enumerant " << enumerant["enumerant"]
<< " is out of order. It has value " << value
<< " but follows the enumerant with value " << maxValue << std::endl;
std::exit(1);
} else {
maxValue = value;
}
}
EnumCaps caps(getCaps(enumerant));
std::string version = enumerant["version"].asString();
std::string lastVersion = enumerant["lastVersion"].asString();
Extensions exts(getExts(enumerant));
OperandParameters params;
const Json::Value& paramsJson = enumerant["parameters"];
if (!paramsJson.empty()) { // This enumerant has parameters.
assert(paramsJson.isArray());
for (const auto& param : paramsJson) {
const std::string kind = param["kind"].asString();
const std::string doc = param.get("name", "").asString();
const auto p = ToOperandClassAndOptionality(kind, ""); // All parameters are required!
params.push(p.type, doc);
}
}
dest->emplace_back(
value, enumerant["enumerant"].asString(),
std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(params));
}
};
const auto establishOperandClass = [&populateEnumValues](
const std::string& enumName, spv::OperandClass operandClass,
spv::EnumValues* enumValues, const Json::Value& operandEnum, const std::string& category) {
assert(category == "BitEnum" || category == "ValueEnum");
bool bitEnum = (category == "BitEnum");
populateEnumValues(enumValues, operandEnum, bitEnum);
OperandClassParams[operandClass].set(enumName, enumValues, bitEnum);
};
const Json::Value operandEnums = root["operand_kinds"];
for (const auto& operandEnum : operandEnums) {
const std::string enumName = operandEnum["kind"].asString();
const std::string category = operandEnum["category"].asString();
if (enumName == "SourceLanguage") {
establishOperandClass(enumName, OperandSource, &SourceLanguageParams, operandEnum, category);
} else if (enumName == "Decoration") {
establishOperandClass(enumName, OperandDecoration, &DecorationParams, operandEnum, category);
} else if (enumName == "ExecutionMode") {
establishOperandClass(enumName, OperandExecutionMode, &ExecutionModeParams, operandEnum, category);
} else if (enumName == "Capability") {
establishOperandClass(enumName, OperandCapability, &CapabilityParams, operandEnum, category);
} else if (enumName == "AddressingModel") {
establishOperandClass(enumName, OperandAddressing, &AddressingParams, operandEnum, category);
} else if (enumName == "MemoryModel") {
establishOperandClass(enumName, OperandMemory, &MemoryParams, operandEnum, category);
} else if (enumName == "MemorySemantics") {
establishOperandClass(enumName, OperandMemorySemantics, &MemorySemanticsParams, operandEnum, category);
} else if (enumName == "ExecutionModel") {
establishOperandClass(enumName, OperandExecutionModel, &ExecutionModelParams, operandEnum, category);
} else if (enumName == "StorageClass") {
establishOperandClass(enumName, OperandStorage, &StorageParams, operandEnum, category);
} else if (enumName == "SamplerAddressingMode") {
establishOperandClass(enumName, OperandSamplerAddressingMode, &SamplerAddressingModeParams, operandEnum, category);
} else if (enumName == "SamplerFilterMode") {
establishOperandClass(enumName, OperandSamplerFilterMode, &SamplerFilterModeParams, operandEnum, category);
} else if (enumName == "ImageFormat") {
establishOperandClass(enumName, OperandSamplerImageFormat, &ImageFormatParams, operandEnum, category);
} else if (enumName == "ImageChannelOrder") {
establishOperandClass(enumName, OperandImageChannelOrder, &ImageChannelOrderParams, operandEnum, category);
} else if (enumName == "ImageChannelDataType") {
establishOperandClass(enumName, OperandImageChannelDataType, &ImageChannelDataTypeParams, operandEnum, category);
} else if (enumName == "ImageOperands") {
establishOperandClass(enumName, OperandImageOperands, &ImageOperandsParams, operandEnum, category);
} else if (enumName == "FPFastMathMode") {
establishOperandClass(enumName, OperandFPFastMath, &FPFastMathParams, operandEnum, category);
} else if (enumName == "FPRoundingMode") {
establishOperandClass(enumName, OperandFPRoundingMode, &FPRoundingModeParams, operandEnum, category);
} else if (enumName == "FPDenormMode") {
establishOperandClass(enumName, OperandFPDenormMode, &FPDenormModeParams, operandEnum, category);
} else if (enumName == "FPOperationMode") {
establishOperandClass(enumName, OperandFPOperationMode, &FPOperationModeParams, operandEnum, category);
} else if (enumName == "QuantizationModes") {
establishOperandClass(enumName, OperandQuantizationModes, &QuantizationModesParams, operandEnum, category);
} else if (enumName == "OverflowModes") {
establishOperandClass(enumName, OperandOverflowModes, &OverflowModesParams, operandEnum, category);
} else if (enumName == "LinkageType") {
establishOperandClass(enumName, OperandLinkageType, &LinkageTypeParams, operandEnum, category);
} else if (enumName == "FunctionParameterAttribute") {
establishOperandClass(enumName, OperandFuncParamAttr, &FuncParamAttrParams, operandEnum, category);
} else if (enumName == "AccessQualifier") {
establishOperandClass(enumName, OperandAccessQualifier, &AccessQualifierParams, operandEnum, category);
} else if (enumName == "BuiltIn") {
establishOperandClass(enumName, OperandBuiltIn, &BuiltInParams, operandEnum, category);
} else if (enumName == "SelectionControl") {
establishOperandClass(enumName, OperandSelect, &SelectionControlParams, operandEnum, category);
} else if (enumName == "LoopControl") {
establishOperandClass(enumName, OperandLoop, &LoopControlParams, operandEnum, category);
} else if (enumName == "FunctionControl") {
establishOperandClass(enumName, OperandFunction, &FunctionControlParams, operandEnum, category);
} else if (enumName == "Dim") {
establishOperandClass(enumName, OperandDimensionality, &DimensionalityParams, operandEnum, category);
} else if (enumName == "MemoryAccess") {
establishOperandClass(enumName, OperandMemoryOperands, &MemoryAccessParams, operandEnum, category);
} else if (enumName == "Scope") {
establishOperandClass(enumName, OperandScope, &ScopeParams, operandEnum, category);
} else if (enumName == "GroupOperation") {
establishOperandClass(enumName, OperandGroupOperation, &GroupOperationParams, operandEnum, category);
} else if (enumName == "KernelEnqueueFlags") {
establishOperandClass(enumName, OperandKernelEnqueueFlags, &KernelEnqueueFlagsParams, operandEnum, category);
} else if (enumName == "KernelProfilingInfo") {
establishOperandClass(enumName, OperandKernelProfilingInfo, &KernelProfilingInfoParams, operandEnum, category);
} else if (enumName == "RayFlags") {
establishOperandClass(enumName, OperandRayFlags, &RayFlagsParams, operandEnum, category);
} else if (enumName == "RayQueryIntersection") {
establishOperandClass(enumName, OperandRayQueryIntersection, &RayQueryIntersectionParams, operandEnum, category);
} else if (enumName == "RayQueryCommittedIntersectionType") {
establishOperandClass(enumName, OperandRayQueryCommittedIntersectionType, &RayQueryCommittedIntersectionTypeParams, operandEnum, category);
} else if (enumName == "RayQueryCandidateIntersectionType") {
establishOperandClass(enumName, OperandRayQueryCandidateIntersectionType, &RayQueryCandidateIntersectionTypeParams, operandEnum, category);
} else if (enumName == "FragmentShadingRate") {
establishOperandClass(enumName, OperandFragmentShadingRate, &FragmentShadingRateParams, operandEnum, category);
} else if (enumName == "PackedVectorFormat") {
establishOperandClass(enumName, OperandPackedVectorFormat, &PackedVectorFormatParams, operandEnum, category);
}
}
}
}; // end namespace spv

View File

@ -1,301 +0,0 @@
// Copyright (c) 2014-2020 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
// IN THE MATERIALS.
#pragma once
#ifndef JSON_TO_SPIRV
#define JSON_TO_SPIRV
#include <algorithm>
#include <string>
#include <vector>
#include <assert.h>
namespace spv {
// Reads the file in the given |path|. Returns true and the contents of the
// file on success; otherwise, returns false and an empty string.
std::pair<bool, std::string> ReadFile(const std::string& path);
// Fill in all the parameters
void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders);
// For parameterizing operands.
// The ordering here affects the printing order in the SPIR-V specification.
// Please add new operand classes at the end.
enum OperandClass {
OperandNone,
OperandId,
OperandVariableIds,
OperandOptionalLiteral,
OperandOptionalLiteralString,
OperandOptionalLiteralStrings,
OperandVariableLiterals,
OperandVariableIdLiteral,
OperandVariableLiteralId,
OperandAnySizeLiteralNumber,
OperandLiteralNumber,
OperandLiteralString,
OperandSource,
OperandExecutionModel,
OperandAddressing,
OperandMemory,
OperandExecutionMode,
OperandStorage,
OperandDimensionality,
OperandSamplerAddressingMode,
OperandSamplerFilterMode,
OperandSamplerImageFormat,
OperandImageChannelOrder,
OperandImageChannelDataType,
OperandImageOperands,
OperandFPFastMath,
OperandFPRoundingMode,
OperandLinkageType,
OperandAccessQualifier,
OperandFuncParamAttr,
OperandDecoration,
OperandBuiltIn,
OperandSelect,
OperandLoop,
OperandFunction,
OperandMemorySemantics,
OperandMemoryOperands,
OperandScope,
OperandGroupOperation,
OperandKernelEnqueueFlags,
OperandKernelProfilingInfo,
OperandCapability,
OperandRayFlags,
OperandRayQueryIntersection,
OperandRayQueryCommittedIntersectionType,
OperandRayQueryCandidateIntersectionType,
OperandFragmentShadingRate,
OperandFPDenormMode,
OperandFPOperationMode,
OperandQuantizationModes,
OperandOverflowModes,
OperandPackedVectorFormat,
OperandOpcode,
OperandCount
};
// For direct representation of the JSON grammar "instruction_printing_class".
struct PrintingClass {
std::string tag;
std::string heading;
};
using PrintingClasses = std::vector<PrintingClass>;
// Any specific enum can have a set of capabilities that allow it:
typedef std::vector<std::string> EnumCaps;
// A set of extensions.
typedef std::vector<std::string> Extensions;
// Parameterize a set of operands with their OperandClass(es) and descriptions.
class OperandParameters {
public:
OperandParameters() { }
void push(OperandClass oc, const std::string& d, bool opt = false)
{
opClass.push_back(oc);
desc.push_back(d);
optional.push_back(opt);
}
void setOptional();
OperandClass getClass(int op) const { return opClass[op]; }
const char* getDesc(int op) const { return desc[op].c_str(); }
bool isOptional(int op) const { return optional[op]; }
int getNum() const { return (int)opClass.size(); }
protected:
std::vector<OperandClass> opClass;
std::vector<std::string> desc;
std::vector<bool> optional;
};
// An ordered sequence of EValue. We'll preserve the order found in the
// JSON file. You can look up a value by enum or by name. If there are
// duplicate values, then take the first. We assume names are unique.
// The EValue must have an unsigned |value| field and a string |name| field.
template <typename EValue>
class EnumValuesContainer {
public:
using ContainerType = std::vector<EValue>;
using iterator = typename ContainerType::iterator;
using const_iterator = typename ContainerType::const_iterator;
EnumValuesContainer() {}
// Constructs an EValue in place as a new element at the end of the
// sequence.
template <typename... Args>
void emplace_back(Args&&... args) {
values.emplace_back(std::forward<Args>(args)...);
}
// Returns the first EValue in the sequence with the given value.
// More than one EValue might have the same value.
EValue& operator[](unsigned value) {
auto where = std::find_if(begin(), end(), [&value](const EValue& e) {
return value == e.value;
});
assert((where != end()) && "Could not find enum in the enum list");
return *where;
}
// gets *all* entries for the value, including the first one
void gatherAliases(unsigned value, std::vector<EValue*>& aliases) {
std::for_each(begin(), end(), [&](EValue& e) {
if (value == e.value)
aliases.push_back(&e);});
}
// Returns the EValue with the given name. We assume uniqueness
// by name.
EValue& at(std::string name) {
auto where = std::find_if(begin(), end(), [&name](const EValue& e) {
return name == e.name;
});
assert((where != end()) && "Could not find name in the enum list");
return *where;
}
iterator begin() { return values.begin(); }
iterator end() { return values.end(); }
private:
ContainerType values;
};
// A single enumerant value. Corresponds to a row in an enumeration table
// in the spec.
class EnumValue {
public:
EnumValue() : value(0), desc(nullptr) {}
EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps,
const std::string& the_firstVersion, const std::string& the_lastVersion,
Extensions&& the_extensions, OperandParameters&& the_operands) :
value(the_value), name(the_name), capabilities(std::move(the_caps)),
firstVersion(std::move(the_firstVersion)), lastVersion(std::move(the_lastVersion)),
extensions(std::move(the_extensions)), operands(std::move(the_operands)), desc(nullptr) { }
// For ValueEnum, the value from the JSON file.
// For BitEnum, the index of the bit position represented by this mask.
// (That is, what you shift 1 by to get the mask.)
unsigned value;
std::string name;
EnumCaps capabilities;
std::string firstVersion;
std::string lastVersion;
// A feature only be enabled by certain extensions.
// An empty list means the feature does not require an extension.
// Normally, only Capability enums are enabled by extension. In turn,
// other enums and instructions are enabled by those capabilities.
Extensions extensions;
OperandParameters operands;
const char* desc;
};
using EnumValues = EnumValuesContainer<EnumValue>;
// Parameterize a set of enumerants that form an enum
class EnumDefinition {
public:
EnumDefinition() :
desc(0), bitmask(false), enumValues(nullptr) { }
void set(const std::string& enumName, EnumValues* enumValuesArg, bool mask = false)
{
codeName = enumName;
bitmask = mask;
enumValues = enumValuesArg;
}
// Returns the first EnumValue in the sequence with the given value.
// More than one EnumValue might have the same value. Only valid
// if enumValues has been populated.
EnumValue& operator[](unsigned value) {
assert(enumValues != nullptr);
return (*enumValues)[value];
}
// Returns the name of the first EnumValue with the given value.
// Assumes enumValues has been populated.
const char* getName(unsigned value) {
return (*this)[value].name.c_str();
}
using iterator = EnumValues::iterator;
iterator begin() { return enumValues->begin(); }
iterator end() { return enumValues->end(); }
std::string codeName; // name to use when declaring headers for code
const char* desc;
bool bitmask; // true if these enumerants combine into a bitmask
EnumValues* enumValues; // parameters for each individual enumerant
};
// Parameterize an instruction's logical format, including its known set of operands,
// per OperandParameters above.
class InstructionValue : public EnumValue {
public:
InstructionValue(EnumValue&& e, const std::string& printClass, bool has_type, bool has_result)
: EnumValue(std::move(e)),
printingClass(printClass),
opDesc("TBD"),
typePresent(has_type),
resultPresent(has_result),
alias(this) { }
InstructionValue(const InstructionValue& v)
{
*this = v;
alias = this;
}
bool hasResult() const { return resultPresent != 0; }
bool hasType() const { return typePresent != 0; }
void setAlias(const InstructionValue& a) { alias = &a; }
const InstructionValue& getAlias() const { return *alias; }
bool isAlias() const { return alias != this; }
std::string printingClass;
const char* opDesc;
protected:
int typePresent : 1;
int resultPresent : 1;
const InstructionValue* alias; // correct only after discovering the aliases; otherwise points to this
};
using InstructionValues = EnumValuesContainer<InstructionValue>;
// Parameterization info for all instructions.
extern InstructionValues InstructionDesc;
extern PrintingClasses InstructionPrintingClasses;
// These hold definitions of the enumerants used for operands.
// This is indexed by OperandClass, but not including OperandOpcode.
extern EnumDefinition OperandClassParams[];
}; // end namespace spv
#endif // JSON_TO_SPIRV

View File

@ -1,255 +0,0 @@
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
/// It is intended to be used with #include "json/json-forwards.h"
/// This header provides forward declaration for all JsonCpp types.
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
/*
The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
conditions of the MIT License (see below), or 3) under the terms of dual
Public Domain/MIT License conditions described here, as they choose.
The MIT License is about as close to Public Domain as a license can get, and is
described in clear, concise terms at:
http://en.wikipedia.org/wiki/MIT_License
The full text of the MIT License follows:
========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
(END LICENSE TEXT)
The MIT license is compatible with both the GPL and commercial
software, affording one all of the rights of Public Domain with the
minor nuisance of being required to keep the above copyright notice
and license text in the source code. Note also that by accepting the
Public Domain "license" you can re-license your copy using whatever
license you like.
*/
// //////////////////////////////////////////////////////////////////////
// End of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
# define JSON_FORWARD_AMALGATED_H_INCLUDED
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
#define JSON_IS_AMALGAMATION
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
#ifndef JSON_USE_EXCEPTION
#define JSON_USE_EXCEPTION 1
#endif
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGAMATION
#ifdef JSON_IN_CPPTL
#include <cpptl/config.h>
#ifndef JSON_USE_CPPTL
#define JSON_USE_CPPTL 1
#endif
#endif
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
#if defined(_MSC_VER)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
#if defined(_MSC_VER)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#endif // ifdef JSON_IN_CPPTL
#if !defined(JSON_API)
#define JSON_API
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
// Microsoft Visual Studio 6 only support conversion from __int64 to double
// (no conversion from unsigned __int64).
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
// characters in the debug information)
// All projects I've ever seen with VS6 were using this globally (not bothering
// with pragma push/pop).
#pragma warning(disable : 4786)
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#elif defined(__clang__) && defined(__has_feature)
#if __has_feature(attribute_deprecated_with_message)
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
#endif
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
#endif
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef long long int Int64;
typedef unsigned long long int UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
#define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED

View File

@ -1,130 +0,0 @@
// Copyright (c) 2014-2019 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
// to deal in the Materials without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Materials, and to permit persons to whom the
// Materials are furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Materials.
//
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
// IN THE MATERIALS.
//#include <fstream>
#include <string>
#include <algorithm>
#include "jsonToSpirv.h"
#include "header.h"
// Command-line options
enum TOptions {
EOptionNone = 0x000,
EOptionPrintHeader = 0x008,
};
std::string jsonPath;
int Options;
spv::TLanguage Language;
void Usage()
{
printf("Usage: spirv option [file]\n"
"\n"
" -h <language> print header for given language to stdout, from one of:\n"
" C - C99 header\n"
" C++ - C++03 or greater header (also accepts C++03)\n"
" C++11 - C++11 or greater header\n"
" JSON - JSON format data\n"
" Lua - Lua module\n"
" Python - Python module (also accepts Py)\n"
" C# - C# module (also accepts CSharp)\n"
" D - D module\n"
" Beef - Beef module\n"
" -H print header in all supported languages to files in current directory\n"
);
}
std::string tolower_s(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
return s;
}
bool ProcessArguments(int argc, char* argv[])
{
argc--;
argv++;
for (; argc >= 1; argc--, argv++) {
if (argv[0][0] == '-') {
switch (argv[0][1]) {
case 'H':
Options |= EOptionPrintHeader;
Language = spv::ELangAll;
break;
case 'h': {
if (argc < 2)
return false;
Options |= EOptionPrintHeader;
const std::string language(tolower_s(argv[1]));
if (language == "c") {
Language = spv::ELangC;
} else if (language == "c++" || language == "c++03") {
Language = spv::ELangCPP;
} else if (language == "c++11") {
Language = spv::ELangCPP11;
} else if (language == "json") {
Language = spv::ELangJSON;
} else if (language == "lua") {
Language = spv::ELangLua;
} else if (language == "python" || language == "py") {
Language = spv::ELangPython;
} else if (language == "c#" || language == "csharp") {
Language = spv::ELangCSharp;
} else if (language == "d") {
Language = spv::ELangD;
} else if (language == "beef") {
Language = spv::ELangBeef;
} else
return false;
return true;
}
default:
return false;
}
} else {
jsonPath = std::string(argv[0]);
}
}
return true;
}
int main(int argc, char* argv[])
{
if (argc < 2 || ! ProcessArguments(argc, argv)) {
Usage();
return 1;
}
spv::jsonToSpirv(jsonPath, (Options & EOptionPrintHeader) != 0);
if (Options & EOptionPrintHeader)
spv::PrintHeader(Language, std::cout);
return 0;
}

View File

@ -1,32 +0,0 @@
{
// This is build task definition file for MS VisualStudio Code.
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello"
},
{
"label": "configure",
"type": "shell",
"command": "./bootstrap && ./configure"
},
{
"label": "build",
"type": "shell",
"command": "make -j4",
"problemMatcher": [
"$gcc"
]
},
{
"label": "clean",
"type": "shell",
"command": "make clean",
"problemMatcher": []
}
]
}