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
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# To run locally:
# act -P windows-2025-vs2026=-self-hosted
# run_ci.bat
# Worked fine

name: Run tests

on:
push:
pull_request:

jobs:
build-and-test:
runs-on: windows-2025-vs2026

steps:
- uses: actions/checkout@v6

- name: Setup MSVC
# TODO: Check version and explore updated versions
# Specifically for using VS 2026
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64

# 19.44.35227 currently (25-5-2026)
- name: Get toolset info
run: cl

- name: Build and run only tests
shell: cmd
run: build.bat test-only
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ dkms.conf
build/

# Vendor
vendor/
vendor/*
# include doctest and font
!vendor/doctest.h
!vendor/DOCTEST_LICENSE
!vendor/NotoSans-Regular.ttf

# ffmpeg logs
*.log
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ Version used: 8.1

The easiest way to get FFmpeg on Windows: from the git master or release builds section of
https://www.gyan.dev/ffmpeg/builds/ Download a full_build of any kind, such as
ffmpeg-2026-04-26-git-4867d251ad-full_build.7z. Make a folder next to compress.exe named "vendor"
and inside that named "ffmpeg". Then copy all the contents of the downloaded zip "bin" folder (10
items) to "vendor/ffmpeg"
ffmpeg-2026-04-26-git-4867d251ad-full_build.7z. Make a folder inside named "ffmpeg" inside "vendor".
Then copy all the contents of the downloaded zip "bin" folder (10 items) to "vendor/ffmpeg"

### ImGui

Expand All @@ -39,6 +38,10 @@ Run x64 Native Tools Command Prompt for VS (version optional)
build.bat
```

### Tests

[Doctest](https://github.com/doctest/doctest), version used 2.5.2. Included in the repo already

## Notes / limits

- If the requested size is too small for the video's length (would force video bitrate < 50 kbps),
Expand Down
116 changes: 96 additions & 20 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,59 @@ setlocal enabledelayedexpansion
IF not EXIST build mkdir build
pushd build

set argConfig=%1
set config=debug
set arg1=%1
set arg2=%2

if "!argConfig!" == "rel" (
set config=debug
set modeApp=1
set modeTest=0

rem default modeApp: 1 modeTest: 0
rem build test: modeApp: 1 modeTest: 1
rem test-only: modeApp: 0 modeTest: 1

rem build -> debug build
rem build rel -> release build
rem build test -> debug build and run debug test
rem build rel test -> rel build and run rel test
rem build test-only -> run debug test
rem build rel test-only -> run rel test
rem "rel" can be replaced with "release" anytime

if "!arg1!" == "rel" (
set config=release
) else if "!arg1!" == "release" (
set config=release
) else if "!arg2!" == "rel" (
set config=release
) else if "!argConfig!" == "release" (
) else if "!arg2!" == "release" (
set config=release
)

if "!arg1!" == "test" (
set modeTest=1
) else if "!arg2!" == "test" (
set modeTest=1
)

rem test-only overrides everything
if "!arg1!" == "test-only" (
set modeApp=0
set modeTest=1
) else if "!arg2!" == "test-only" (
set modeApp=0
set modeTest=1
)

echo Config: !config!
echo App: !modeApp!
echo Test: !modeTest!

rem /FAs /Fm, .asm and .map
rem /LTCG link time optimization, not really used for unity builds I suppose
rem not used: /Zc:__cplusplus

rem remove debug from release
set defines=-DCOMPRESSOR_WIN32=1 -DCOMPRESSOR_DEBUG=1
set flags=/W4 /FC /Oi /EHa- /GR- /GS /std:c++20 /utf-8 /nologo

Expand All @@ -36,9 +74,7 @@ if !config! == debug (
set flags=!flags! /MD /Od
)

echo !defines!
echo !flags!
set flags=!defines! !flags!
set flagsCombined=!defines! !flags!

rem TODO: take a look at /FIXED
rem TODO: examine flags that might make Microsoft Defender flag as a virus
Expand All @@ -51,26 +87,66 @@ set dxLibraries=d3d11.lib dxgi.lib d3dcompiler.lib

set buildFailed=0

if exist *.pdb del /q *.pdb
if !modeApp! == 1 (
if exist *.pdb del /q win32_compressor.pdb

cl !flags! ../src/win32_compressor.cpp /I ../src /I ../vendor/imgui ^
/link !linkerFlags! !win32Libraries! !dxLibraries!
echo !defines!
echo !flags!

if ERRORLEVEL 1 (
set buildFailed=1
echo win32_compressor.cpp failed
)
cl !flagsCombined! ../src/win32_compressor.cpp /I ../src /I ../vendor/imgui ^
/link !linkerFlags! !win32Libraries! !dxLibraries!

popd
if ERRORLEVEL 1 (
set buildFailed=1
echo win32_compressor.cpp failed
)

rem Don't remember the layout when testing UX
IF EXIST imgui.ini del imgui.ini

set NOW=!TIME:~0,8!

rem Don't remember the layout when testing UX
IF EXIST imgui.ini del imgui.ini
echo.
if !buildFailed! NEQ 0 (
echo Build failed !DATE! !NOW!
) else (
echo Build succeeded !DATE! !NOW!
)
)

if !modeTest! == 1 (
echo Building tests...
set defines=!defines! -DCOMPRESSOR_TESTS=1
echo !defines!
echo !flags!
set flagsCombined=!defines! !flags!

cl !flagsCombined! /wd4505 ../src/compressor_tests.cpp /I ../src /I ../vendor ^
/link /SUBSYSTEM:CONSOLE !win32Libraries!
set NOW=!TIME:~0,8!
if ERRORLEVEL 1 (
echo tests.cpp failed !DATE! !NOW!
set buildFailed=1
) else (
echo Running tests...
rem --success, show all INFO output
compressor_tests.exe --no-intro
if ERRORLEVEL 1 (
set buildFailed=1
echo Tests failed !DATE! !NOW!
) else (
echo Tests passed !DATE! !NOW!
)
)
)

set NOW=!TIME:~0,8!
popd

echo.
if !buildFailed! NEQ 0 (
echo Build failed !DATE! !NOW!
echo BUILD FAILED
exit /b 1
) else (
echo Build succeeded !DATE! !NOW!
echo BUILD SUCCESS
exit /b 0
)
2 changes: 2 additions & 0 deletions run_ci.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
act -P windows-2025-vs2026=-self-hosted
3 changes: 3 additions & 0 deletions src/compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ StrLengthW(const wchar* str) {
return len;
}

/**
* Inspects the bytes in order
*/
static bool32
StrEqual(const char* a, const char* b) {
ASSERT(a && b);
Expand Down
Loading
Loading