Skip to content

Commit 2aa1cad

Browse files
committed
Working nix feature flag.
1 parent 75e7f0c commit 2aa1cad

File tree

5 files changed

+38
-76
lines changed

5 files changed

+38
-76
lines changed

alvr/server_openvr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ crate-type = ["cdylib"]
1111

1212
[features]
1313
gpl = [] # Enable for FFmpeg support on Windows. Always enabled on Linux
14+
nix = []
1415

1516
[dependencies]
1617
alvr_common.workspace = true

alvr/server_openvr/build.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
use std::{env, path::PathBuf};
22

33
fn get_ffmpeg_path() -> PathBuf {
4-
let ffmpeg_path = alvr_filesystem::deps_dir()
5-
.join(if cfg!(target_os = "linux") {
6-
"linux"
7-
} else {
8-
"windows"
9-
})
10-
.join("ffmpeg");
4+
if cfg!(not(feature = "nix")) {
5+
let ffmpeg_path = alvr_filesystem::deps_dir()
6+
.join(if cfg!(target_os = "linux") {
7+
"linux"
8+
} else {
9+
"windows"
10+
})
11+
.join("ffmpeg");
1112

12-
if cfg!(target_os = "linux") {
13-
ffmpeg_path.join("alvr_build")
13+
if cfg!(target_os = "linux") {
14+
ffmpeg_path.join("alvr_build")
15+
} else {
16+
ffmpeg_path
17+
}
1418
} else {
15-
ffmpeg_path
19+
pkg_config::Config::new()
20+
.probe("libavcodec")
21+
.unwrap()
22+
.to_owned()
23+
.include_paths
24+
.pop()
25+
.unwrap()
26+
.parent()
27+
.unwrap()
28+
.to_path_buf()
1629
}
1730
}
1831

fix-finding-libs.patch

Lines changed: 0 additions & 35 deletions
This file was deleted.

flake.lock

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

flake.nix

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@
3636
pkg-config
3737
rustToolchain
3838
rustPlatform.bindgenHook
39-
llvmPackages.bintools
39+
llvmPackages.bintools
4040
vulkan-headers
4141
vulkan-loader
42-
#libGL
4342
];
4443

4544
dependencyPackages = [
@@ -76,8 +75,6 @@
7675
xvidcore
7776
bzip2
7877
gmp
79-
jdk
80-
jre
8178
];
8279

8380
nvidiaPackages = with cudaPackages; [
@@ -86,13 +83,6 @@
8683
libnpp
8784
];
8885

89-
libsPatch = toString (
90-
replaceVars ./fix-finding-libs.patch {
91-
ffmpeg = lib.getDev ffmpeg;
92-
x264 = lib.getDev x264;
93-
}
94-
);
95-
9686
androidComposition = androidenv.composeAndroidPackages {
9787
minPlatformVersion = "28";
9888
maxPlatformVersion = "32";
@@ -152,9 +142,6 @@
152142
])
153143
];
154144
RUST_BACKTRACE = "1";
155-
shellHook = ''
156-
git apply ${libsPatch}
157-
'';
158145
};
159146
in
160147
{
@@ -169,7 +156,7 @@
169156
"-lssl"
170157
];
171158
RUSTFLAGS = toString [
172-
"-C link-self-contained=-linker"
159+
"-C link-self-contained=-linker"
173160
(map (a: "-C link-args=${a}") [
174161
"-Wl,--push-state,--no-as-needed"
175162
"-lEGL"
@@ -179,16 +166,11 @@
179166
])
180167
];
181168
cargoBuildFlags = [
169+
"--workspace"
182170
"--exclude alvr_xtask"
183-
"--workspace"
184171
];
185172
buildNoDefaultFeatures = true;
186-
patches = [
187-
(replaceVars ./fix-finding-libs.patch {
188-
ffmpeg = lib.getDev ffmpeg;
189-
x264 = lib.getDev x264;
190-
})
191-
];
173+
buildFeatures = [ "nix" ];
192174
version = "21.0.0-master"; # TODO Change to the release
193175
doCheck = false; # TODO Broken right now
194176
src = ./.;
@@ -213,6 +195,7 @@
213195
cp -r ./build/alvr_streamer_linux/share/. $out/share
214196
ln -s $out/lib $out/lib64
215197
'';
198+
# TODO FIX that it needs to run the below command.
216199
postBuild = ''
217200
# Build SteamVR driver ("streamer")
218201
cargo xtask build-streamer --release

0 commit comments

Comments
 (0)