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

Setup user environment #381

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9c1fe21
feat: Initial env mod implementation
SergioGasquez Oct 20, 2023
c1f6ec5
feat: Add windows and unix mods
SergioGasquez Oct 20, 2023
1ce8855
feat: Write env files
SergioGasquez Oct 20, 2023
0841d8c
feat: Add writing env files and cleanup
SergioGasquez Oct 20, 2023
f524d90
chore: Clippy lints
SergioGasquez Oct 20, 2023
9c3baee
feat: Update env scripts
SergioGasquez Oct 20, 2023
9445317
feat: Use custom error
SergioGasquez Oct 20, 2023
5b0316d
style: Format includes
SergioGasquez Oct 20, 2023
804b154
docs: Update changelog
SergioGasquez Oct 21, 2023
e378fcf
feat: Avoid code duplication
SergioGasquez Oct 21, 2023
257ef2b
feat: Remove legacy export file
SergioGasquez Oct 21, 2023
50de174
feat: Add unix post install message
SergioGasquez Oct 21, 2023
e1501d7
feat: Add no-modify-env argumentr
SergioGasquez Oct 21, 2023
7a03981
feat: Improve WindowsShells
SergioGasquez Oct 21, 2023
ea68ad4
feat: Remove export files
SergioGasquez Oct 21, 2023
8dfdb74
refactor: Improve methods name
SergioGasquez Oct 21, 2023
1b81a6e
feat: Add environment cleanup
SergioGasquez Oct 21, 2023
6711141
refactor: Review methods visibility
SergioGasquez Oct 21, 2023
ec8ad0d
feat: Rework Windows env setup
SergioGasquez Oct 21, 2023
c9a1188
fix: Fix clippy lints
SergioGasquez Oct 21, 2023
6f3c264
style: Improve fmt
SergioGasquez Oct 21, 2023
52086db
fix: Fix Windows build
SergioGasquez Oct 22, 2023
8663d28
fix: Fix Windows build
SergioGasquez Oct 22, 2023
332c45d
fix: Fix Windows build
SergioGasquez Oct 22, 2023
cf29809
fix: Fix Windows environment
SergioGasquez Oct 22, 2023
24ed143
feat: Remove TODO
SergioGasquez Oct 22, 2023
dd10bcf
feat: Improve Windwos environment setup
SergioGasquez Oct 23, 2023
12af08b
docs: Update docstrings
SergioGasquez Oct 23, 2023
742905e
fix: Avoid error if the install_dir does not exists
SergioGasquez Oct 23, 2023
91f6f18
refactor: Update logs to make them less verbose
SergioGasquez Oct 23, 2023
c310703
docs: Update readme
SergioGasquez Oct 23, 2023
af750a1
docs: Update changelog
SergioGasquez Oct 23, 2023
19f7513
fix: Remove leftover comment
SergioGasquez Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Setup user environment (#381)

### Fixed

### Changed
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ openssl = { version = "0.10.57", features = ["vendored"] }

[target.'cfg(windows)'.dependencies]
winreg = "0.51.0"
winapi = { version = "0.3.9", features = ["winuser"] }

[dev-dependencies]
assert_cmd = "2.0.12"
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ Options:

### Install Subcommand

> **Warning**
>
> #### Environment modification
> Installation will, by default, modify your environment. If you dont want `espup` to modify your environment, please use the `--no-modify-env` argument.

> **Note**
>
> #### Xtensa Rust destination path
Expand All @@ -125,7 +130,7 @@ Options:
> **Note**
>
> #### GitHub API
> During the installation process, several GitHub queries are made, [which are subject to certain limits](https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting). Our number of queries should not hit the limits unless you are running `espup install` command numerous times in a short span of time. We recommend setting the [`GITHUB_TOKEN` environment variable](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret) when using `espup` in CI, if you want to use `espup` on CI, recommend using it via the [`xtensa-toolchain` action](https://github.com/esp-rs/xtensa-toolchain/), and making sure `GITHUB_TOKEN` is not set when using it on a host machine. See https://github.com/esp-rs/xtensa-toolchain/issues/15 for more details on this.
> During the installation process, several GitHub queries are made, [which are subject to certain limits](https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting). Our number of queries should not hit the limit unless you are running `espup install` command numerous times in a short span of time. We recommend setting the [`GITHUB_TOKEN` environment variable](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret) when using `espup` in CI, if you want to use `espup` on CI, recommend using it via the [`xtensa-toolchain` action](https://github.com/esp-rs/xtensa-toolchain/), and making sure `GITHUB_TOKEN` is not set when using it on a host machine. See https://github.com/esp-rs/xtensa-toolchain/issues/15 for more details on this.

```
Usage: espup install [OPTIONS]
Expand All @@ -136,9 +141,6 @@ Options:

[possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin]

-f, --export-file <EXPORT_FILE>
Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html)

-e, --extended-llvm
Extends the LLVM installation.

Expand All @@ -160,6 +162,9 @@ Options:

[default: nightly]

-o, --no-modify-env
Don't configure environment variables

-k, --skip-version-parse
Skips parsing Xtensa Rust version

Expand Down Expand Up @@ -202,9 +207,6 @@ Options:

[possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin]

-f, --export-file <EXPORT_FILE>
Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html)

-e, --extended-llvm
Extends the LLVM installation.

Expand All @@ -226,6 +228,9 @@ Options:

[default: nightly]

-o, --no-modify-env
Don't configure environment variables

-k, --skip-version-parse
Skips parsing Xtensa Rust version

Expand Down
10 changes: 6 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Command line interface.

use crate::targets::{parse_targets, Target};
use clap::Parser;
use clap_complete::Shell;
use std::{collections::HashSet, path::PathBuf};
use std::collections::HashSet;

#[derive(Debug, Parser)]
pub struct CompletionsOpts {
Expand All @@ -17,9 +19,6 @@ pub struct InstallOpts {
/// Target triple of the host.
#[arg(short = 'd', long, value_parser = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu" , "x86_64-apple-darwin" , "aarch64-apple-darwin"])]
pub default_host: Option<String>,
/// Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html).
#[arg(short = 'f', long)]
pub export_file: Option<PathBuf>,
/// Extends the LLVM installation.
///
/// This will install the whole LLVM instead of only installing the libs.
Expand All @@ -34,6 +33,9 @@ pub struct InstallOpts {
/// Nightly Rust toolchain version.
#[arg(short = 'n', long, default_value = "nightly")]
pub nightly_version: String,
/// Don't configure environment variables
#[arg(short = 'o', long)]
pub no_modify_env: bool,
/// Skips parsing Xtensa Rust version.
#[arg(short = 'k', long)]
pub skip_version_parse: bool,
Expand Down
165 changes: 0 additions & 165 deletions src/env.rs

This file was deleted.

32 changes: 32 additions & 0 deletions src/env/env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
rem espup CMD setup

set XTENSA_GCC={xtensa_gcc}
if not "%XTENSA_GCC%" == "" (
echo %PATH% | findstr /C:"%XTENSA_GCC%" 1>nul
if errorlevel 1 (
rem Prepending path
set PATH=%XTENSA_GCC%;%PATH%
)
)

set RISCV_GCC={riscv_gcc}
if not "%RISCV_GCC%" == "" (
echo %PATH% | findstr /C:"%RISCV_GCC%" 1>nul
if errorlevel 1 (
rem Prepending path
set PATH=%RISCV_GCC%;%PATH%
)
)

set LIBCLANG_PATH={libclang_path}
set LIBCLANG_BIN_PATH={libclang_bin_path}
if not "%LIBCLANG_BIN_PATH%" == "" (
echo %PATH% | findstr /C:"%LIBCLANG_BIN_PATH%" 1>nul
if errorlevel 1 (
rem Prepending path
set PATH=%LIBCLANG_BIN_PATH%;%PATH%
)
)

set CLANG_PATH={clang_path}
19 changes: 19 additions & 0 deletions src/env/env.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# espup shell setup
set XTENSA_GCC "{xtensa_gcc}"
if test -n "$XTENSA_GCC"
if not contains "{xtensa_gcc}" $PATH
# Prepending path
set -x PATH "{xtensa_gcc}" $PATH
end
end

set RISCV_GCC "{riscv_gcc}"
if test -n "$RISCV_GCC"
if not contains "{riscv_gcc}" $PATH
# Prepending path
set -x PATH "{riscv_gcc}" $PATH
end
end

set -x LIBCLANG_PATH "{libclang_path}"
set -x CLANG_PATH "{clang_path}"
28 changes: 28 additions & 0 deletions src/env/env.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# espup PowerShell setup
# affix semicolons on either side of $Env:PATH to simplify matching
$XTENSA_GCC = "{xtensa_gcc}"
if ($XTENSA_GCC -ne "") {
if (-not ($Env:PATH -like "*;$XTENSA_GCC;*")) {
# Prepending path
$Env:PATH = "$XTENSA_GCC;$Env:PATH"
}
}

$RISCV_GCC = "{riscv_gcc}"
if ($RISCV_GCC -ne "") {
if (-not ($Env:PATH -like "*;$RISCV_GCC;*")) {
# Prepending path
$Env:PATH = "$RISCV_GCC;$Env:PATH"
}
}

$Env:LIBCLANG_PATH = "{libclang_path}"
$LIBCLANG_BIN_PATH = "{libclang_bin_path}"
if ($LIBCLANG_BIN_PATH -ne "") {
if (-not ($Env:PATH -like "*;$LIBCLANG_BIN_PATH;*")) {
# Prepending path
$Env:PATH = "$LIBCLANG_BIN_PATH;$Env:PATH"
}
}

$Env:CLANG_PATH = "{clang_path}"
25 changes: 25 additions & 0 deletions src/env/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
# espup shell setup
# affix colons on either side of $PATH to simplify matching
XTENSA_GCC="{xtensa_gcc}"
if [[ -n "${XTENSA_GCC}" ]]; then
case ":${PATH}:" in
*:"{xtensa_gcc}":*) ;;
*)
# Prepending path
export PATH="{xtensa_gcc}:$PATH"
;;
esac
fi
RISCV_GCC="{riscv_gcc}"
if [[ -n "${RISCV_GCC}" ]]; then
case ":${PATH}:" in
*:"{riscv_gcc}":*) ;;
*)
# Prepending path
export PATH="{riscv_gcc}:$PATH"
;;
esac
fi
export LIBCLANG_PATH="{libclang_path}"
export CLANG_PATH="{clang_path}"
Loading