Skip to content

Instantly share code, notes, and snippets.

@cpyarger
Last active February 8, 2022 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpyarger/70bfb0d4cae1bcd13faa94e134aa8b5c to your computer and use it in GitHub Desktop.
Save cpyarger/70bfb0d4cae1bcd13faa94e134aa8b5c to your computer and use it in GitHub Desktop.
Automated setup and install obs-studio build environment on windows 10
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/cpyarger/70bfb0d4cae1bcd13faa94e134aa8b5c/raw/bd082a975e6b264ab83cacdf3775c05d106f2f78/OBS_ENV_SETUP.ps1'))
# This script sets up everything needed to do obs-studio development on windows 10
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install Git
choco install -y git
# Install Cmake
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
# Install 7zip and create alias
choco install -y 7zip
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
# Create Directories
New-Item -Path 'C:\obs-deps' -ItemType Directory -force
New-Item -Path 'C:\obs-deps\VS' -ItemType Directory -force
New-Item -Path 'C:\obs' -ItemType Directory -force
# Download and extract Dependencies
Invoke-WebRequest -URI https://obsproject.com/downloads/dependencies2019.zip -OutFile 'C:\obs-deps\dependencies2019.zip'
Expand-Archive -LiteralPath 'C:\obs-deps\dependencies2019.zip' -DestinationPath C:\obs-deps
# Download and extract Qt
Invoke-WebRequest -URI https://cdn-fastly.obsproject.com/downloads/Qt_5.15.2.7z -OutFile 'C:\obs-deps\Qt_5.15.2.7z'
sz x -o"C:\obs-deps" "C:\obs-deps\Qt_5.15.2.7z" -r ;
# Download and extract CEF
Invoke-WebRequest -URI https://cdn-fastly.obsproject.com/downloads/cef_binary_4638_windows_x64.zip -OutFile 'C:\obs-deps\cef_binary_4638_windows_x64.zip'
Expand-Archive -LiteralPath 'C:\obs-deps\cef_binary_4638_windows_x64.zip' -DestinationPath C:\obs-deps
# Download and install Visual Studio 2019
$url = "https://aka.ms/vs/17/release/vs_community.exe"
$downloadPath = "C:\obs-deps\VS"
$filePath = "C:\obs-deps\VS\vs_community.exe"
Invoke-WebRequest -URI $url -OutFile $filePath
$workloadArgument = @(
'--add Microsoft.Net.Component.4.7.1.SDK'
'--add Microsoft.VisualStudio.Component.Windows10SDK.20348'
'--add Microsoft.Net.Component.4.7.1.TargetingPack'
)
$optionsAddLayout = [string]::Join(" ", $workloadArgument )
$optionsQuiet = "--quiet"
$optionsLayout = "--layout $downloadPath"
$optionsIncludeRecommended = "--includeRecommended"
$vsOptions = @(
$optionsLayout,
$optionsIncludeRecommended,
$optionsAddLayout
$optionsQuiet
)
Start-Process -FilePath $filePath -ArgumentList $vsOptions
# Clone OBS
cd C:\obs
git clone --recursive https://github.com/obsproject/obs-studio.git
New-Item -Path 'C:\obs\obs-studio\build' -ItemType Directory -force
cd C:\obs\obs-studio\build
# Set Environment Variables globally
[Environment]::SetEnvironmentVariable("DepsPath32", "C:\obs-deps\win32", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("DepsPath64", "C:\obs-deps\win64", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("DepsPath", "C:\obs-deps\win64", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("QTDIR", "C:\obs-deps\5.15.2\msvc2019_64", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("QTDIR32", "C:\obs-deps\5.15.2\msvc2019", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("QTDIR64", "C:\obs-deps\5.15.2\msvc2019_64", [System.EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("CEF_ROOT_DIR", "C:\obs-deps\cef_binary_4638_windows_x64", [System.EnvironmentVariableTarget]::Machine)
# Set Environment Variables for this process (means we dont need to restart the shell for them to work)
[Environment]::SetEnvironmentVariable("DepsPath32", "C:\obs-deps\win32", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("DepsPath64", "C:\obs-deps\win64", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("DepsPath", "C:\obs-deps\win64", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("QTDIR", "C:\obs-deps\5.15.2\msvc2019_64", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("QTDIR32", "C:\obs-deps\5.15.2\msvc2019", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("QTDIR64", "C:\obs-deps\5.15.2\msvc2019_64", [System.EnvironmentVariableTarget]::Process)
[Environment]::SetEnvironmentVariable("CEF_ROOT_DIR", "C:\obs-deps\cef_binary_4638_windows_x64", [System.EnvironmentVariableTarget]::Process)
C:\Program Files\CMake\bin\cmake-gui.exe ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment