Skip to content

Commit 02ab90a

Browse files
authored
Improved dev setup (#199)
* Improved build script to build debug as well * Debug for rust * Adds Meet sample to SDK package * Adding workspace for vscode * Adds ios builds for build script, enables verbose logging in Unity for ios * Meet is now sample in package * Added developer setup in README
1 parent f9ce7d0 commit 02ab90a

89 files changed

Lines changed: 11235 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22
#
33
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
44
#
5-
/[Ll]ibrary/
6-
/[Tt]emp/
7-
/[Oo]bj/
8-
/[Bb]uild/
9-
/[Bb]uilds/
10-
/[Ll]ogs/
11-
/[Uu]ser[Ss]ettings/
5+
**/[Ll]ibrary/
6+
**/[Tt]emp/
7+
**/[Oo]bj/
8+
**/[Bb]uild/
9+
**/[Bb]uilds/
10+
**/[Ll]ogs/
11+
**/[Uu]ser[Ss]ettings/
12+
13+
**/[Aa]ssets/Samples/
14+
**/[Aa]ssets/Samples.meta
15+
**/[Aa]ssets/TextMesh Pro/
16+
**/[Aa]ssets/TextMesh Pro.meta
1217

1318
# MemoryCaptures can get excessive in size.
1419
# They also could contain extremely sensitive data
15-
/[Mm]emoryCaptures/
20+
**/[Mm]emoryCaptures/
1621

1722
# Recordings can get excessive in size
18-
/[Rr]ecordings/
23+
**/[Rr]ecordings/
1924

2025
# Uncomment this line if you wish to ignore the asset store tools plugin
2126
# /[Aa]ssets/AssetStoreTools*
2227

2328
# Autogenerated Jetbrains Rider plugin
24-
/[Aa]ssets/Plugins/Editor/JetBrains*
29+
**/[Aa]ssets/Plugins/Editor/JetBrains*
2530

2631
# Visual Studio cache directory
2732
.vs/
@@ -65,11 +70,11 @@ sysinfo.txt
6570
crashlytics-build.properties
6671

6772
# Packed Addressables
68-
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
73+
**/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
6974

7075
# Temporary auto-generated Android Assets
71-
/[Aa]ssets/[Ss]treamingAssets/aa.meta
72-
/[Aa]ssets/[Ss]treamingAssets/aa/*
76+
**/[Aa]ssets/[Ss]treamingAssets/aa.meta
77+
**/[Aa]ssets/[Ss]treamingAssets/aa/*
7378

7479
.DS_Store
7580

@@ -81,5 +86,5 @@ downloads~
8186
/Runtime/Plugins/ffi-*/livekit_ffi.h.meta
8287

8388
# Ignore temporaries from GameCI
84-
/[Aa]rtifacts/
85-
/[Cc]odeCoverage/
89+
**/[Aa]rtifacts/
90+
**/[Cc]odeCoverage/

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "lldb",
6+
"request": "attach",
7+
"name": "Rust/C++ Unity auto",
8+
"waitFor": true,
9+
"program": "Unity",
10+
"sourceLanguages": ["rust"]
11+
},
12+
{
13+
"type": "lldb",
14+
"request": "attach",
15+
"name": "Rust/C++ Unity manual",
16+
"pid": "${command:pickProcess}", // For manual picking, if there are multiple Unity instances running
17+
"sourceLanguages": ["rust"]
18+
}
19+
]
20+
}

BuildScripts~/build_ffi_locally.sh

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,91 @@ GREEN='\033[0;32m'
1212
RESET='\033[0m'
1313

1414
usage() {
15-
echo "Usage: $0 <platform>"
15+
echo "Usage: $0 <platform> [build_type]"
1616
echo ""
1717
echo "Platforms:"
1818
echo " macos Build for aarch64-apple-darwin"
1919
echo " android Build for aarch64-linux-android"
20+
echo " ios Build for aarch64-apple-ios"
21+
echo ""
22+
echo "Build types (optional, defaults to 'debug'):"
23+
echo " release Optimized release build"
24+
echo " debug Debug build"
2025
exit 1
2126
}
2227

23-
if [ $# -ne 1 ]; then
24-
echo -e "${RED}Error: Expected exactly one argument.${RESET}"
28+
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
29+
echo -e "${RED}Error: Expected one or two arguments.${RESET}"
2530
usage
2631
fi
2732

2833
PLATFORM="$1"
34+
BUILD_TYPE="${2:-debug}"
35+
36+
case "$BUILD_TYPE" in
37+
release)
38+
BUILD_FLAG="--release"
39+
BUILD_DIR="release"
40+
;;
41+
debug)
42+
BUILD_FLAG=""
43+
BUILD_DIR="debug"
44+
;;
45+
*)
46+
echo -e "${RED}Error: Unknown build type '$BUILD_TYPE'. Expected 'release' or 'debug'.${RESET}"
47+
usage
48+
;;
49+
esac
2950

3051
case "$PLATFORM" in
52+
# MACOS
3153
macos)
32-
echo "Building for macOS (aarch64-apple-darwin)..."
54+
echo "Building for macOS (aarch64-apple-darwin) [$BUILD_TYPE]..."
3355
cargo build \
3456
--manifest-path "$MANIFEST" \
35-
--release \
36-
--workspace \
37-
-p livekit \
57+
$BUILD_FLAG \
58+
-p livekit-ffi \
3859
--target aarch64-apple-darwin
3960
BUILD_STATUS=$?
4061

41-
SRC="$BASE_TARGET/aarch64-apple-darwin/release/liblivekit_ffi.dylib"
62+
SRC="$BASE_TARGET/aarch64-apple-darwin/$BUILD_DIR/liblivekit_ffi.dylib"
4263
DST="$BASE_DST/ffi-macos-arm64/liblivekit_ffi.dylib"
4364
;;
65+
# ANDROID
4466
android)
45-
echo "Building for Android (aarch64-linux-android)..."
67+
echo "Building for Android (aarch64-linux-android) [$BUILD_TYPE]..."
4668
pushd "$ROOT/client-sdk-rust~" > /dev/null
4769
cargo ndk \
4870
--target aarch64-linux-android \
4971
build \
50-
--release \
51-
-p livekit \
52-
--workspace \
72+
$BUILD_FLAG \
73+
-p livekit-ffi \
5374
-v \
5475
--no-default-features \
5576
--features "rustls-tls-webpki-roots"
5677
BUILD_STATUS=$?
5778
popd > /dev/null
5879

59-
SRC="$BASE_TARGET/aarch64-linux-android/release/liblivekit_ffi.so"
80+
SRC="$BASE_TARGET/aarch64-linux-android/$BUILD_DIR/liblivekit_ffi.so"
6081
DST="$BASE_DST/ffi-android-arm64/liblivekit_ffi.so"
82+
JAR_SRC="$BASE_TARGET/aarch64-linux-android/$BUILD_DIR/libwebrtc.jar"
83+
JAR_DST="$BASE_DST/ffi-android-arm64/libwebrtc.jar"
84+
;;
85+
# IOS
86+
ios)
87+
echo "Building for iOS (aarch64-apple-ios) [$BUILD_TYPE]..."
88+
pushd "$ROOT/client-sdk-rust~/livekit-ffi" > /dev/null
89+
cargo rustc \
90+
--crate-type staticlib \
91+
$BUILD_FLAG \
92+
--target aarch64-apple-ios \
93+
--no-default-features \
94+
--features "rustls-tls-webpki-roots"
95+
BUILD_STATUS=$?
96+
popd > /dev/null
97+
98+
SRC="$BASE_TARGET/aarch64-apple-ios/$BUILD_DIR/liblivekit_ffi.a"
99+
DST="$BASE_DST/ffi-ios-arm64/liblivekit_ffi.a"
61100
;;
62101
*)
63102
echo -e "${RED}Error: Unknown platform '$PLATFORM'.${RESET}"
@@ -70,6 +109,7 @@ if [ $BUILD_STATUS -ne 0 ]; then
70109
exit 1
71110
fi
72111

112+
# Copy the built lib
73113
echo ""
74114
echo "Copying to $DST..."
75115
cp -f "$SRC" "$DST"
@@ -83,4 +123,18 @@ if [ $? -eq 0 ]; then
83123
else
84124
echo -e "${RED}Failed to copy $(basename "$DST"). Check that the source file exists and the destination directory is writable.${RESET}"
85125
exit 1
126+
fi
127+
128+
# For android, also copy the built libwebrtc.jar
129+
if [ "$PLATFORM" = "android" ]; then
130+
echo ""
131+
echo "Copying to $JAR_DST..."
132+
cp -f "$JAR_SRC" "$JAR_DST"
133+
134+
if [ $? -eq 0 ]; then
135+
echo -e "${GREEN}Copied $(basename "$JAR_DST") successfully.${RESET}"
136+
else
137+
echo -e "${RED}Failed to copy $(basename "$JAR_DST"). Check that the source file exists and the destination directory is writable.${RESET}"
138+
exit 1
139+
fi
86140
fi

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,40 @@ You can use the package manager to import local `client-sdk-unity` into your Uni
4848

4949
Or you can import the git url `https://github.com/livekit/client-sdk-unity.git` from the package manager.
5050

