Skip to content

Commit

Permalink
Merge branch 'main' into feat/temp-runtime-read-file
Browse files Browse the repository at this point in the history
Signed-off-by: Mateo Miccino <mateomiccino@gmail.com>
  • Loading branch information
kuruk-mm committed Aug 28, 2023
2 parents 6782fb6 + 1b4a98b commit 76c5e19
Show file tree
Hide file tree
Showing 54 changed files with 1,748 additions and 298 deletions.
238 changes: 146 additions & 92 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,46 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.71
override: true
components: clippy, rustfmt
- run: rustup component add rustfmt
- name: Set up Python
uses: actions/setup-python@v4
- name: Install gdtoolkit 4
run: pip3 install "gdtoolkit==4.*"
- name: Check format GDScript
run: gdformat -d godot/

# Depedencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
- name: install ffmpeg deps (linux)
run: sudo apt install -y --no-install-recommends clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev
if: runner.os == 'linux'

- name: cargo xtask install
working-directory: rust
run: cargo xtask install --no-templates
- uses: actions-rs/cargo@v1
name: cargo check
with:
command: check
args: --manifest-path rust/Cargo.toml
- uses: actions-rs/cargo@v1
name: cargo fmt
with:
command: fmt
args: --manifest-path rust/Cargo.toml --all -- --check
- uses: actions-rs/cargo@v1
name: cargo clippy
with:
command: clippy
args: --manifest-path rust/Cargo.toml -- -D warnings
working-directory: rust/xtask
run: cargo run -- install --no-templates

- name: cargo check
working-directory: rust/decentraland-godot-lib
run: cargo check

- name: cargo fmt
working-directory: rust/decentraland-godot-lib
run: cargo fmt --all -- --check

- name: cargo clippy
working-directory: rust/decentraland-godot-lib
run: cargo clippy -- -D warnings


coverage:
name: Coverage
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
env:
GODOT4_BIN: ${{ github.workspace }}/.bin/godot/godot4_bin
steps:
Expand All @@ -64,34 +69,49 @@ jobs:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
toolchain: 1.71
override: true
components: llvm-tools-preview

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
rust/Cargo.lock
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust/decentraland-godot-lib/target/
rust/decentraland-godot-lib/Cargo.lock
rust/xtask/target/
rust/xtask/Cargo.lock
key: coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: coverage-cargo-


# Depedencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
- name: install ffmpeg deps (linux)
run: sudo apt install -y --no-install-recommends clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev
if: runner.os == 'linux'

- name: cargo xtask install
working-directory: rust
run: cargo xtask install --no-templates
working-directory: rust/xtask
run: cargo run -- install --no-templates

# Build section

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run xtask coverage
working-directory: rust
run: cargo xtask coverage
working-directory: rust/xtask
run: cargo run -- coverage

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
Expand All @@ -100,95 +120,129 @@ jobs:

