summaryrefslogtreecommitdiffstats
path: root/packaging/macos/modulesets/patches/rust_cmake_install.patch
blob: b1025cd7b712d48990c9d4cde2a5b91483163e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- a/CMakeLists.txt	2020-11-29 02:35:19.000000000 +0100
+++ b/CMakeLists.txt	2020-11-29 02:35:44.000000000 +0100
@@ -0,0 +1,24 @@
+# This is a wrapper to install Rust via cmake. Its only purpose is to supply an
+# interface that can be used from JHBuild.
+#
+# usage:
+#   cmake -DVERSION=<Rust version>
+#   make install
+
+cmake_minimum_required(VERSION 3.1)
+project(rust)
+
+add_custom_command(OUTPUT rust
+  # use bash so we can supply environment variables to rustup-init.sh
+  COMMAND bash "-c" "RUSTUP_HOME=${CMAKE_INSTALL_PREFIX}/home/.rustup CARGO_HOME=${CMAKE_INSTALL_PREFIX}/home/.cargo ${CMAKE_CURRENT_SOURCE_DIR}/rustup-init.sh -y --no-modify-path --profile minimal"
+  COMMAND bash "-c" "${CMAKE_INSTALL_PREFIX}/home/.cargo/bin/rustup toolchain install ${VERSION}"
+  COMMAND bash "-c" "${CMAKE_INSTALL_PREFIX}/home/.cargo/bin/rustup default ${VERSION}"
+  COMMAND bash "-c" "${CMAKE_INSTALL_PREFIX}/home/.cargo/bin/rustup toolchain remove stable"
+)
+
+add_custom_target(
+  install_rust ALL
+  DEPENDS rust
+)
+
+install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/home/.cargo/bin/ DESTINATION bin USE_SOURCE_PERMISSIONS)