CLI Tool
The axslc command-line tool compiles .axsl shader source files into per-stage GLSL outputs.
Synopsis
axslc [options] <input.axsl>Options
| Flag | Long Form | Description |
|---|---|---|
-o | --output <prefix> | Output file prefix. Default: out |
-I | --include-path <path> | Override base directory for @include resolution |
-v | --verbose | Print compilation status and stage count |
-h | --help | Print usage information |
--version | Print version string |
Output Naming
For each stage present in the compiled result, one file is written:
<prefix>.vert.glsl - vertex stage
<prefix>.frag.glsl - fragment stage
<prefix>.geom.glsl - geometry stage
<prefix>.comp.glsl - compute stageOnly stages that appear in the source are written.
Default Output
Without -o, files are named:
out.vert.glsl
out.frag.glsl
etc.Custom Prefix
With -o custom/shader:
custom/shader.vert.glsl
custom/shader.frag.glsl
etc.TIP
The parent directory must exist. axslc will not create intermediate directories.
Include Path Resolution
Default Behavior
@include paths are resolved relative to the input file's directory.
Example:
shaders/
main.axsl (@include "common/defs.axsl")
common/
defs.axslaxslc shaders/main.axslThe include is resolved as: shaders/common/defs.axsl
Override with -I
axslc -I /path/to/includes main.axslNow @include "defs.axsl" is resolved as: /path/to/includes/defs.axsl
Bare Filename
If the input file has no parent directory (bare filename like shader.axsl), includes are resolved from the current working directory.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (bad args, I/O, compilation failure) |
Example Usage
Basic Compilation
axslc shader.axslProduces:
out.vert.glsl(if vertex stage present)out.frag.glsl(if fragment stage present)
Custom Output
axslc -o build/shaders/light light.axslProduces:
build/shaders/light.vert.glslbuild/shaders/light.frag.glsl
With Include Path
axslc -I ./shaders/includes -o build/pbr pbr.axsl- Includes resolved from
./shaders/includes/ - Output to
build/pbr.*.glsl
Verbose Output
axslc -v -o build/shader shader.axslPrints:
Compiling shader.axsl...
Wrote build/shader.vert.glsl
Wrote build/shader.frag.glsl
Compilation successful (2 stages)Error Output
Errors are written to stderr with source context:
shader.axsl:15:9: unresolved symbol: 'unknown_func'
13 | void main() {
14 | vec3 pos = a.a_pos;
15 | vec3 result = unknown_func(pos);
| ^
16 | gl_Position = vec4(result, 1.0);
17 | }Integration with Build Systems
Makefile
AXSLC = axslc
SHADER_SRC = shaders/main.axsl
SHADER_OUT = build/shaders/main
$(SHADER_OUT).vert.glsl $(SHADER_OUT).frag.glsl: $(SHADER_SRC)
@mkdir -p $(dir $(SHADER_OUT))
$(AXSLC) -o $(SHADER_OUT) $(SHADER_SRC)
.PHONY: shaders
shaders: $(SHADER_OUT).vert.glsl $(SHADER_OUT).frag.glslCMake
find_program(AXSLC axslc REQUIRED)
function(add_shader TARGET SOURCE OUTPUT_PREFIX)
set(OUTPUTS
${OUTPUT_PREFIX}.vert.glsl
${OUTPUT_PREFIX}.frag.glsl
)
add_custom_command(
OUTPUT ${OUTPUTS}
COMMAND ${AXSLC} -o ${OUTPUT_PREFIX} ${SOURCE}
DEPENDS ${SOURCE}
COMMENT "Compiling shader ${SOURCE}"
)
add_custom_target(${TARGET} DEPENDS ${OUTPUTS})
endfunction()
add_shader(main_shader
${CMAKE_SOURCE_DIR}/shaders/main.axsl
${CMAKE_BINARY_DIR}/shaders/main
)Shell Script
#!/bin/bash
set -e
SHADER_DIR="shaders"
OUTPUT_DIR="build/shaders"
mkdir -p "$OUTPUT_DIR"
for shader in "$SHADER_DIR"/*.axsl; do
basename=$(basename "$shader" .axsl)
echo "Compiling $basename..."
axslc -o "$OUTPUT_DIR/$basename" "$shader"
done
echo "All shaders compiled successfully"Troubleshooting
"cannot open include"
Check that:
- The include path is correct relative to the input file
- Or use
-Ito set the correct base path - The included file exists and is readable
"wrote" messages but no file output
Check that:
- The parent directory exists (create it first)
- You have write permissions in the output directory
Compilation succeeds but GLSL compilation fails
AXSLC does not perform type checking. Type errors will be caught by your OpenGL driver's GLSL compiler. Check:
- The generated
.glslfiles for correctness - GLSL compiler error messages from
glCompileShader