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
5 changes: 4 additions & 1 deletion .github/workflows/demo-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y build-essential cmake libglfw3-dev libvulkan-dev libvulkan-volk-dev patchelf pkg-config xvfb zip
- name: Verify generated upstream variant
working-directory: source/modules/antono2/imgui
run: ./scripts/check_upstream_variant.sh
run: |
v run setup.vsh --check
./scripts/check_upstream_variant.sh
- name: Select package variant
id: variant
working-directory: source/modules/antono2/imgui
Expand Down Expand Up @@ -176,6 +178,7 @@ jobs:
if (-not $InstallPath) { throw 'Visual Studio C++ tools were not found' }
Import-Module (Join-Path $InstallPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $InstallPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
v -check-syntax ./source/modules/antono2/imgui/setup.vsh
./source/modules/antono2/imgui/scripts/run_demo_windows.ps1 -BuildOnly -DemoDirectory "$env:GITHUB_WORKSPACE\source\demo"
- name: Package and verify
shell: pwsh
Expand Down
3 changes: 2 additions & 1 deletion QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Quick start

The generated V bindings are already committed. Most users only need to build
The generated V bindings are already committed. Most users can prepare the
checkout on Linux, macOS, or Windows with `v run setup.vsh`. They only need to build
the native Dear ImGui/ImPlot library; LuaJIT and the binding generator are not
required.

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
For a fresh-clone setup and a one-command GLFW/Vulkan demo, see
[`QUICKSTART.md`](QUICKSTART.md).

The cross-platform setup entry point installs prerequisites and builds the
native library without regenerating bindings:

```sh
v run setup.vsh
```

Use `v run setup.vsh --check` for read-only diagnostics.

This is an automated process to generate `imgui.v` and `implot.v`
- generate C for imgui using [cimgui](https://github.com/cimgui/cimgui)
- generate C for implot using [cimplot](https://github.com/cimgui/cimplot)
Expand Down
97 changes: 97 additions & 0 deletions setup.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env -S v run

// Cross-platform entry point for the native Dear ImGui/ImPlot build.

import os

fn run(command string) ! {
println('\n> ${command}')
result := os.execute(command)
if result.output.trim_space() != '' {
println(result.output.trim_right('\r\n'))
}
if result.exit_code != 0 {
return error('command failed with exit code ${result.exit_code}')
}
}

fn setup_vulkan(mode string) ! {
if mode == '--install' {
run('v install antono2.vulkan')!
}
setup := os.join_path(os.vmodules_dir(), 'antono2', 'vulkan', 'setup.vsh')
if !os.is_file(setup) {
return error('antono2.vulkan does not include setup.vsh; install or update it first')
}
run('v run ${os.quoted_path(setup)} ${mode}')!
$if windows {
value := os.execute('powershell -NoProfile -Command "[Environment]::GetEnvironmentVariable(\'VULKAN_SDK\', \'Machine\')"')
if value.exit_code == 0 && value.output.trim_space() != '' {
os.setenv('VULKAN_SDK', value.output.trim_space(), true)
}
}
}

fn main() {
if os.args.len > 2 || (os.args.len == 2 && os.args[1] !in ['--install', '--check', '-h', '--help']) {
eprintln('Usage: v run setup.vsh [--install|--check]')
exit(2)
}
if os.args.len == 2 && os.args[1] in ['-h', '--help'] {
println('Usage: v run setup.vsh [--install|--check]\n\nDefault: install dependencies and build the native ImGui library.\n--check: report prerequisites without changing the system or build tree.')
return
}
install := os.args.len == 1 || os.args[1] == '--install'
mode := if install { '--install' } else { '--check' }
project_dir := os.dir(os.real_path(@FILE))
$if linux {
run('bash ${os.quoted_path(os.join_path(project_dir, 'scripts', 'setup_linux.sh'))} ${mode}') or {
panic(err)
}
if install {
run('git -C ${os.quoted_path(project_dir)} submodule update --init --recursive') or {
panic(err)
}
run('v run ${os.quoted_path(os.join_path(project_dir, 'build_vimgui.vsh'))} --linkage shared --glfw system') or {
panic(err)
}
}
} $else $if macos {
setup_vulkan(mode) or { panic(err) }
if !os.exists_in_system_path('brew') {
eprintln('Homebrew is required for automatic CMake and GLFW installation: https://brew.sh')
exit(1)
}
if install {
run('brew install cmake glfw') or { panic(err) }
run('v install antono2.glfw') or { panic(err) }
run('git -C ${os.quoted_path(project_dir)} submodule update --init --recursive') or {
panic(err)
}
prefix := os.execute('brew --prefix glfw').output.trim_space()
os.setenv('GLFW_INCLUDE', os.join_path(prefix, 'include'), true)
os.setenv('GLFW_LIB', os.join_path(prefix, 'lib'), true)
run('v run ${os.quoted_path(os.join_path(project_dir, 'build_vimgui.vsh'))} --linkage shared --glfw system') or {
panic(err)
}
}
} $else $if windows {
setup_vulkan(mode) or { panic(err) }
script := if install { 'run_demo_windows.ps1' } else { 'check_windows.ps1' }
mut command := 'powershell -NoProfile -ExecutionPolicy Bypass -File ${os.quoted_path(os.join_path(project_dir, 'scripts', script))}'
if install {
command += ' -NativeOnly'
} else {
command += ' -BundledGlfw'
}
run(command) or { panic(err) }
} $else {
eprintln('Automatic setup is unsupported on this operating system.')
exit(1)
}
if install {
println('\nDear ImGui/ImPlot native libraries are ready. Run `./scripts/run_demo.sh` (Linux/macOS) or `scripts\\run_demo_windows.ps1` to launch the demo.')
} else {
println('\nDear ImGui/ImPlot prerequisite check passed.')
}
}