commit
03eb8afc2a
@ -0,0 +1,10 @@ |
|||||||
|
.*.sw* |
||||||
|
.DS_Store |
||||||
|
*.sqlite3 |
||||||
|
*.sqlite3-wal |
||||||
|
*.sqlite3-shm |
||||||
|
debug |
||||||
|
coverage/ |
||||||
|
.coverage |
||||||
|
builddir |
||||||
|
subprojects |
||||||
@ -0,0 +1 @@ |
|||||||
|
set makeprg=meson\ compile\ -C\ . |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
all: build |
||||||
|
|
||||||
|
reset: |
||||||
|
powershell -executionpolicy bypass .\scripts\reset_build.ps1
|
||||||
|
|
||||||
|
build: |
||||||
|
meson compile -j 4 -C builddir
|
||||||
|
|
||||||
|
release_build: |
||||||
|
meson --wipe builddir -Db_ndebug=true --buildtype release
|
||||||
|
meson compile -j 4 -C builddir
|
||||||
|
|
||||||
|
debug_build: |
||||||
|
meson setup --wipe builddir -Db_ndebug=true --buildtype debugoptimized
|
||||||
|
meson compile -j 4 -C builddir
|
||||||
|
|
||||||
|
run: build |
||||||
|
./builddir/chip8.exe
|
||||||
|
|
||||||
|
debug: build |
||||||
|
gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe
|
||||||
|
|
||||||
|
debug_run: build |
||||||
|
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/chip8.exe
|
||||||
|
|
||||||
|
clean: |
||||||
|
meson compile --clean -C builddir
|
||||||
@ -0,0 +1,7 @@ |
|||||||
|
# chip-8 Interpreter |
||||||
|
|
||||||
|
Just a little fun project. I based the first version on this really great blog post https://austinmorlan.com/posts/chip8_emulator/ |
||||||
|
|
||||||
|
Other resources from trapexit at: |
||||||
|
|
||||||
|
https://github.com/trapexit/chip-8_documentation |
||||||
@ -0,0 +1,92 @@ |
|||||||
|
project('chip8', 'cpp', |
||||||
|
version: '0.1.0', |
||||||
|
default_options: [ |
||||||
|
'cpp_std=c++23', |
||||||
|
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1', |
||||||
|
]) |
||||||
|
|
||||||
|
# use this for common options only for our executables |
||||||
|
cpp_args=[ |
||||||
|
'-Wno-unused-parameter', |
||||||
|
'-Wno-unused-function', |
||||||
|
'-Wno-unused-variable', |
||||||
|
'-Wno-unused-but-set-variable', |
||||||
|
'-Wno-deprecated-declarations', |
||||||
|
] |
||||||
|
link_args=[] |
||||||
|
# these are passed as override_defaults |
||||||
|
exe_defaults = [ 'warning_level=2' ] |
||||||
|
|
||||||
|
cc = meson.get_compiler('cpp') |
||||||
|
dependencies = [] |
||||||
|
|
||||||
|
if build_machine.system() == 'windows' |
||||||
|
add_global_link_arguments( |
||||||
|
'-static-libgcc', |
||||||
|
'-static-libstdc++', |
||||||
|
'-static', |
||||||
|
language: 'cpp', |
||||||
|
) |
||||||
|
|
||||||
|
sfml_main = dependency('sfml_main') |
||||||
|
opengl32 = cc.find_library('opengl32', required: true) |
||||||
|
winmm = cc.find_library('winmm', required: true) |
||||||
|
gdi32 = cc.find_library('gdi32', required: true) |
||||||
|
|
||||||
|
dependencies += [ |
||||||
|
opengl32, winmm, gdi32, sfml_main |
||||||
|
] |
||||||
|
exe_defaults += ['werror=true'] |
||||||
|
|
||||||
|
elif build_machine.system() == 'darwin' |
||||||
|
add_global_link_arguments( |
||||||
|
language: 'cpp', |
||||||
|
) |
||||||
|
|
||||||
|
opengl = dependency('OpenGL') |
||||||
|
corefoundation = dependency('CoreFoundation') |
||||||
|
carbon = dependency('Carbon') |
||||||
|
cocoa = dependency('Cocoa') |
||||||
|
iokit = dependency('IOKit') |
||||||
|
corevideo = dependency('CoreVideo') |
||||||
|
|
||||||
|
link_args += ['-ObjC'] |
||||||
|
exe_defaults += ['werror=false'] |
||||||
|
dependencies += [ |
||||||
|
opengl, corefoundation, carbon, cocoa, iokit, corevideo |
||||||
|
] |
||||||
|
endif |
||||||
|
|
||||||
|
catch2 = subproject('catch2').get_variable('catch2_with_main_dep') |
||||||
|
fmt = subproject('fmt').get_variable('fmt_dep') |
||||||
|
freetype2 = subproject('freetype2').get_variable('freetype_dep') |
||||||
|
|
||||||
|
flac = subproject('flac').get_variable('flac_dep') |
||||||
|
ogg = subproject('ogg').get_variable('libogg_dep') |
||||||
|
vorbis = subproject('vorbis').get_variable('vorbis_dep') |
||||||
|
vorbisfile = subproject('vorbis').get_variable('vorbisfile_dep') |
||||||
|
vorbisenc = subproject('vorbis').get_variable('vorbisenc_dep') |
||||||
|
sfml_audio = subproject('sfml').get_variable('sfml_audio_dep') |
||||||
|
sfml_graphics = subproject('sfml').get_variable('sfml_graphics_dep') |
||||||
|
sfml_network = subproject('sfml').get_variable('sfml_network_dep') |
||||||
|
sfml_system = subproject('sfml').get_variable('sfml_system_dep') |
||||||
|
sfml_window = subproject('sfml').get_variable('sfml_window_dep') |
||||||
|
|
||||||
|
dependencies += [ |
||||||
|
fmt, freetype2, |
||||||
|
flac, ogg, vorbis, vorbisfile, vorbisenc, |
||||||
|
sfml_audio, sfml_graphics, |
||||||
|
sfml_network, sfml_system, |
||||||
|
sfml_window |
||||||
|
] |
||||||
|
|
||||||
|
sources = [ |
||||||
|
'src/dbc.cpp', |
||||||
|
] |
||||||
|
|
||||||
|
executable('chip8', |
||||||
|
sources + [ 'src/main.cpp' ], |
||||||
|
cpp_args: cpp_args, |
||||||
|
link_args: link_args, |
||||||
|
override_options: exe_defaults, |
||||||
|
dependencies: dependencies) |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
mv .\subprojects\packagecache . |
||||||
|
rm -recurse -force .\subprojects\,.\builddir\ |
||||||
|
mkdir subprojects |
||||||
|
mv .\packagecache .\subprojects\ |
||||||
|
mkdir builddir |
||||||
|
cp wraps\*.wrap subprojects\ |
||||||
|
meson setup --default-library=static --prefer-static builddir |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
mv -f ./subprojects/packagecache . |
||||||
|
rm -rf subprojects builddir |
||||||
|
mkdir subprojects |
||||||
|
mv -f packagecache ./subprojects/ && true |
||||||
|
mkdir builddir |
||||||
|
cp wraps/*.wrap subprojects/ |
||||||
|
# on OSX you can't do this with static |
||||||
|
meson setup --default-library=static --prefer-static builddir |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
mkdir builddir |
||||||
|
mkdir subprojects |
||||||
|
cp wraps/*.wrap subprojects |
||||||
|
meson setup -Ddefault_library=static builddir |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
set -ex |
||||||
|
|
||||||
|
mkdir subprojects |
||||||
|
mkdir builddir |
||||||
|
cp wraps/*.wrap subprojects/ |
||||||
|
meson setup builddir |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
set -e |
||||||
|
|
||||||
|
fswatch -o *.cpp | while read num |
||||||
|
do echo ">>>>>>>>>>>>>>>>>>>>>> `date`" |
||||||
|
if meson compile -C builddir |
||||||
|
then |
||||||
|
./builddir/sfmldemo |
||||||
|
else |
||||||
|
echo "^^^^^^^^^^^^^^^^^^^^^ ERROR `date`" |
||||||
|
fi |
||||||
|
done |
||||||
@ -0,0 +1,255 @@ |
|||||||
|
function Test-WinUtilPackageManager { |
||||||
|
<# |
||||||
|
|
||||||
|
.SYNOPSIS |
||||||
|
Checks if Winget and/or Choco are installed |
||||||
|
|
||||||
|
.PARAMETER winget |
||||||
|
Check if Winget is installed |
||||||
|
|
||||||
|
.PARAMETER choco |
||||||
|
Check if Chocolatey is installed |
||||||
|
|
||||||
|
#> |
||||||
|
|
||||||
|
Param( |
||||||
|
[System.Management.Automation.SwitchParameter]$winget, |
||||||
|
[System.Management.Automation.SwitchParameter]$choco |
||||||
|
) |
||||||
|
|
||||||
|
$status = "not-installed" |
||||||
|
|
||||||
|
if ($winget) { |
||||||
|
# Check if Winget is available while getting it's Version if it's available |
||||||
|
$wingetExists = $true |
||||||
|
try { |
||||||
|
$wingetVersionFull = winget --version |
||||||
|
} catch [System.Management.Automation.CommandNotFoundException], [System.Management.Automation.ApplicationFailedException] { |
||||||
|
Write-Warning "Winget was not found due to un-availablity reasons" |
||||||
|
$wingetExists = $false |
||||||
|
} catch { |
||||||
|
Write-Warning "Winget was not found due to un-known reasons, The Stack Trace is:`n$($psitem.Exception.StackTrace)" |
||||||
|
$wingetExists = $false |
||||||
|
} |
||||||
|
|
||||||
|
# If Winget is available, Parse it's Version and give proper information to Terminal Output. |
||||||
|
# If it isn't available, the return of this funtion will be "not-installed", indicating that |
||||||
|
# Winget isn't installed/available on The System. |
||||||
|
if ($wingetExists) { |
||||||
|
# Check if Preview Version |
||||||
|
if ($wingetVersionFull.Contains("-preview")) { |
||||||
|
$wingetVersion = $wingetVersionFull.Trim("-preview") |
||||||
|
$wingetPreview = $true |
||||||
|
} else { |
||||||
|
$wingetVersion = $wingetVersionFull |
||||||
|
$wingetPreview = $false |
||||||
|
} |
||||||
|
|
||||||
|
# Check if Winget's Version is too old. |
||||||
|
$wingetCurrentVersion = [System.Version]::Parse($wingetVersion.Trim('v')) |
||||||
|
# Grabs the latest release of Winget from the Github API for version check process. |
||||||
|
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop |
||||||
|
$wingetLatestVersion = [System.Version]::Parse(($response.tag_name).Trim('v')) #Stores version number of latest release. |
||||||
|
$wingetOutdated = $wingetCurrentVersion -lt $wingetLatestVersion |
||||||
|
Write-Host "===========================================" -ForegroundColor Green |
||||||
|
Write-Host "--- Winget is installed ---" -ForegroundColor Green |
||||||
|
Write-Host "===========================================" -ForegroundColor Green |
||||||
|
Write-Host "Version: $wingetVersionFull" -ForegroundColor White |
||||||
|
|
||||||
|
if (!$wingetPreview) { |
||||||
|
Write-Host " - Winget is a release version." -ForegroundColor Green |
||||||
|
} else { |
||||||
|
Write-Host " - Winget is a preview version. Unexpected problems may occur." -ForegroundColor Yellow |
||||||
|
} |
||||||
|
|
||||||
|
if (!$wingetOutdated) { |
||||||
|
Write-Host " - Winget is Up to Date" -ForegroundColor Green |
||||||
|
$status = "installed" |
||||||
|
} |
||||||
|
else { |
||||||
|
Write-Host " - Winget is Out of Date" -ForegroundColor Red |
||||||
|
$status = "outdated" |
||||||
|
} |
||||||
|
} else { |
||||||
|
Write-Host "===========================================" -ForegroundColor Red |
||||||
|
Write-Host "--- Winget is not installed ---" -ForegroundColor Red |
||||||
|
Write-Host "===========================================" -ForegroundColor Red |
||||||
|
$status = "not-installed" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($choco) { |
||||||
|
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { |
||||||
|
Write-Host "===========================================" -ForegroundColor Green |
||||||
|
Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green |
||||||
|
Write-Host "===========================================" -ForegroundColor Green |
||||||
|
Write-Host "Version: v$chocoVersion" -ForegroundColor White |
||||||
|
$status = "installed" |
||||||
|
} else { |
||||||
|
Write-Host "===========================================" -ForegroundColor Red |
||||||
|
Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red |
||||||
|
Write-Host "===========================================" -ForegroundColor Red |
||||||
|
$status = "not-installed" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return $status |
||||||
|
} |
||||||
|
|
||||||
|
function Get-WinUtilWingetPrerequisites { |
||||||
|
<# |
||||||
|
.SYNOPSIS |
||||||
|
Downloads the Winget Prereqs. |
||||||
|
.DESCRIPTION |
||||||
|
Downloads Prereqs for Winget. Version numbers are coded as variables and can be updated as uncommonly as Microsoft updates the prereqs. |
||||||
|
#> |
||||||
|
|
||||||
|
# I don't know of a way to detect the prereqs automatically, so if someone has a better way of defining these, that would be great. |
||||||
|
# Microsoft.VCLibs version rarely changes, but for future compatibility I made it a variable. |
||||||
|
$versionVCLibs = "14.00" |
||||||
|
$fileVCLibs = "https://aka.ms/Microsoft.VCLibs.x64.${versionVCLibs}.Desktop.appx" |
||||||
|
# Write-Host "$fileVCLibs" |
||||||
|
# Microsoft.UI.Xaml version changed recently, so I made the version numbers variables. |
||||||
|
$versionUIXamlMinor = "2.8" |
||||||
|
$versionUIXamlPatch = "2.8.6" |
||||||
|
$fileUIXaml = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v${versionUIXamlPatch}/Microsoft.UI.Xaml.${versionUIXamlMinor}.x64.appx" |
||||||
|
# Write-Host "$fileUIXaml" |
||||||
|
|
||||||
|
Try{ |
||||||
|
Write-Host "Downloading Microsoft.VCLibs Dependency..." |
||||||
|
Invoke-WebRequest -Uri $fileVCLibs -OutFile $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx |
||||||
|
Write-Host "Downloading Microsoft.UI.Xaml Dependency...`n" |
||||||
|
Invoke-WebRequest -Uri $fileUIXaml -OutFile $ENV:TEMP\Microsoft.UI.Xaml.x64.appx |
||||||
|
} |
||||||
|
Catch{ |
||||||
|
throw [WingetFailedInstall]::new('Failed to install prerequsites') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function Get-WinUtilWingetLatest { |
||||||
|
<# |
||||||
|
.SYNOPSIS |
||||||
|
Uses GitHub API to check for the latest release of Winget. |
||||||
|
.DESCRIPTION |
||||||
|
This function grabs the latest version of Winget and returns the download path to Install-WinUtilWinget for installation. |
||||||
|
#> |
||||||
|
# Invoke-WebRequest is notoriously slow when the byte progress is displayed. The following lines disable the progress bar and reset them at the end of the function |
||||||
|
$PreviousProgressPreference = $ProgressPreference |
||||||
|
$ProgressPreference = "silentlyContinue" |
||||||
|
Try{ |
||||||
|
# Grabs the latest release of Winget from the Github API for the install process. |
||||||
|
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop |
||||||
|
$latestVersion = $response.tag_name #Stores version number of latest release. |
||||||
|
$licenseWingetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*License1.xml"} #Index value for License file. |
||||||
|
Write-Host "Latest Version:`t$($latestVersion)`n" |
||||||
|
Write-Host "Downloading..." |
||||||
|
$assetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"} |
||||||
|
Invoke-WebRequest -Uri $licenseWingetUrl -OutFile $ENV:TEMP\License1.xml |
||||||
|
# The only pain is that the msixbundle for winget-cli is 246MB. In some situations this can take a bit, with slower connections. |
||||||
|
Invoke-WebRequest -Uri $assetUrl -OutFile $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle |
||||||
|
} |
||||||
|
Catch{ |
||||||
|
throw [WingetFailedInstall]::new('Failed to get latest Winget release and license') |
||||||
|
} |
||||||
|
$ProgressPreference = $PreviousProgressPreference |
||||||
|
} |
||||||
|
|
||||||
|
function Install-WinUtilWinget { |
||||||
|
<# |
||||||
|
|
||||||
|
.SYNOPSIS |
||||||
|
Installs Winget if it is not already installed. |
||||||
|
|
||||||
|
.DESCRIPTION |
||||||
|
This function will download the latest version of Winget and install it. If Winget is already installed, it will do nothing. |
||||||
|
#> |
||||||
|
$isWingetInstalled = Test-WinUtilPackageManager -winget |
||||||
|
|
||||||
|
Try { |
||||||
|
if ($isWingetInstalled -eq "installed") { |
||||||
|
Write-Host "`nWinget is already installed.`r" -ForegroundColor Green |
||||||
|
return |
||||||
|
} elseif ($isWingetInstalled -eq "outdated") { |
||||||
|
Write-Host "`nWinget is Outdated. Continuing with install.`r" -ForegroundColor Yellow |
||||||
|
} else { |
||||||
|
Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red |
||||||
|
} |
||||||
|
|
||||||
|
# Gets the computer's information |
||||||
|
if ($null -eq $sync.ComputerInfo){ |
||||||
|
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop |
||||||
|
} else { |
||||||
|
$ComputerInfo = $sync.ComputerInfo |
||||||
|
} |
||||||
|
|
||||||
|
if (($ComputerInfo.WindowsVersion) -lt "1809") { |
||||||
|
# Checks if Windows Version is too old for Winget |
||||||
|
Write-Host "Winget is not supported on this version of Windows (Pre-1809)" -ForegroundColor Red |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
# Install Winget via GitHub method. |
||||||
|
# Used part of my own script with some modification: ruxunderscore/windows-initialization |
||||||
|
Write-Host "Downloading Winget Prerequsites`n" |
||||||
|
Get-WinUtilWingetPrerequisites |
||||||
|
Write-Host "Downloading Winget and License File`r" |
||||||
|
Get-WinUtilWingetLatest |
||||||
|
Write-Host "Installing Winget w/ Prerequsites`r" |
||||||
|
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml |
||||||
|
Write-Host "Manually adding Winget Sources, from Winget CDN." |
||||||
|
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time. |
||||||
|
Write-Host "Winget Installed" -ForegroundColor Green |
||||||
|
Write-Host "Enabling NuGet and Module..." |
||||||
|
Install-PackageProvider -Name NuGet -Force |
||||||
|
Install-Module -Name Microsoft.WinGet.Client -Force |
||||||
|
# Winget only needs a refresh of the environment variables to be used. |
||||||
|
Write-Output "Refreshing Environment Variables...`n" |
||||||
|
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") |
||||||
|
} Catch { |
||||||
|
Write-Host "Failure detected while installing via GitHub method. Continuing with Chocolatey method as fallback." -ForegroundColor Red |
||||||
|
# In case install fails via GitHub method. |
||||||
|
Try { |
||||||
|
# Install Choco if not already present |
||||||
|
Install-WinUtilChoco |
||||||
|
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget-cli" |
||||||
|
Write-Host "Winget Installed" -ForegroundColor Green |
||||||
|
Write-Output "Refreshing Environment Variables...`n" |
||||||
|
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") |
||||||
|
} Catch { |
||||||
|
throw [WingetFailedInstall]::new('Failed to install!') |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
$isAdmin = [System.Security.Principal.WindowsPrincipal]::new( |
||||||
|
[System.Security.Principal.WindowsIdentity]::GetCurrent()). |
||||||
|
IsInRole('Administrators') |
||||||
|
|
||||||
|
if(-not $isAdmin) { |
||||||
|
$params = @{ |
||||||
|
FilePath = 'powershell' # or pwsh if Core |
||||||
|
Verb = 'RunAs' |
||||||
|
ArgumentList = @( |
||||||
|
'-ExecutionPolicy ByPass' |
||||||
|
'-File "{0}"' -f $PSCommandPath |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
Start-Process -Wait @params |
||||||
|
Write-Host "Admin stuff done..." |
||||||
|
} else { |
||||||
|
Write-Host "In Admin stuff..." |
||||||
|
Install-WinUtilWinget |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','chocolatey' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Git.Git' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Microsoft.WindowsTerminal' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Python.Python.3.12' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','AntibodySoftware.WizFile' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Kitware.CMake' |
||||||
|
Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Microsoft.VCRedist.2015+.x64' |
||||||
|
|
||||||
|
Start-Process -Verb RunAs -Wait powershell -argumentlist 'C:\ProgramData\chocolatey\bin\choco.exe','install','geany','geany-plugins','winlibs','conan','meson' |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
#include "dbc.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
void dbc::log(const string &message, const std::source_location location) { |
||||||
|
std::cout << '[' << location.file_name() << ':' |
||||||
|
<< location.line() << "|" |
||||||
|
<< location.function_name() << "] " |
||||||
|
<< message << std::endl; |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::sentinel(const string &message, const std::source_location location) { |
||||||
|
string err = $F("[SENTINEL!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::SentinelError{err}; |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::pre(const string &message, bool test, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = $F("[PRE!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::PreCondError{err}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::pre(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||||
|
dbc::pre(message, tester(), location); |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::post(const string &message, bool test, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = $F("[POST!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::PostCondError{err}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::post(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||||
|
dbc::post(message, tester(), location); |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::check(bool test, const string &message, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = $F("[CHECK!] {}\n", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::CheckError{err}; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <string> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <functional> |
||||||
|
#include <source_location> |
||||||
|
|
||||||
|
// AKA the Fuckit macro
|
||||||
|
#define $F(FMT, ...) fmt::format(FMT, ##__VA_ARGS__) |
||||||
|
|
||||||
|
namespace dbc { |
||||||
|
using std::string; |
||||||
|
|
||||||
|
class Error { |
||||||
|
public: |
||||||
|
const string message; |
||||||
|
Error(string m) : message{m} {} |
||||||
|
Error(const char *m) : message{m} {} |
||||||
|
}; |
||||||
|
|
||||||
|
class CheckError : public Error {}; |
||||||
|
class SentinelError : public Error {}; |
||||||
|
class PreCondError : public Error {}; |
||||||
|
class PostCondError : public Error {}; |
||||||
|
|
||||||
|
void log(const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
[[noreturn]] void sentinel(const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void pre(const string &message, bool test, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void pre(const string &message, std::function<bool()> tester, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void post(const string &message, bool test, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void post(const string &message, std::function<bool()> tester, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void check(bool test, const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
#define _USE_MATH_DEFINES |
||||||
|
#include <math.h> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <SFML/Graphics/Sprite.hpp> |
||||||
|
#include <SFML/Graphics/Texture.hpp> |
||||||
|
#include <SFML/Graphics/RenderWindow.hpp> |
||||||
|
#include <SFML/System.hpp> |
||||||
|
#include <SFML/Audio.hpp> |
||||||
|
#include <SFML/Window/Event.hpp> |
||||||
|
#include "dbc.hpp" |
||||||
|
|
||||||
|
int main() { |
||||||
|
fmt::print("Setting up a window for you...\n"); |
||||||
|
|
||||||
|
sf::RenderWindow window(sf::VideoMode({1280, 720}), "Simple Game Demo"); |
||||||
|
window.setFramerateLimit(60); |
||||||
|
window.setVerticalSyncEnabled(true); |
||||||
|
|
||||||
|
sf::Clock deltaClock; |
||||||
|
sf::Clock clock; |
||||||
|
sf::Time tick = clock.getElapsedTime(); |
||||||
|
|
||||||
|
while (window.isOpen()) { |
||||||
|
window.clear(); |
||||||
|
window.display(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = Catch2-3.7.1 |
||||||
|
source_url = https://github.com/catchorg/Catch2/archive/v3.7.1.tar.gz |
||||||
|
source_filename = Catch2-3.7.1.tar.gz |
||||||
|
source_hash = c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.7.1-1/Catch2-3.7.1.tar.gz |
||||||
|
wrapdb_version = 3.7.1-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
catch2 = catch2_dep |
||||||
|
catch2-with-main = catch2_with_main_dep |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = flac-1.4.3 |
||||||
|
source_url = https://github.com/xiph/flac/releases/download/1.4.3/flac-1.4.3.tar.xz |
||||||
|
source_filename = flac-1.4.3.tar.xz |
||||||
|
source_hash = 6c58e69cd22348f441b861092b825e591d0b822e106de6eb0ee4d05d27205b70 |
||||||
|
patch_filename = flac_1.4.3-2_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/flac_1.4.3-2/get_patch |
||||||
|
patch_hash = 3eace1bd0769d3e0d4ff099960160766a5185d391c8f583293b087a1f96c2a9c |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/flac_1.4.3-2/flac-1.4.3.tar.xz |
||||||
|
wrapdb_version = 1.4.3-2 |
||||||
|
|
||||||
|
[provide] |
||||||
|
flac = flac_dep |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = fmt-11.0.2 |
||||||
|
source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz |
||||||
|
source_filename = fmt-11.0.2.tar.gz |
||||||
|
source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f |
||||||
|
patch_filename = fmt_11.0.2-1_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch |
||||||
|
patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz |
||||||
|
wrapdb_version = 11.0.2-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
fmt = fmt_dep |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = freetype-2.13.3 |
||||||
|
source_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.xz |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/freetype2_2.13.3-1/freetype-2.13.3.tar.xz |
||||||
|
source_filename = freetype-2.13.3.tar.xz |
||||||
|
source_hash = 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289 |
||||||
|
wrapdb_version = 2.13.3-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
freetype2 = freetype_dep |
||||||
|
freetype = freetype_dep |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libpng-1.6.44 |
||||||
|
source_url = https://github.com/glennrp/libpng/archive/v1.6.44.tar.gz |
||||||
|
source_filename = libpng-1.6.44.tar.gz |
||||||
|
source_hash = 0ef5b633d0c65f780c4fced27ff832998e71478c13b45dfb6e94f23a82f64f7c |
||||||
|
patch_filename = libpng_1.6.44-1_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/libpng_1.6.44-1/get_patch |
||||||
|
patch_hash = 394b07614c45fbd1beac8b660386216a490fe12f841a1a445799b676c9c892fb |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libpng_1.6.44-1/libpng-1.6.44.tar.gz |
||||||
|
wrapdb_version = 1.6.44-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
libpng = libpng_dep |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = nlohmann_json-3.11.3 |
||||||
|
lead_directory_missing = true |
||||||
|
source_url = https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip |
||||||
|
source_filename = nlohmann_json-3.11.3.zip |
||||||
|
source_hash = a22461d13119ac5c78f205d3df1db13403e58ce1bb1794edc9313677313f4a9d |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/nlohmann_json_3.11.3-1/nlohmann_json-3.11.3.zip |
||||||
|
wrapdb_version = 3.11.3-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
nlohmann_json = nlohmann_json_dep |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libogg-1.3.5 |
||||||
|
source_url = https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz |
||||||
|
source_filename = libogg-1.3.5.tar.xz |
||||||
|
source_hash = c4d91be36fc8e54deae7575241e03f4211eb102afb3fc0775fbbc1b740016705 |
||||||
|
patch_filename = ogg_1.3.5-6_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/ogg_1.3.5-6/get_patch |
||||||
|
patch_hash = 8be6dcd5f93bbf9c0b9c8ec1fa29810226a60f846383074ca05b313a248e78b2 |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/ogg_1.3.5-6/libogg-1.3.5.tar.xz |
||||||
|
wrapdb_version = 1.3.5-6 |
||||||
|
|
||||||
|
[provide] |
||||||
|
ogg = libogg_dep |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
[wrap-git] |
||||||
|
directory=SFML-3.0.0 |
||||||
|
url=https://github.com/SFML/SFML.git |
||||||
|
revision=3.0.0 |
||||||
|
depth=1 |
||||||
|
method=cmake |
||||||
|
|
||||||
|
[provide] |
||||||
|
sfml_audio = sfml_audio_dep |
||||||
|
sfml_graphics = sfml_graphics_dep |
||||||
|
sfml_main = sfml_main_dep |
||||||
|
sfml_network = sfml_network_dep |
||||||
|
sfml_system = sfml_system_dep |
||||||
|
sfml_window = sfml_window_dep |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libvorbis-1.3.7 |
||||||
|
source_url = https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.xz |
||||||
|
source_filename = libvorbis-1.3.7.tar.xz |
||||||
|
source_hash = b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b |
||||||
|
patch_filename = vorbis_1.3.7-4_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/vorbis_1.3.7-4/get_patch |
||||||
|
patch_hash = 979e22b24b16c927040700dfd8319cd6ba29bf52a14dbc66b1cb4ea60504f14a |
||||||
|
wrapdb_version = 1.3.7-4 |
||||||
|
|
||||||
|
[provide] |
||||||
|
vorbis = vorbis_dep |
||||||
|
vorbisfile = vorbisfile_dep |
||||||
|
vorbisenc = vorbisenc_dep |
||||||
Loading…
Reference in new issue