当前位置: 首页 > 工具软件 > vex > 使用案例 >

Houdini 学习文档 -VEX-编译器Vcc

季稳
2023-12-01

Vex compiler (vcc) Vex 编译器

Overview of how to use the VEX language compiler vcc and its pre-processor and pragma statements.

概述如何使用VEX语言编译器vcc及其预处理程序和pragma语句。

The vcc compiler compiles VEX source code into a form executable by Houdini. The VEX compiler (vcc) is capable of compiling VEX code, generating dialog scripts for VEX functions, and also giving quick help by listing the global variables and functions available in any given context.

vcc编译器将VEX源代码编译成Houdini可执行的形式。VEX编译器(vcc)能够编译VEX代码,为VEX函数生成对话脚本,并通过列出在任何给定上下文中可用的全局变量和函数来提供快速帮助。

Command-line options 命令行选项

Note

Most options have a short and a long form. The long form is shown in square brackets after the short form.

大多数选项有短表单和长表单。长表单在短表单后面的方括号中显示。

-h [--help]

Show help message for the compiler. 显示编译器的帮助消息。

Compiler options 编译器选项

-o [--vex-output] [file|-]

Specify that a VEX code output is required. If the filename given is 'stdout', then the output will be printed to the console. If none of --hda-output--otl-output, or --ds-output are specified, this option is implied. By default the output filename is constructed from the context function. If no context function is defined, then the input filename is used as a base. If multiple input files are given, then the filename argument will be ignored, and the output filename constructed from the aforementioned rules.

指定需要一个VEX代码输出。如果给出的文件名是“stdout”,那么输出将被打印到控制台。如果没有指定—hda-output、—otl-output或—ds-output,则隐含此选项。默认情况下,输出文件名由上下文函数构造。如果没有定义上下文函数,则使用输入文件名作为基础。如果给定多个输入文件,则会忽略filename参数,并根据上述规则构造输出文件名。

-d [--compile-all]

Compile all functions into the VEX code, even if they're not used by the context function, either directly or indirectly. This option is useful for doing syntax checking on include files.

将所有函数编译到VEX代码中,即使上下文函数没有直接或间接地使用它们。此选项用于对包含文件执行语法检查。

-z [--no-optimize]

Generate unoptimized VEX code. 生成未优化的VEX代码。

-V [--no-version-id]

Don’t embed a Houdini version identifier in the VEX code. 不要在VEX代码中嵌入Houdini版本标识符。

Preprocessor options 预处理器选项

-E [--parse-only]

Only parse the input files to the standard output. No compilation will take place.

只将输入文件解析为标准输出。不进行编译。

-D [--define] name[=value]

Define a macro for the pre-processor. If no value is given with the name, the name is defined as 1.

为预处理程序定义一个宏。如果名称没有指定值,则将名称定义为1。

-I [--include-dir] path

