Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build anki web assets from rslib-bridge/anki submodule #217

Merged
merged 14 commits into from
Jul 19, 2022
Merged
8 changes: 7 additions & 1 deletion .github/workflows/robolectric_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@ jobs:

- name: Run Tests (win)
if: matrix.os == 'windows-latest'
run: ./gradlew rsdroid:test -x jar -x cargoBuildArm -x cargoBuildX86 -x cargoBuildArm64 -x cargoBuildX86_64
run: |
echo "Removing Bash from WSL"
mikehardy marked this conversation as resolved.
Show resolved Hide resolved
rm.exe "C:/WINDOWS/system32/bash.EXE"
Set-Alias -Name bash -Value "C:/msys64/usr/bin/bash.exe"
$env:BAZEL_SH = "C:/msys64/usr/bin/bash.exe"
[Environment]::SetEnvironmentVariable('BAZEL_SH', 'C:/msys64/usr/bin/bash.exe', 'Machine')
./gradlew rsdroid:test -x jar -x cargoBuildArm -x cargoBuildX86 -x cargoBuildArm64 -x cargoBuildX86_64
9 changes: 9 additions & 0 deletions .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
bash: "C:/msys64/usr/bin/bash.exe"
BAZEL_SH: "C:/msys64/usr/bin/bash.exe"

jobs:
build:
timeout-minutes: 80
Expand Down Expand Up @@ -134,4 +138,9 @@ jobs:
$Env:ANDROID_NDK_PATH = "C:\ProgramFiles\Android\android-sdk\ndk-bundle"
$Env:ANDROID_SDK_ROOT = "C:\ProgramFiles\Android\android-sdk"
$env:ANDROID_HOME
echo "Removing Bash from WSL"
krmanik marked this conversation as resolved.
Show resolved Hide resolved
rm.exe "C:/WINDOWS/system32/bash.EXE"
Set-Alias -Name bash -Value "C:/msys64/usr/bin/bash.exe"
$env:BAZEL_SH = "C:/msys64/usr/bin/bash.exe"
[Environment]::SetEnvironmentVariable('BAZEL_SH', 'C:/msys64/usr/bin/bash.exe', 'Machine')
./gradlew clean assembleRelease -DtestBuildType=release # assembleAndroidTest
12 changes: 11 additions & 1 deletion .github/workflows/windows_pure_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
bash: "C:/msys64/usr/bin/bash.exe"
BAZEL_SH: "C:/msys64/usr/bin/bash.exe"

jobs:
build:
runs-on: windows-latest
Expand Down Expand Up @@ -95,4 +99,10 @@ jobs:
${{ runner.os }}-v1-node-module-cache

- name: Build
run: ./gradlew clean assembleRelease -DtestBuildType=release
run: |
echo "Removing Bash from WSL"
krmanik marked this conversation as resolved.
Show resolved Hide resolved
rm.exe "C:/WINDOWS/system32/bash.EXE"
Set-Alias -Name bash -Value "C:/msys64/usr/bin/bash.exe"
$env:BAZEL_SH = "C:/msys64/usr/bin/bash.exe"
[Environment]::SetEnvironmentVariable('BAZEL_SH', 'C:/msys64/usr/bin/bash.exe', 'Machine')
./gradlew clean assembleRelease -DtestBuildType=release
4 changes: 2 additions & 2 deletions rsdroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ android {

task buildAnkiWebAssets(type: Exec) {
krmanik marked this conversation as resolved.
Show resolved Hide resolved
workingDir "$rootDir"
String toolPath = System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows') ? 'tools\\web\\build-web-assets.ps1' : 'tools/web/build-web-assets.sh'
String toolPath = System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows') ? 'tools/web/build-web-assets.ps1' : 'tools/web/build-web-assets.sh'
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'Powershell -File', toolPath
commandLine 'PowerShell', '-File', toolPath
} else {
commandLine 'sh', '-c', toolPath
}
Expand Down
19 changes: 11 additions & 8 deletions tools/web/build-web-assets.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
Set-Alias -Name bash -Value "C:/msys64/usr/bin/bash.exe"
$env:BAZEL_SH = "C:/msys64/usr/bin/bash.exe"
krmanik marked this conversation as resolved.
Show resolved Hide resolved

$SRC_DIR = (Get-Item .).FullName
$ROOT_DIR = (Get-Item D:/a/).FullName
$ANKI_SRC = (Get-Item $SRC_DIR/rslib-bridge/anki).FullName
$TEMP_DIR = (Get-Item $ENV:Temp).FullName
$TEMP_DIR = (Get-Item $ENV:TEMP).FullName

New-Item -P $SRC_DIR/rsdroid/build/generated/anki_artifacts/web -itemType Directory
$BUILD_DIR = (Get-Item $SRC_DIR/rsdroid/build/generated/anki_artifacts).FullName

Set-Location -Path $ANKI_SRC
bazel build --symlink_prefix=$TEMP_DIR/.bazel/ -c opt buildinfo.txt --verbose_failures
Copy-Item -Path $TEMP_DIR/.bazel/bin/buildinfo.txt -Destination $BUILD_DIR/buildinfo.txt -PassThru

bazel build ts/reviewer/reviewer_extras_bundle --symlink_prefix=$TEMP_DIR/.bazel/

Set-Location -Path $ANKI_SRC/qt/aqt/data/web/pages
bazel build pages --symlink_prefix=$TEMP_DIR/.bazel/
bazel --output_user_root=$ROOT_DIR/_bzl build -c opt buildinfo.txt --symlink_prefix=$TEMP_DIR/.bazel/ --verbose_failures
Copy-Item -Path $TEMP_DIR/.bazel/bin/buildinfo.txt -Destination $BUILD_DIR/buildinfo.txt -PassThru

Copy-Item -Path "$TEMP_DIR\.bazel\bin\qt\aqt\data\web\pages\*" -Destination $BUILD_DIR/web -Recurse -PassThru
bazel --output_user_root=$ROOT_DIR/_bzl build ts/reviewer/reviewer_extras_bundle --symlink_prefix=$TEMP_DIR/.bazel/ --verbose_failures
Copy-Item -Path $TEMP_DIR/.bazel/bin/ts/reviewer/reviewer_extras_bundle.js -Destination $BUILD_DIR/web -PassThru

bazel --output_user_root=$ROOT_DIR/_bzl build qt/aqt/data/web/pages --symlink_prefix=$TEMP_DIR/.bazel/ --verbose_failures
Get-Childitem $TEMP_DIR/.bazel/bin/qt/aqt/data/web/pages -Recurse -Include *.html,*.js,*.css | Copy-Item -Destination $BUILD_DIR/web -PassThru