build:
name: Build and test
if: ${{ github.ref == 'refs/heads/main' }}
# Comment next line to test this job on PRs
if: ${{ github.ref == 'refs/heads/main' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
rust: [stable]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
GODOT4_BIN: ${{ github.workspace }}/.bin/godot/godot4_bin
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.71
override: true

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust/target/
rust/decentraland-godot-lib/target/
rust/decentraland-godot-lib/Cargo.lock
rust/xtask/target/
rust/xtask/Cargo.lock
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: cargo xtask install
working-directory: rust
run: cargo xtask install

- name: Set up target platform
if: ${{ matrix.os == 'macos-latest' }}

# Depedencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
- name: install ffmpeg deps (linux)
run: sudo apt install -y --no-install-recommends clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev
if: runner.os == 'linux'

# => MacOS
- name: install ffmpeg deps (macOs)
if: runner.os == 'macos'
run: brew install ffmpeg pkg-config

# TODO: cross-build deprecated with the ffmpeg integration
# - name: Set up target platform
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# rustup target add x86_64-apple-darwin
# rustup target add aarch64-apple-darwin


# => Windows
- name: set CLANG path for ffmpeg deps (windows)
if: runner.os == 'windows'
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- uses: actions-rs/cargo@v1
if: ${{ matrix.os != 'macos-latest' }}
name: cargo build
with:
command: build
args: --manifest-path rust/Cargo.toml --release

- uses: actions-rs/cargo@v1
name: build for x86_64 (macos)
if: ${{ matrix.os == 'macos-latest' }}
with:
command: build
args: --manifest-path rust/Cargo.toml --release --target=x86_64-apple-darwin
$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"
# => All platforms
- name: cargo xtask install
working-directory: rust/xtask
run: cargo run -- install

# Build section
- name: cargo build
working-directory: rust/decentraland-godot-lib
run: cargo build --release

# TODO: cross-build deprecated with the ffmpeg integration

# - uses: actions-rs/cargo@v1
# name: build for x86_64 (macos)
# if: ${{ matrix.os == 'macos-latest' }}
# with:
# command: build
# args: --manifest-path rust/decentraland-godot-lib/Cargo.toml --release --target=x86_64-apple-darwin

- uses: actions-rs/cargo@v1
name: build for arm64 (macos)
if: ${{ matrix.os == 'macos-latest' }}
with:
command: build
args: --manifest-path rust/Cargo.toml --release --target=aarch64-apple-darwin

- uses: actions-rs/cargo@v1
name: cargo test
with:
command: test
args: --manifest-path rust/Cargo.toml --release

- name: Make universal library
if: ${{ matrix.os == 'macos-latest' }}
# - uses: actions-rs/cargo@v1
# name: build for arm64 (macos)
# if: ${{ matrix.os == 'macos-latest' }}
# with:
# command: build
# args: --manifest-path rust/decentraland-godot-lib/Cargo.toml --release --target=aarch64-apple-darwin

- name: cargo test
working-directory: rust/decentraland-godot-lib
run: cargo test

# TODO: cross-build deprecated with the ffmpeg integration
# Package section
# # => MacOS
# - name: Make universal library
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# mkdir rust/decentraland-godot-lib/target/release || true
# lipo -create rust/decentraland-godot-lib/target/x86_64-apple-darwin/release/libdecentraland_godot_lib.dylib rust/decentraland-godot-lib/target/aarch64-apple-darwin/release/libdecentraland_godot_lib.dylib -output rust/decentraland-godot-lib/target/release/libdecentraland_godot_lib.dylib

# => Linux/MacOS (unix)
- name: Copy library (linux/macos)
if: ${{ matrix.os != 'windows-latest' }}
run: |
mkdir rust/target/release || true
lipo -create rust/target/x86_64-apple-darwin/release/libdecentraland_godot_lib.dylib rust/target/aarch64-apple-darwin/release/libdecentraland_godot_lib.dylib -output rust/target/release/libdecentraland_godot_lib.dylib
cp rust/decentraland-godot-lib/target/release/libdecentraland_godot_lib.so godot/lib/ || true
cp rust/decentraland-godot-lib/target/release/libdecentraland_godot_lib.dylib godot/lib/ || true
- name: Copy library (win)
# => Windows
- name: Copy library (windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cp rust/target/release/decentraland_godot_lib.dll godot/lib/
- name: Copy library (unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
cp rust/target/release/libdecentraland_godot_lib.so godot/lib/ || true
cp rust/target/release/libdecentraland_godot_lib.dylib godot/lib/ || true
cp rust/decentraland-godot-lib/target/release/decentraland_godot_lib.dll godot/lib/
# Export section (multi platform)
- name: Export
working-directory: rust
run: cargo xtask export
working-directory: rust/xtask
run: cargo run -- export

- uses: actions/upload-artifact@master
with:
name: decentraland-godot-${{ matrix.os }}
path: |
exports/**/*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.linkedProjects": ["rust/xtask/Cargo.toml", "rust/decentraland-godot-lib/Cargo.toml"]
}
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Decentraland Godot Rust

## Install dependencies

1. Install rust (https://www.rust-lang.org/tools/install)
2. Go to `rust` folder, and run `cargo xtask install`.
## Set up project

1. Clone the repo using `git clone https://github.com/decentraland/godot-explorer`
2. Install [rust](https://www.rust-lang.org/tools/install)
3. Download and install third party libraries
- **Linux** (apt-get based):
- Install alsa and udev: `sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev`
- Install ffmpeg deps: `sudo apt install -y --no-install-recommends clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev`
- Install Livekit deps: `sudo apt update -y; sudo apt install -y libssl-dev libx11-dev libgl1-mesa-dev libxext-dev`
- **MacOS**: `brew install ffmpeg pkg-config`
- **Windows**:
- download and unzip `https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z`
- set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately)
- set `FFMPEG_DIR` = `root folder where ffmpeg has been unzipped`
- add `ffmpeg\bin` to your `PATH`
- the `.github/workflows/ci.yml` file can be useful to guide you

2. Go to `rust/xtask` folder, and run `cargo run -- install`.

## Running and editting the project

You can run `cargo xtask run` to build the Rust library and execute the client.
- With `-r` it builds the library in release mode. Note: the Godot executable is an editor, so it's a `release_debug` build, see the Target section [here](https://docs.godotengine.org/en/stable/contributing/development/compiling/introduction_to_the_buildsystem.html) for more infromation.
- With `-e` it also builds the library, but the project edition is executed instead of the client.
1. Ensure you are in `rust/xtask` folder first
2. You can run `cargo run -- run` to build the Rust library and execute the client.
- With adding `-r` it builds the library in release mode. Note: the Godot executable is an editor, so it's a `release_debug` build, see the Target section [here](https://docs.godotengine.org/en/stable/contributing/development/compiling/introduction_to_the_buildsystem.html) for more infromation.
- With adding `-e` it also builds the library, but the project edition is executed instead of the client.

## GDScript formatting

Expand All @@ -19,4 +34,5 @@ When GD files are modified, they must be well-formated. You can autoformat all f
This repos is set up to be opened with Visual Studio Code. In the section `Run and Debug` in the Activity bar, you can find the configuration for your platform.

## Run test with coverage
Run `cargo xtask coverage --dev`. It'll create a `coverage` folder with the index.html with the all information. For running this commands you need to have lvvm tools and grcov, you can install them with `rustup component add llvm-tools-preview` and `cargo install grcov`.
1. Ensure you are in `rust/xtask` folder first
2. Run `cargo run -- coverage --dev`. It'll create a `coverage` folder with the index.html with the all information. For running this commands you need to have lvvm tools and grcov, you can install them with `rustup component add llvm-tools-preview` and `cargo install grcov`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="a629a89b73dc43168bdec2c7512d655e"
dest_md5="c0ec027fbbe01c6124f2613800a0e97c"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="7e78c5cae22b0d236cc58fb9daaf289a"
dest_md5="ad5cf229cf5dba0c063ab3c7fdabd2f0"

Binary file not shown.
Binary file modified godot/.godot/uid_cache.bin
Binary file not shown.
Binary file added godot/assets/sfx/ui_fade_in.wav
Binary file not shown.
Loading

0 comments on commit 76c5e19

Please sign in to comment.