Add the path specified to the include path (the list of directories search for files referenced by the #include directive to the pre-processor). The standard Houdini include path is under vex/include.

将指定的路径添加到include路径(在预处理程序中搜索#include指令引用的文件的目录列表)。标准的Houdini include路径位于vex/include之下。

Diagnostic options 诊断选项

-w id[,id...]

Suppress printing of certain warnings and information messages. wlist is a comma-separated list of warning numbers to suppress.

禁止打印某些警告和信息消息。wlist是一个逗号分隔的要禁止的警告号列表。

-F [--Werror]

Treat all non-suppressed warnings as errors.

将所有未禁止的警告视为错误。

-e [--Werror-output] file

Redirect all diagnostic output to the filename given, rather than print them to the standard error output.

将所有诊断输出重定向到给定的文件名,而不是将它们打印到标准错误输出。

-q [--Wno-info]

Suppress informational messages. 禁止信息消息

-Q [--Werror-only]

Suppress informational and warning messages. Overrides --Wno-info. 禁止信息和警告消息。覆盖——Wno-info。

--fmessage-limit <N>

Set a maximum number of messages that will be printed before stopping. Set to 0 (the default) for no limit.

设置消息停止之前打印它的最大数量。设置为0(默认值),没有限制。

VEX Context options VEX上下文选项

-c [--context] name

If no context function is defined, this can be used to specify which VEX context to use when compiling the source(s).

如果没有定义上下文函数(主函数),则编译源文件时可以使用指定的VEX上下文函数。

-X [--list-context] context

Print out global variables and function signatures defined for the given VEX context. The argument value of contexts can be used to list all available VEX contexts.

打印为给定VEX上下文定义的全局变量和函数签名。上下文的参数值可用于列出所有可用的VEX上下文。

Asset options 资源选项

-L [--hda-append] [file|-]

Append a digital asset generated from the VEX source to the specified operator type library file. If the file doesn’t exist, it will be created.

将从VEX源生成的数字资产附加到指定的操作符类型库文件。如果文件不存在,将创建它。

-l [--hda-output] [file|-]

Write a digital asset definition for the context function to the specified operator type library file. If the library file already exists, it will be overwritten.

将上下文函数的数字资产定义写入指定的操作符类型库文件。如果库文件已经存在,它将被覆盖。

-K [--hda-vex-section] name

Store the generated VEX code in the given section name in the HDA, rather than the standard section name for the given VEX context.

将生成的VEX代码存储在HDA中的给定节名中,而不是存储在给定VEX上下文的标准节名中。

-a [--hda-dialog-script] file

Use the parameter definitions in the given file instead of the ones automatically generated from the VEX source. The dialog script’s operator definition will still be taken from the VEX source.

使用给定文件中的参数定义,而不是从VEX源自动生成的参数定义。对话脚本的操作符定义仍然取自VEX源。

-U [--hda-dialog-script-only]

Only embed the dialog script into the OTL. No VEX code will be added.

只将对话脚本嵌入到OTL中。没有VEX代码将被添加。

-n [--op-name] name

Use the given name as the name for the operator. This overrides any #pragma opname statement in the code.

使用给定的名称作为操作符的名称。这将覆盖代码中的任何#pragma opname语句。

-S [--op-script-name] name

Use the given name as the script name for the operator. This overrides any #pragma opscript statement in the code.

使用给定的名称作为操作符的脚本名称。这将覆盖代码中的任何#pragma opscript语句。

-N [--op-label] name

Use the given name as the UI label for the operator. This overides any #pragma oplabel statement in the code.

使用给定的名称作为操作符的UI标签。这将覆盖代码中的任何#pragma oplabel语句。

-C [--op-icon] name

Use the given name as the icon to use for the operator. This overides any #pragma opicon statement in the code.

使用给定的名称作为操作符使用的图标。这将覆盖代码中的任何#pragma opicon语句。

-t [--op-min-inputs] N

Set the minimum number of inputs for the operator. This overides any #pragma opmininputs statement in the code. The minimum input value will be adjusted to fit the operator type being generated.

设置操作符的最小输入数。这将覆盖代码中的任何#pragma opmininput语句。最小输入值将被调整以适合正在生成的操作符类型。

-T [--op-max-inputs] N

Set the maximum number of inputs for the operator. This overides any #pragma opmaxinputs statement in the code. The maximum input value will be adjusted to fit the operator type being generated.

设置操作符的最大输入数。这将覆盖代码中的任何#pragma opmaxinputs语句。最大输入值将被调整以适合正在生成的操作符类型。

Dialog Script options对话框脚本选项

-u [--ds-output] [file|-]

Write a dialog script to the filename given. As with --vex-output and --hda-output, if multiple input files are given, then the filename given is ignored and the output filename automatically constructed from either the context function name, or the input filename, if no context function is defined.

根据给定的文件名编写对话脚本。与—vex-output和—hda-output一样,如果给定多个输入文件,则忽略给定的文件名,如果没有定义上下文函数,则根据上下文函数名或输入文件名自动构造输出文件名。

Pre-processor 预处理程序

The compiler has a pre-processor which strips comments, reads include files, and expands macros.

编译器有一个预处理程序,用于删除注释、读取包含文件和展开宏。

The pre-processor supports many of the usual C Pre-Processor directives:

预处理器支持许多常见的C预处理器指令:

#define name token-string

Replace subsequent uses of name with token-string. 将名称的后续使用替换为令牌字符串。

#define name(arg,...,arg) token-string

Replace subsequent instances of name with token-string. Each argument to name is replaced in token-string during expansion.

用令牌字符串替换name的后续实例。在扩展中,要命名的每个参数都在令牌字符串中替换。

#undef name

"Undefine" the macro so subsequent uses of name are not expanded. “Undefine”宏,因此名称的后续使用不会展开。

#include "filename"

Inserts the contents of the file at this point in the source code. When you use quotes, the directory containing the current file is searched for filename before the standard locations (including the path).

在源代码中插入文件的内容。当使用引号时,包含当前文件的目录将在标准位置(包括路径)之前搜索文件名。

#ifdef name

The following lines until the next #endif or else directive will be compiled if and only if name is a defined macro.

只有当且仅当name是一个定义好的宏时,才会编译下面的行,直到下一个#endif或else指令。

#ifndef name

The lines following will be compiled if and only if name is not a defined macro.

只有当且仅当name不是一个定义的宏时,才会编译下面的代码行。

#if constant-expr

The following lines until the next #endif or #else directive will be compiled if and only if constant-expr evaluates to non-zero.

当且仅当constant-expr的计算结果为非零时,将编译下面的行,直到下一个#endif或#else指令。

The expression can use the following operators:

 

表达式可以使用以下操作符:

  • Comparisons (==!=<=>=<>)

  • Logical AND (&&), OR (||), and NOT (!).

  • Bitwise AND (&), OR (|), exclusive OR (^), and NOT (~).

  • Arithmetic (+-*/%).

  • Parentheses. 圆括号

The expression can also use the following functions:

该表达式还可以使用以下函数:

defined(name)

Returns 1 if the name is a defined macro, or 0 if it is not. 如果名称是定义的宏,则返回1;如果不是,则返回0。

#if defined(foo) && defined(fum)

environment(name)

Returns 1 if name is a defined environment variable. 如果name是定义的环境变量,则返回1。

access(filename)

Returns 1 if filename can be read by the application, or 0 if the file cannot be read.

如果应用程序可以读取文件名,返回1;如果无法读取文件,返回0。

#if access("/etc/passwd")
#include </etc/passwd>
#endif

strcmp(str1, str2)

Works the same as the C/C++ function of the same name, if the two strings have the same contents, the function returns 0. Each argument should be a quoted string or a macro that expands to a quoted string.

工作原理与同名的C/ c++函数相同,如果两个字符串的内容相同,函数返回0。每个参数都应该是一个带引号的字符串或一个扩展为带引号字符串的宏。

#define VALUE "foo"
#if strcmp(VALUE, "bar") != 0
This statement is false since "foo" != "bar"
#endif
#if !strcmp(VALUE, "foo")
This statement is TRUE since strcmp("foo", "bar") == 0
#endif

Expressions are evaluated from left to right (unlike the ANSI C standard of right to left). As with the ANSI pre-procssor, all numbers must be integers.

表达式从左到右求值(不像ANSI C标准的从右到左求值)。与ANSI预处理器一样,所有的数字都必须是整数。

#else

The following lines until the next #endif directive will be compiled if and only if the previous #if directive evaluated to zero.

当且仅当前一个#if指令的值为零时,才编译下一个#endif指令之前的以下行。

#endif

Marks the end of a section of conditional code. Every test directive must have a matching #endif.

标记条件代码段的末尾。每个测试指令必须有一个匹配的#endif。

#pragma ...

Specifies extended language features. See the list of pragmas. 指定扩展语言特性。参见pragmas列表。

Predefined macros 预定义的宏

The following macros are pre-defined:  以下宏是预先定义的:

__vex

This symbol is always defined. You can use this in an if pre-processor directive to check that the program is being compiled by vcc.

这个符号总是被定义。您可以在if预处理器指令中使用它来检查程序是否由vcc编译。

__vex_major

The major version number of the compiler. 编译器的主要版本号。

__vex_minor

The minor version number of the compiler. 编译器的副版本号。

__vex_build

The build version number of the compiler. 编译器的生成版本号。

__vex_patch

The patch version number of the compiler. 编译器的补丁版本号。

__LINE__

The current line number of the source file. 源文件的当前行号。

__FILE__

The file being compiled. 正在编译的文件。

__DATE__

The current date (as a quoted string). Example: "Dec 31 1999" 当前日期(作为引用字符串)。例子:“一九九九年十二月三十一日”

__TIME__

The current time (as a quoted string). Example: "23:59:59" 当前时间(作为引用字符串)。例如:“23:59:59”

printf("Starting shader %s at %s", __FILE__, __DATE__);
 类似资料: