Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 4 additions & 66 deletions .github/workflows/generated-bindings-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,7 @@ jobs:
if: matrix.v-channel != 'stable' && steps.checkout_v_source.outcome == 'success'
id: setup_v_source
continue-on-error: ${{ matrix.v-channel == 'master' }}
shell: bash
run: |
if [[ "${{ matrix.v-channel }}" == v3 ]]; then
make -C .ci-v-source local=1
else
make -C .ci-v-source
fi
echo "$GITHUB_WORKSPACE/.ci-v-source" >> "$GITHUB_PATH"
.ci-v-source/v version
run: v run ci/compile_checks.vsh build-source .ci-v-source "${{ matrix.v-channel }}"
- name: Check the SDK setup entry point
if: runner.os == 'Linux' && (matrix.v-channel == 'stable' || steps.setup_v_source.outcome == 'success')
run: sh .github/scripts/setup-vulkan-ci.sh --help
Expand Down Expand Up @@ -164,69 +156,15 @@ jobs:
bindings-path: .
- name: Assemble isolated module
if: matrix.v-channel == 'stable' || steps.setup_v_source.outcome == 'success'
shell: bash
run: |
set -euo pipefail
module_root="$RUNNER_TEMP/vmodules/antono2/vulkan"
mkdir -p "$module_root/c" "$module_root/ergonomic"
cp vulkan.v vulkan_video.v loader.v v.mod VERSION REGISTRY_COMMIT VOLK_COMMIT "$module_root/"
cp c/loader_bridge.h c/volk.c.v c/volk_impl.h c/vulkan_core_prelude.h "$module_root/c/"
cp -R c/vendor "$module_root/c/"
cp ergonomic/*.v "$module_root/ergonomic/"
echo "VMODULES=$RUNNER_TEMP/vmodules" >> "$GITHUB_ENV"
run: v run ci/compile_checks.vsh stage "${{ runner.temp }}/vmodules"
- name: Type-check with the strict V3 frontend
if: matrix.v-channel == 'v3'
shell: bash
run: |
set -euo pipefail
v \
-new-compiler \
-check \
-cflags "-I$VMODULES/antono2/vulkan/c/vendor/include -I$VMODULES/antono2/vulkan/c/vendor/volk -I$VMODULES/antono2/vulkan -I$VULKAN_SDK/include" \
generator/test/main.c.v
v \
-new-compiler \
-d vulkan_xlib \
-check \
-cflags "-I$VMODULES/antono2/vulkan/c/vendor/include -I$VMODULES/antono2/vulkan/c/vendor/volk -I$VMODULES/antono2/vulkan -I$VULKAN_SDK/include" \
generator/test/main.c.v
v \
-new-compiler \
-check \
-cflags "-I$VMODULES/antono2/vulkan/c/vendor/include -I$VMODULES/antono2/vulkan/c/vendor/volk -I$VMODULES/antono2/vulkan -I$VULKAN_SDK/include" \
ci/bundled_header_smoke
run: v run ci/compile_checks.vsh frontend
- name: Compile smoke test and ergonomic unit tests
id: compile
if: matrix.v-channel == 'stable' || steps.setup_v_source.outcome == 'success'
continue-on-error: ${{ matrix.v-channel != 'stable' }}
shell: bash
run: |
set -euo pipefail
v_flags=(-cc "${{ matrix.compiler }}")
if [[ "${{ matrix.v-channel }}" == v3 ]]; then
# Strict V3 does not yet expand module-relative or environment-
# derived #flag include paths, so pass the verified paths explicitly.
v_flags=(
-new-compiler
"${v_flags[@]}"
-cflags "-I$VMODULES/antono2/vulkan/c/vendor/include -I$VMODULES/antono2/vulkan/c/vendor/volk -I$VMODULES/antono2/vulkan -I$VULKAN_SDK/include"
)
fi
if [[ "${{ runner.os }}" == macOS ]]; then
v "${v_flags[@]}" -o "$RUNNER_TEMP/vulkan-smoke" generator/test
else
v "${v_flags[@]}" run generator/test
fi
v "${v_flags[@]}" -o "$RUNNER_TEMP/bundled-header-smoke" ci/bundled_header_smoke
v "${v_flags[@]}" run ci/header_order_smoke
v "${v_flags[@]}" test ergonomic
v run scripts/check_docs.vsh
v "${v_flags[@]}" -o "$RUNNER_TEMP/vulkan-first-use" examples/getting_started
v "${v_flags[@]}" -o "$RUNNER_TEMP/vulkan-conveniences" examples/conveniences
if [[ "${{ runner.os }}" == Linux && "${{ matrix.v-channel }}" == stable ]]; then
v -d vulkan_xlib -cc "${{ matrix.compiler }}" \
-o "$RUNNER_TEMP/vulkan-xlib-smoke" ci/platform_xlib
fi
run: v run ci/compile_checks.vsh smoke "${{ runner.temp }}" "${{ matrix.compiler }}" "${{ matrix.v-channel }}"
- name: Validate TinyCC loader and ergonomic API
if: runner.os == 'Linux' && matrix.v-channel == 'stable'
shell: bash
Expand Down
159 changes: 159 additions & 0 deletions ci/compile_checks.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Stage an isolated Vulkan module and run the binding compiler matrix.
import os
import rand

const usage = 'Usage: v run ci/compile_checks.vsh stage VMODULES | build-source SOURCE {v3|master} | frontend | smoke SCRATCH CC {stable|v3|master}'
const usage_status = 2
const root_files = ['vulkan.v', 'vulkan_video.v', 'loader.v', 'v.mod', 'VERSION', 'REGISTRY_COMMIT',
'VOLK_COMMIT']
const c_files = ['loader_bridge.h', 'volk.c.v', 'volk_impl.h', 'vulkan_core_prelude.h']

fn command(program string, args []string) ! {
mut child := os.new_process(program)
child.set_args(args)
child.run()
child.wait()
status := child.code
child.close()
if status != 0 {
return error_with_code('${program} ${args.join(' ')} exited with status ${status}', status)
}
}

fn append_actions_file(variable string, value string) ! {
if value.contains_any('\r\n') {
return error('Paths containing line breaks are unsupported.')
}
path := os.getenv(variable)
if path != '' {
mut file := os.open_append(path)!
defer { file.close() }
file.writeln(value)!
}
}

fn stage(root string, modules string) ! {
namespace := os.join_path(modules, 'antono2')
target := os.join_path(namespace, 'vulkan')
if os.exists(target) || os.is_link(target) {
return error('Vulkan already exists at ${target}. Use a fresh isolated VMODULES directory.')
}
draft := os.join_path(namespace, '.vulkan-stage-' + rand.uuid_v4())
os.mkdir_all(os.join_path(draft, 'c'))!
defer { os.rmdir_all(draft) or {} }
os.mkdir(os.join_path(draft, 'ergonomic'))!
for file in root_files {
os.cp(os.join_path(root, file), os.join_path(draft, file))!
}
for file in c_files {
os.cp(os.join_path(root, 'c', file), os.join_path(draft, 'c', file))!
}
os.cp_all(os.join_path(root, 'c', 'vendor'), os.join_path(draft, 'c', 'vendor'), false)!
for file in os.ls(os.join_path(root, 'ergonomic'))!.filter(it.ends_with('.v')) {
os.cp(os.join_path(root, 'ergonomic', file), os.join_path(draft, 'ergonomic', file))!
}
os.rename_dir(draft, target)!
append_actions_file('GITHUB_ENV', 'VMODULES=${modules}')!
println('Staged Vulkan in ${target}')
}

fn build_source(source string, channel string) ! {
// v run sets VEXE to the bootstrap binary. Make uses VEXE as its output path.
os.unsetenv('VEXE')
mut args := ['-C', source]
if channel == 'v3' {
args << 'local=1'
}
command('make', args)!
command(os.join_path(source, 'v'), ['version'])!
append_actions_file('GITHUB_PATH', source)!
}

fn v3_flags() ![]string {
modules := os.getenv('VMODULES')
sdk := os.getenv('VULKAN_SDK')
if modules == '' || sdk == '' {
return error('Set VMODULES and VULKAN_SDK before running the strict V3 checks.')
}
module_root := os.join_path(modules, 'antono2', 'vulkan')
include := [os.join_path(module_root, 'c', 'vendor', 'include'),
os.join_path(module_root, 'c', 'vendor', 'volk'), module_root, os.join_path(sdk, 'include')]
// Strict V3 needs the include paths that the stable compiler reads from #flag.
return ['-new-compiler', '-cflags', include.map('-I' + os.quoted_path(it)).join(' ')]
}

fn frontend(compiler string) ! {
flags := v3_flags()!
command(compiler, with_flags(flags, ['-check', 'generator/test/main.c.v']))!
command(compiler, with_flags(flags, ['-check', '-d', 'vulkan_xlib', 'generator/test/main.c.v']))!
command(compiler, with_flags(flags, ['-check', 'ci/bundled_header_smoke']))!
}

fn with_flags(flags []string, args []string) []string {
mut invocation := flags.clone()
invocation << args
return invocation
}

fn smoke(compiler string, scratch string, cc string, channel string) ! {
os.mkdir_all(scratch)!
mut flags := ['-cc', cc]
if channel == 'v3' {
flags << v3_flags()!
}
$if macos {
command(compiler, with_flags(flags, ['-o', os.join_path(scratch, 'vulkan-smoke'),
'generator/test']))!
} $else {
command(compiler, with_flags(flags, ['run', 'generator/test']))!
}
command(compiler, with_flags(flags, ['-o', os.join_path(scratch, 'bundled-header-smoke'),
'ci/bundled_header_smoke']))!
command(compiler, with_flags(flags, ['run', 'ci/header_order_smoke']))!
command(compiler, with_flags(flags, ['test', 'ergonomic']))!
command(compiler, ['run', 'scripts/check_docs.vsh'])!
command(compiler, with_flags(flags, ['-o', os.join_path(scratch, 'vulkan-first-use'),
'examples/getting_started']))!
command(compiler, with_flags(flags, ['-o', os.join_path(scratch, 'vulkan-conveniences'),
'examples/conveniences']))!
$if linux {
if channel == 'stable' {
command(compiler, ['-d', 'vulkan_xlib', '-cc', cc, '-o',
os.join_path(scratch, 'vulkan-xlib-smoke'), 'ci/platform_xlib'])!
}
}
}

fn run(args []string) ! {
if args in [['--help'], ['-h']] {
println(usage)
return
}
root := os.dir(@DIR)
match true {
args.len == 2 && args[0] == 'stage' && args[1] != '' {
stage(root, os.abs_path(args[1]))!
}
args.len == 3 && args[0] == 'build-source' && args[1] != '' && args[2] in ['v3', 'master'] {
build_source(os.abs_path(args[1]), args[2])!
}
args == ['frontend'] {
os.chdir(root)!
frontend(os.find_abs_path_of_executable('v')!)!
}
args.len == 4 && args[0] == 'smoke' && args[1] != '' && args[2] != ''
&& args[3] in ['stable', 'v3', 'master'] {
scratch := os.abs_path(args[1])
os.chdir(root)!
smoke(os.find_abs_path_of_executable('v')!, scratch, args[2], args[3])!
}
else {
return error_with_code(usage, usage_status)
}
}
}

run(os.args[1..]) or {
eprintln(err.msg())
exit(if err.code() > 0 { err.code() } else { 1 })
}
18 changes: 18 additions & 0 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ decoding or OpenCL interoperability. Use the tested V compiler from `compatibili
Choose `--profile v3` for the pinned V3 compiler or `--profile release` for
the released compiler when the project defines multiple profiles.

## Reproduce the compiler smoke checks

From the Vulkan checkout, put the generator revision pinned in
`compatibility.json` under `generator/` and install the Vulkan SDK. With the
tested V release and GCC on `PATH`, run the Linux stable lane in an isolated
module directory.

```sh
scratch=$(mktemp -d)
export VMODULES="$scratch/modules"
v run ci/compile_checks.vsh stage "$VMODULES"
v run ci/compile_checks.vsh smoke "$scratch" gcc stable
```

To run just the strict frontend checks, put the pinned V3 compiler on `PATH`,
set `VULKAN_SDK`, and run `v run ci/compile_checks.vsh frontend` with the staged
module directory.

## Vulkan SDK setup in GitHub Actions

After installing V on the runner, use the SDK setup action with the VulkanCI
Expand Down
Loading