Skip to content

CLI Tool

The axslc command-line tool compiles .axsl shader source files into per-stage GLSL outputs.

Synopsis

bash
axslc [options] <input.axsl>

Options

FlagLong FormDescription
-o--output <prefix>Output file prefix. Default: out
-I--include-path <path>Override base directory for @include resolution
-v--verbosePrint compilation status and stage count
-h--helpPrint usage information
--versionPrint 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 stage

Only 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.axsl
bash
axslc shaders/main.axsl

The include is resolved as: shaders/common/defs.axsl

Override with -I

bash
axslc -I /path/to/includes main.axsl

Now @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

CodeMeaning
0Success
1Error (bad args, I/O, compilation failure)

Example Usage

Basic Compilation

bash
axslc shader.axsl

Produces:

  • out.vert.glsl (if vertex stage present)
  • out.frag.glsl (if fragment stage present)

Custom Output

bash
axslc -o build/shaders/light light.axsl

Produces:

  • build/shaders/light.vert.glsl
  • build/shaders/light.frag.glsl

With Include Path

bash
axslc -I ./shaders/includes -o build/pbr pbr.axsl
  • Includes resolved from ./shaders/includes/
  • Output to build/pbr.*.glsl

Verbose Output

bash
axslc -v -o build/shader shader.axsl

Prints:

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

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.glsl

CMake

cmake
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

bash
#!/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 -I to 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 .glsl files for correctness
  • GLSL compiler error messages from glCompileShader