51+
## Local development
52+
5153
### Building Livekit plugins locally
5254

5355
For local development, initialize the git submodule containing the Rust code for the LiveKit plugin libraries.
5456

55-
There is a [helper script](https://github.com/livekit/client-sdk-unity/blob/main/BuildScripts~/build_ffi_locally.sh) to build the libraries locally and exchange the downloaded libraries with the build artifacts.
57+
There is a [helper script](https://github.com/livekit/client-sdk-unity/blob/main/BuildScripts~/build_ffi_locally.sh) to build the libraries locally and exchange the downloaded libraries with the local build artifacts in the correct `Runtime/Plugins` folder.
5658

5759
Currently, the build script supports the following arguments:
5860
- macos
5961
- android
62+
- ios
63+
64+
In the following options:
65+
- debug (default)
66+
- release
67+
68+
So a build command is for example:
69+
`./BuildScripts~/build_ffi_locally.sh macos release`
70+
71+
### VSCode setup
72+
73+
Look at the Unity-SDK.code-workspace setup for VSCode. This will use the Meet Sample as the Unity project and the Unity SDK package as two roots in a multi-root workspace and the Meet.sln as the `dotnet.defaultSolution`, enabling Rust and C# IDE support.
74+
75+
### Debugging
76+
77+
For C# debugging, there is a simple attach launch option called `C# Unity`, for example in the `Meet/.vscode/launch.json`.
78+
79+
For Rust / C++ debugging on MacOS, you need to install the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension. The debug attach is defined in `.vscode/launch.json`.
80+
81+
1. Build the livekit-ffi lib locally in debug mode with `./BuildScripts~/build_ffi_locally.sh macos debug`
82+
2. Start the Unity Editor
83+
3. Attach to the Unity Editor process (either auto or manual process picker)
84+
4. Start the Scene in Editor
6085

6186
### iOS
6287

Runtime/Scripts/Internal/FFIClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static void InitializeSdk()
143143
#endif
144144

145145
var sdkVersion = PackageVersion.Get();
146-
NativeMethods.LiveKitInitialize(FFICallback, captureLogs, "unity", sdkVersion); // TODO: Get SDK version
146+
NativeMethods.LiveKitInitialize(FFICallback, captureLogs, "unity", sdkVersion);
147147

148148
Utils.Debug("FFIServer - Initialized");
149149
initialized = true;

Runtime/Scripts/Video/YuvToRgbConverter.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"visualstudiotoolsforunity.vstuc"
4+
]
5+
}

Samples~/Meet/.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "C# Unity",
6+
"type": "vstuc",
7+
"request": "attach"
8+
}
9+
]
10+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"**/.git": true,
5+
"**/.vs": true,
6+
"**/.gitmodules": true,
7+
"**/.vsconfig": true,
8+
"**/*.booproj": true,
9+
"**/*.pidb": true,
10+
"**/*.suo": true,
11+
"**/*.user": true,
12+
"**/*.userprefs": true,
13+
"**/*.unityproj": true,
14+
"**/*.dll": true,
15+
"**/*.exe": true,
16+
"**/*.pdf": true,
17+
"**/*.mid": true,
18+
"**/*.midi": true,
19+
"**/*.wav": true,
20+
"**/*.gif": true,
21+
"**/*.ico": true,
22+
"**/*.jpg": true,
23+
"**/*.jpeg": true,
24+
"**/*.png": true,
25+
"**/*.psd": true,
26+
"**/*.tga": true,
27+
"**/*.tif": true,
28+
"**/*.tiff": true,
29+
"**/*.3ds": true,
30+
"**/*.3DS": true,
31+
"**/*.fbx": true,
32+
"**/*.FBX": true,
33+
"**/*.lxo": true,
34+
"**/*.LXO": true,
35+
"**/*.ma": true,
36+
"**/*.MA": true,
37+
"**/*.obj": true,
38+
"**/*.OBJ": true,
39+
"**/*.asset": true,
40+
"**/*.cubemap": true,
41+
"**/*.flare": true,
42+
"**/*.mat": true,
43+
"**/*.meta": true,
44+
"**/*.prefab": true,
45+
"**/*.unity": true,
46+
"build/": true,
47+
"Build/": true,
48+
"Library/": true,
49+
"library/": true,
50+
"obj/": true,
51+
"Obj/": true,
52+
"Logs/": true,
53+
"logs/": true,
54+
"ProjectSettings/": true,
55+
"UserSettings/": true,
56+
"temp/": true,
57+
"Temp/": true
58+
},
59+
"dotnet.defaultSolution": "Meet.sln"
60+
}

Samples~/Meet/Assets/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)