From b692426db4bd88dc8dfad50da70abb4dbb8792dd Mon Sep 17 00:00:00 2001 From: voletro <65332602+voletro@users.noreply.github.com> Date: Thu, 30 Jun 2022 11:44:14 +1000 Subject: [PATCH 1/7] Rewrite of setup-system.ps1 This is a full rewrite of setup-system.ps1 that sets up a users machine for Spacedrive development. The CONTRIBUTING.md also includes info on this file. --- .github/scripts/setup-system.ps1 | 168 +++++++++++++++++++++++++++++-- CONTRIBUTING.md | 2 + 2 files changed, 161 insertions(+), 9 deletions(-) diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index 9a8a206b5..786cdd824 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -1,10 +1,160 @@ -Write-Host "This script is currently being used by CI and will need some more work before anyone can use it like the 'setup-system.sh' script for macOS and Linux!" +# Get temp folder +$temp = [System.IO.Path]::GetTempPath() -$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath) -Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n" -Invoke-WebRequest "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z" -OutFile ffmpeg-release-full-shared.7z -7z x ffmpeg-release-full-shared.7z -mkdir ffmpeg -mv ffmpeg-*/* ffmpeg/ -Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n" -Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n" \ No newline at end of file +# Get current running dir +$currentLocation = $((Get-Location).path) + +$Host.UI.RawUI.WindowTitle = "Spacedrive DE Setup (Administrator)" +$Host.UI.RawUI.BackgroundColor = "Black" + +# Check to see if a command exists (eg if an app is installed) +Function CheckCommand { + + Param ($command) + + $oldPreference = $ErrorActionPreference + + $ErrorActionPreference = 'stop' + + try { if (Get-Command $command) { RETURN $true } } + + Catch { RETURN $false } + + Finally { $ErrorActionPreference = $oldPreference } + +} + +Clear-Host + +Write-Host "Spacedrive Development Environment Setup" -ForegroundColor Magenta +Write-Host @" + +To set up your machine for Spacedrive development, this script will do the following: + +1) Check for Rust and Cargo + +2) Install pnpm (if not installed) + +3) Install the latest version of Node.js using pnpm + +4) Install LLVM (compiler for ffmpeg-rust) + +4) Download ffmpeg and set as an environment variable + +"@ + +Write-Host "Press the Enter key to begin, or press CTRL + C to stop." -ForegroundColor Gray + +Read-Host + +Write-Host "Checking for Rust and Cargo..." -ForegroundColor Yellow +Start-Sleep -Milliseconds 150 + +$cargoCheck = CheckCommand cargo + +if ($cargoCheck -eq $false) { + Write-Host @" +Cargo is not installed. + +To use Spacedrive on Windows, Cargo needs to be installed. +The Visual Studio C++ Build tools are also required. +Instructions can be found here: + +https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-windows + +Once you have installed Cargo, re-run this script. + +"@ + Write-Host "Press the Enter key to close." -ForegroundColor Gray + Read-Host + Exit +} +else { + Write-Host "Cargo is installed." +} + +Write-Host +Write-Host "Checking for pnpm..." -ForegroundColor Yellow +Start-Sleep -Milliseconds 150 + +$pnpmCheck = CheckCommand pnpm +if ($pnpmCheck -eq $false) { + + Write-Host "pnpm is not installed. Installing now." + Write-Host "Running the pnpm installer..." + + #pnpm installer taken from https://pnpm.io + Invoke-WebRequest https://get.pnpm.io/install.ps1 -useb | Invoke-Expression + + # Reset the PATH env variables to make sure pnpm is accessible + $env:PNPM_HOME = [System.Environment]::GetEnvironmentVariable("PNPM_HOME", "User") + $env:Path = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("Path", "User")) + +} +else { + Write-Host "pnpm is installed." +} + +Write-Host +Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow +Write-Host "This will set your global Node version to the latest!" +Start-Sleep -Milliseconds 150 + +# Runs the pnpm command to use the latest version of node, which also installs it +Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs + +Write-Host +Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow +# Downloads latest installer for LLVM +$filenamePattern = "*-win64.exe" +$releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest" +$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url + +Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe" + +Write-Host +Write-Host "Running the LLVM installer..." -ForegroundColor Yellow +Write-Host "Please follow the instructions to install LLVM." +Write-Host "Ensure you add LLVM to your PATH." + +Start-Process "$temp\llvm.exe" -Wait + +Write-Host +Write-Host "Downloading the latest ffmpeg build..." -ForegroundColor Yellow + +# Downloads the latest shared build of ffmpeg from GitHub +$filenamePattern = "*-full_build-shared.zip" +$releasesUri = "https://api.github.com/repos/GyanD/codexffmpeg/releases/latest" +$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url +$filename = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).name +$remove = ".zip" +$foldername = $filename.Substring(0, ($filename.Length - $remove.Length)) + +Start-BitsTransfer -Source $downloadUri -Destination "$temp\ffmpeg.zip" + +Write-Host +Write-Host "Expanding ffmpeg zip..." -ForegroundColor Yellow + +Expand-Archive "$temp\ffmpeg.zip" $HOME -ErrorAction SilentlyContinue + +Remove-Item "$temp\ffmpeg.zip" + +Write-Host +Write-Host "Setting environment variables..." -ForegroundColor Yellow + +# Sets environment variable for ffmpeg +[System.Environment]::SetEnvironmentVariable('FFMPEG_DIR', "$HOME\$foldername", [System.EnvironmentVariableTarget]::User) + +Write-Host +Write-Host "Copying Required .dll files..." -ForegroundColor Yellow + +# Create target\debug folder, continue if already exists +New-Item -Path $currentLocation\target\debug -ItemType Directory -ErrorAction SilentlyContinue + +# Copies all .dll required for rust-ffmpeg to target\debug folder +Get-ChildItem "$HOME\$foldername\bin" -recurse -filter *.dll | Copy-Item -Destination "$currentLocation\target\debug" + +Write-Host +Write-Host "Your machine has been setup for Spacedrive development!" +Write-Host "Press the Enter key to close." -ForegroundColor Gray +Read-Host \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 942c66d63..7c7f383f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,6 +41,8 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal - `$ cd spacedrive` - For Linux or MacOS users run: `./.github/scripts/setup-system.sh` - This will install FFMPEG and any other required dependencies for Spacedrive to build. +- For Windows users run using PowerShell: `.\.github\scripts\setup-system.ps1` + - This will install pnpm, LLVM, FFMPEG and any other required dependencies for Spacedrive to build. - `$ pnpm i` - `$ pnpm prep` - Runs all necessary codegen & builds required dependencies. From 65ad2bab7e274ac5ce7b3217f0f96f008d18f015 Mon Sep 17 00:00:00 2001 From: voletro <65332602+voletro@users.noreply.github.com> Date: Fri, 1 Jul 2022 10:38:41 +1000 Subject: [PATCH 2/7] Remove user input so it works with ci. --- .github/scripts/setup-system.ps1 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index 786cdd824..99c8049e8 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -43,10 +43,6 @@ To set up your machine for Spacedrive development, this script will do the follo "@ -Write-Host "Press the Enter key to begin, or press CTRL + C to stop." -ForegroundColor Gray - -Read-Host - Write-Host "Checking for Rust and Cargo..." -ForegroundColor Yellow Start-Sleep -Milliseconds 150 @@ -65,8 +61,6 @@ https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-windows Once you have installed Cargo, re-run this script. "@ - Write-Host "Press the Enter key to close." -ForegroundColor Gray - Read-Host Exit } else { @@ -156,5 +150,3 @@ Get-ChildItem "$HOME\$foldername\bin" -recurse -filter *.dll | Copy-Item -Destin Write-Host Write-Host "Your machine has been setup for Spacedrive development!" -Write-Host "Press the Enter key to close." -ForegroundColor Gray -Read-Host \ No newline at end of file From b783c32a04db59e3436d176ab26971d485df8616 Mon Sep 17 00:00:00 2001 From: voletro <65332602+voletro@users.noreply.github.com> Date: Tue, 5 Jul 2022 11:21:42 +1000 Subject: [PATCH 3/7] Added headless mode, added LLVM installer to ci. --- .github/scripts/setup-system.ps1 | 67 ++++++++++++++++++++------------ .github/workflows/ci.yml | 20 ++++++---- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index 99c8049e8..b2651a40c 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -1,12 +1,15 @@ +# Get ci parameter to check if running with ci +param( + [Parameter()] + [Switch]$ci +) + # Get temp folder $temp = [System.IO.Path]::GetTempPath() # Get current running dir $currentLocation = $((Get-Location).path) -$Host.UI.RawUI.WindowTitle = "Spacedrive DE Setup (Administrator)" -$Host.UI.RawUI.BackgroundColor = "Black" - # Check to see if a command exists (eg if an app is installed) Function CheckCommand { @@ -24,8 +27,6 @@ Function CheckCommand { } -Clear-Host - Write-Host "Spacedrive Development Environment Setup" -ForegroundColor Magenta Write-Host @" @@ -80,7 +81,7 @@ if ($pnpmCheck -eq $false) { #pnpm installer taken from https://pnpm.io Invoke-WebRequest https://get.pnpm.io/install.ps1 -useb | Invoke-Expression - # Reset the PATH env variables to make sure pnpm is accessible + # Reset the PATH env variables to make sure pnpm is accessible $env:PNPM_HOME = [System.Environment]::GetEnvironmentVariable("PNPM_HOME", "User") $env:Path = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("Path", "User")) @@ -89,29 +90,47 @@ else { Write-Host "pnpm is installed." } -Write-Host -Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow -Write-Host "This will set your global Node version to the latest!" -Start-Sleep -Milliseconds 150 +# A GitHub Action takes care of installing node, so this isn't necessary if running in the ci. +if ($ci -eq $True) { + Write-Host + Write-Host "Running with Ci, skipping Node install." -ForegroundColor Yellow +} +else { + Write-Host + Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow + Write-Host "This will set your global Node version to the latest!" + Start-Sleep -Milliseconds 150 -# Runs the pnpm command to use the latest version of node, which also installs it -Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs + # Runs the pnpm command to use the latest version of node, which also installs it + Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs +} -Write-Host -Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow -# Downloads latest installer for LLVM -$filenamePattern = "*-win64.exe" -$releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest" -$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url -Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe" -Write-Host -Write-Host "Running the LLVM installer..." -ForegroundColor Yellow -Write-Host "Please follow the instructions to install LLVM." -Write-Host "Ensure you add LLVM to your PATH." +# We can't run the installer if running in ci, so we install LLVM through a GitHub Action instead. +if ($ci -eq $True) { + Write-Host + Write-Host "Running with Ci, skipping LLVM install." -ForegroundColor Yellow +} +else { + Write-Host + Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow + # Downloads latest installer for LLVM + $filenamePattern = "*-win64.exe" + $releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest" + $downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url + + Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe" + + Write-Host + Write-Host "Running the LLVM installer..." -ForegroundColor Yellow + Write-Host "Please follow the instructions to install LLVM." + Write-Host "Ensure you add LLVM to your PATH." + + Start-Process "$temp\llvm.exe" -Wait +} + -Start-Process "$temp\llvm.exe" -Wait Write-Host Write-Host "Downloading the latest ffmpeg build..." -ForegroundColor Yellow diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 013354f45..d78582456 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: id: pnpm-cache run: | echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - + - uses: actions/cache@v3 name: Setup pnpm cache with: @@ -44,7 +44,7 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - + - name: Install pnpm dependencies run: pnpm --frozen-lockfile i @@ -81,7 +81,7 @@ jobs: with: version: 7 run_install: false - + - name: Install Rust stable uses: actions-rs/toolchain@v1 with: @@ -89,19 +89,25 @@ jobs: profile: minimal override: true components: rustfmt, rust-src - + - name: Cache Rust Dependencies uses: Swatinem/rust-cache@v1 with: sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }} + - name: Install LLVM and Clang + if: matrix.platform == 'windows-latest' + uses: KyleMayes/install-llvm-action@v1 + with: + version: '14' + - name: Run 'setup-system.sh' script if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest' run: ./.github/scripts/setup-system.sh - + - name: Run 'setup-system.ps1' script if: matrix.platform == 'windows-latest' - run: ./.github/scripts/setup-system.ps1 + run: ./.github/scripts/setup-system.ps1 -ci - name: Get pnpm store directory id: pnpm-cache @@ -116,7 +122,7 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Install pnpm dependencies run: pnpm --frozen-lockfile i - + - name: Cache Prisma codegen id: cache-prisma uses: actions/cache@v3 From 6ee4974068ab068b027ef55ff1c698e89d68cb4e Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Tue, 5 Jul 2022 23:55:44 +0800 Subject: [PATCH 4/7] remove Cargo frozen flag --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d78582456..b1ab6a535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,13 +133,13 @@ jobs: - name: Generate Prisma client working-directory: core if: steps.cache-prisma.outputs.cache-hit != 'true' - run: cargo run --frozen -p prisma-cli --release -- generate + run: cargo run -p prisma-cli --release -- generate - name: Cargo fetch run: cargo fetch - name: Check Core - run: cargo check --frozen -p sdcore --release + run: cargo check -p sdcore --release - name: Bundle Desktop run: pnpm desktop tauri build @@ -147,7 +147,7 @@ jobs: - name: Build Server if: matrix.platform == 'ubuntu-latest' run: | - cargo build --frozen -p server --release + cargo build -p server --release cp ./target/release/server ./apps/server/server - name: Determine image name & tag From afd33b2d4c2e2490c5fe64f71763c3c5339ba1da Mon Sep 17 00:00:00 2001 From: voletro <65332602+voletro@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:28:28 +1000 Subject: [PATCH 5/7] Remove Action for LLVM, use action that is already built in. Set GH env variables. --- .github/scripts/setup-system.ps1 | 17 +++++++++++++---- .github/workflows/ci.yml | 6 ------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index b2651a40c..2ba78c9cf 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -107,11 +107,13 @@ else { -# We can't run the installer if running in ci, so we install LLVM through a GitHub Action instead. +# The ci has LLVM installed already, so we instead just set the env variables. if ($ci -eq $True) { Write-Host Write-Host "Running with Ci, skipping LLVM install." -ForegroundColor Yellow -} + + $VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath) + Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n" else { Write-Host Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow @@ -155,8 +157,15 @@ Remove-Item "$temp\ffmpeg.zip" Write-Host Write-Host "Setting environment variables..." -ForegroundColor Yellow -# Sets environment variable for ffmpeg -[System.Environment]::SetEnvironmentVariable('FFMPEG_DIR', "$HOME\$foldername", [System.EnvironmentVariableTarget]::User) +if ($ci -eq $True) { + # If running in ci, we need to use GITHUB_ENV and GITHUB_PATH instead of the normal PATH env variables, so we set them here + Add-Content $env:GITHUB_ENV "FFMPEG_DIR=$HOME\$foldername`n" + Add-Content $env:GITHUB_PATH "$HOME\$foldername\bin`n" +} +else { + # Sets environment variable for ffmpeg + [System.Environment]::SetEnvironmentVariable('FFMPEG_DIR', "$HOME\$foldername", [System.EnvironmentVariableTarget]::User) +} Write-Host Write-Host "Copying Required .dll files..." -ForegroundColor Yellow diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1ab6a535..d78d7b382 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,12 +95,6 @@ jobs: with: sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }} - - name: Install LLVM and Clang - if: matrix.platform == 'windows-latest' - uses: KyleMayes/install-llvm-action@v1 - with: - version: '14' - - name: Run 'setup-system.sh' script if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest' run: ./.github/scripts/setup-system.sh From c14da1c00c58980c6399f09a6c0104cba5fc05e6 Mon Sep 17 00:00:00 2001 From: voletro <65332602+voletro@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:33:23 +1000 Subject: [PATCH 6/7] Add a close bracket (i'm dumb) --- .github/scripts/setup-system.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1 index 2ba78c9cf..29efe7a36 100644 --- a/.github/scripts/setup-system.ps1 +++ b/.github/scripts/setup-system.ps1 @@ -114,7 +114,8 @@ if ($ci -eq $True) { $VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath) Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n" -else { + +} else { Write-Host Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow # Downloads latest installer for LLVM From e496e42cbe785e4cf1cae3ee26ae9628865477e0 Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Thu, 7 Jul 2022 12:50:43 +0800 Subject: [PATCH 7/7] fix Tauri Appimage icon --- apps/desktop/src-tauri/tauri.linux.conf.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src-tauri/tauri.linux.conf.json b/apps/desktop/src-tauri/tauri.linux.conf.json index 51b5a339d..5fc781e7f 100644 --- a/apps/desktop/src-tauri/tauri.linux.conf.json +++ b/apps/desktop/src-tauri/tauri.linux.conf.json @@ -15,7 +15,13 @@ "active": true, "targets": "all", "identifier": "com.spacedrive.desktop", - "icon": ["icons/icon.icns"], + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], "resources": [], "externalBin": [], "copyright": "Spacedrive Technology Inc.",