diff options
-rw-r--r-- | .github/workflows/release.yaml | 43 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | xtask/src/install.rs | 6 | ||||
-rw-r--r-- | xtask/src/lib.rs | 41 | ||||
-rw-r--r-- | xtask/src/main.rs | 14 | ||||
-rw-r--r-- | xtask/src/not_bash.rs | 17 |
6 files changed, 81 insertions, 41 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index aef961671..f5a07c21f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml | |||
@@ -41,19 +41,27 @@ jobs: | |||
41 | target: x86_64-unknown-linux-musl | 41 | target: x86_64-unknown-linux-musl |
42 | override: true | 42 | override: true |
43 | 43 | ||
44 | - name: Create distribution dir | ||
45 | run: mkdir ./dist | ||
46 | |||
44 | - name: Build | 47 | - name: Build |
45 | if: matrix.os == 'ubuntu-latest' | 48 | if: matrix.os == 'ubuntu-latest' |
46 | run: cargo build --package rust-analyzer --bin rust-analyzer --release --target x86_64-unknown-linux-musl | 49 | run: cargo build --package rust-analyzer --bin rust-analyzer --release --target x86_64-unknown-linux-musl |
47 | env: | 50 | env: |
48 | CC: clang | 51 | CC: clang |
49 | 52 | ||
53 | - name: Build VS Code extension | ||
54 | if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
55 | run: cargo xtask dist | ||
56 | |||
57 | - name: Build VS Code extension | ||
58 | if: matrix.os == 'ubuntu-latest' && github.event_name != 'push' | ||
59 | run: cargo xtask dist --nightly | ||
60 | |||
50 | - name: Build | 61 | - name: Build |
51 | if: matrix.os != 'ubuntu-latest' | 62 | if: matrix.os != 'ubuntu-latest' |
52 | run: cargo build --package rust-analyzer --bin rust-analyzer --release | 63 | run: cargo build --package rust-analyzer --bin rust-analyzer --release |
53 | 64 | ||
54 | - name: Create distribution dir | ||
55 | run: mkdir ./dist | ||
56 | |||
57 | - name: Copy binary | 65 | - name: Copy binary |
58 | if: matrix.os == 'ubuntu-latest' | 66 | if: matrix.os == 'ubuntu-latest' |
59 | run: cp ./target/x86_64-unknown-linux-musl/release/rust-analyzer ./dist/rust-analyzer-linux && strip ./dist/rust-analyzer-linux | 67 | run: cp ./target/x86_64-unknown-linux-musl/release/rust-analyzer ./dist/rust-analyzer-linux && strip ./dist/rust-analyzer-linux |
@@ -72,33 +80,6 @@ jobs: | |||
72 | name: server-${{ matrix.os }} | 80 | name: server-${{ matrix.os }} |
73 | path: ./dist | 81 | path: ./dist |
74 | 82 | ||
75 | build-clients: | ||
76 | name: build-clients | ||
77 | runs-on: ubuntu-latest | ||
78 | steps: | ||
79 | - name: Checkout repository | ||
80 | uses: actions/checkout@v1 | ||
81 | |||
82 | - name: Install Nodejs | ||
83 | uses: actions/setup-node@v1 | ||
84 | with: | ||
85 | node-version: 12.x | ||
86 | |||
87 | - run: npm ci | ||
88 | working-directory: ./editors/code | ||
89 | |||
90 | - run: npm run package --scripts-prepend-node-path | ||
91 | working-directory: ./editors/code | ||
92 | |||
93 | - name: Copy vscode extension | ||
94 | run: mkdir -p ./dist/code && cp ./editors/code/rust-analyzer.vsix ./dist/ | ||
95 | |||
96 | - name: Upload artifacts | ||
97 | uses: actions/upload-artifact@v1 | ||
98 | with: | ||
99 | name: editor-plugins | ||
100 | path: ./dist | ||
101 | |||
102 | make-release: | 83 | make-release: |
103 | name: make-release | 84 | name: make-release |
104 | runs-on: ubuntu-latest | 85 | runs-on: ubuntu-latest |
@@ -150,4 +131,4 @@ jobs: | |||
150 | if: github.event_name == 'push' | 131 | if: github.event_name == 'push' |
151 | working-directory: ./editors/code | 132 | working-directory: ./editors/code |
152 | # token from https://dev.azure.com/rust-analyzer/ | 133 | # token from https://dev.azure.com/rust-analyzer/ |
153 | run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }} | 134 | run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix |
diff --git a/.gitignore b/.gitignore index dc5ceca7f..f835edef0 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -1,4 +1,5 @@ | |||
1 | /target/ | 1 | /target/ |
2 | /dist/ | ||
2 | crates/*/target | 3 | crates/*/target |
3 | **/*.rs.bk | 4 | **/*.rs.bk |
4 | **/*.rs.pending-snap | 5 | **/*.rs.pending-snap |
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index f76467cac..d0d745b05 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -4,10 +4,7 @@ use std::{env, path::PathBuf, str}; | |||
4 | 4 | ||
5 | use anyhow::{bail, format_err, Context, Result}; | 5 | use anyhow::{bail, format_err, Context, Result}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::not_bash::{pushd, run}; |
8 | not_bash::{pushd, run}, | ||
9 | project_root, | ||
10 | }; | ||
11 | 8 | ||
12 | // Latest stable, feel free to send a PR if this lags behind. | 9 | // Latest stable, feel free to send a PR if this lags behind. |
13 | const REQUIRED_RUST_VERSION: u32 = 41; | 10 | const REQUIRED_RUST_VERSION: u32 = 41; |
@@ -27,7 +24,6 @@ pub struct ServerOpt { | |||
27 | 24 | ||
28 | impl InstallCmd { | 25 | impl InstallCmd { |
29 | pub fn run(self) -> Result<()> { | 26 | pub fn run(self) -> Result<()> { |
30 | let _dir = pushd(project_root()); | ||
31 | let both = self.server.is_some() && self.client.is_some(); | 27 | let both = self.server.is_some() && self.client.is_some(); |
32 | if cfg!(target_os = "macos") { | 28 | if cfg!(target_os = "macos") { |
33 | fix_path_for_mac().context("Fix path for mac")? | 29 | fix_path_for_mac().context("Fix path for mac")? |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index f48045d17..adbee10ee 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -19,7 +19,7 @@ use std::{ | |||
19 | 19 | ||
20 | use crate::{ | 20 | use crate::{ |
21 | codegen::Mode, | 21 | codegen::Mode, |
22 | not_bash::{fs2, pushd, rm_rf, run}, | 22 | not_bash::{fs2, pushd, pwd, rm_rf, run}, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | pub use anyhow::Result; | 25 | pub use anyhow::Result; |
@@ -206,3 +206,42 @@ Release: release:{}[] | |||
206 | fn is_release_tag(tag: &str) -> bool { | 206 | fn is_release_tag(tag: &str) -> bool { |
207 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) | 207 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) |
208 | } | 208 | } |
209 | |||
210 | pub fn run_dist(nightly: bool) -> Result<()> { | ||
211 | let dist = project_root().join("dist"); | ||
212 | rm_rf(&dist)?; | ||
213 | fs2::create_dir_all(&dist)?; | ||
214 | |||
215 | let _d = pushd("./editors/code"); | ||
216 | |||
217 | let package_json_path = pwd().join("package.json"); | ||
218 | let original_package_json = fs2::read_to_string(&package_json_path)?; | ||
219 | let _restore = | ||
220 | Restore { path: package_json_path.clone(), contents: original_package_json.clone() }; | ||
221 | |||
222 | let mut package_json = original_package_json.replace(r#""enableProposedApi": true,"#, r#""#); | ||
223 | |||
224 | if nightly { | ||
225 | package_json = package_json | ||
226 | .replace(r#""name": "rust-analyzer""#, r#""name": "rust-analyzer-nightly""#) | ||
227 | .replace( | ||
228 | r#""displayName": "rust-analyzer""#, | ||
229 | r#""displayName": "rust-analyzer nightly""#, | ||
230 | ); | ||
231 | } | ||
232 | fs2::write(package_json_path, package_json)?; | ||
233 | |||
234 | run!("npx vsce package -o {}/rust-analyzer.vsix", dist.display())?; | ||
235 | Ok(()) | ||
236 | } | ||
237 | |||
238 | struct Restore { | ||
239 | path: PathBuf, | ||
240 | contents: String, | ||
241 | } | ||
242 | |||
243 | impl Drop for Restore { | ||
244 | fn drop(&mut self) { | ||
245 | fs2::write(&self.path, &self.contents).unwrap(); | ||
246 | } | ||
247 | } | ||
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index a7dffe2cc..17a2f1c68 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -14,7 +14,9 @@ use pico_args::Arguments; | |||
14 | use xtask::{ | 14 | use xtask::{ |
15 | codegen::{self, Mode}, | 15 | codegen::{self, Mode}, |
16 | install::{ClientOpt, InstallCmd, ServerOpt}, | 16 | install::{ClientOpt, InstallCmd, ServerOpt}, |
17 | pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, Result, | 17 | not_bash::pushd, |
18 | pre_commit, project_root, run_clippy, run_dist, run_fuzzer, run_pre_cache, run_release, | ||
19 | run_rustfmt, Result, | ||
18 | }; | 20 | }; |
19 | 21 | ||
20 | fn main() -> Result<()> { | 22 | fn main() -> Result<()> { |
@@ -22,6 +24,8 @@ fn main() -> Result<()> { | |||
22 | return pre_commit::run_hook(); | 24 | return pre_commit::run_hook(); |
23 | } | 25 | } |
24 | 26 | ||
27 | let _d = pushd(project_root()); | ||
28 | |||
25 | let mut args = Arguments::from_env(); | 29 | let mut args = Arguments::from_env(); |
26 | let subcommand = args.subcommand()?.unwrap_or_default(); | 30 | let subcommand = args.subcommand()?.unwrap_or_default(); |
27 | 31 | ||
@@ -97,6 +101,11 @@ FLAGS: | |||
97 | args.finish()?; | 101 | args.finish()?; |
98 | run_release(dry_run) | 102 | run_release(dry_run) |
99 | } | 103 | } |
104 | "dist" => { | ||
105 | let nightly = args.contains("--nightly"); | ||
106 | args.finish()?; | ||
107 | run_dist(nightly) | ||
108 | } | ||
100 | _ => { | 109 | _ => { |
101 | eprintln!( | 110 | eprintln!( |
102 | "\ | 111 | "\ |
@@ -112,7 +121,8 @@ SUBCOMMANDS: | |||
112 | fuzz-tests | 121 | fuzz-tests |
113 | codegen | 122 | codegen |
114 | install | 123 | install |
115 | lint" | 124 | lint |
125 | dist" | ||
116 | ); | 126 | ); |
117 | Ok(()) | 127 | Ok(()) |
118 | } | 128 | } |
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index 40f706d9f..1697b7fcd 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs | |||
@@ -19,6 +19,11 @@ pub mod fs2 { | |||
19 | fs::read_dir(path).with_context(|| format!("Failed to read {}", path.display())) | 19 | fs::read_dir(path).with_context(|| format!("Failed to read {}", path.display())) |
20 | } | 20 | } |
21 | 21 | ||
22 | pub fn read_to_string<P: AsRef<Path>>(path: P) -> Result<String> { | ||
23 | let path = path.as_ref(); | ||
24 | fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display())) | ||
25 | } | ||
26 | |||
22 | pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> { | 27 | pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> { |
23 | let path = path.as_ref(); | 28 | let path = path.as_ref(); |
24 | fs::write(path, contents).with_context(|| format!("Failed to write {}", path.display())) | 29 | fs::write(path, contents).with_context(|| format!("Failed to write {}", path.display())) |
@@ -40,6 +45,11 @@ pub mod fs2 { | |||
40 | let path = path.as_ref(); | 45 | let path = path.as_ref(); |
41 | fs::remove_dir_all(path).with_context(|| format!("Failed to remove dir {}", path.display())) | 46 | fs::remove_dir_all(path).with_context(|| format!("Failed to remove dir {}", path.display())) |
42 | } | 47 | } |
48 | |||
49 | pub fn create_dir_all<P: AsRef<Path>>(path: P) -> Result<()> { | ||
50 | let path = path.as_ref(); | ||
51 | fs::create_dir_all(path).with_context(|| format!("Failed to create dir {}", path.display())) | ||
52 | } | ||
43 | } | 53 | } |
44 | 54 | ||
45 | macro_rules! _run { | 55 | macro_rules! _run { |
@@ -61,6 +71,10 @@ pub fn pushd(path: impl Into<PathBuf>) -> Pushd { | |||
61 | Pushd { _p: () } | 71 | Pushd { _p: () } |
62 | } | 72 | } |
63 | 73 | ||
74 | pub fn pwd() -> PathBuf { | ||
75 | Env::with(|env| env.cwd()) | ||
76 | } | ||
77 | |||
64 | impl Drop for Pushd { | 78 | impl Drop for Pushd { |
65 | fn drop(&mut self) { | 79 | fn drop(&mut self) { |
66 | Env::with(|env| env.popd()) | 80 | Env::with(|env| env.popd()) |
@@ -85,7 +99,6 @@ pub fn run_process(cmd: String, echo: bool) -> Result<String> { | |||
85 | } | 99 | } |
86 | 100 | ||
87 | fn run_process_inner(cmd: &str, echo: bool) -> Result<String> { | 101 | fn run_process_inner(cmd: &str, echo: bool) -> Result<String> { |
88 | let cwd = Env::with(|env| env.cwd()); | ||
89 | let mut args = shelx(cmd); | 102 | let mut args = shelx(cmd); |
90 | let binary = args.remove(0); | 103 | let binary = args.remove(0); |
91 | 104 | ||
@@ -95,7 +108,7 @@ fn run_process_inner(cmd: &str, echo: bool) -> Result<String> { | |||
95 | 108 | ||
96 | let output = Command::new(binary) | 109 | let output = Command::new(binary) |
97 | .args(args) | 110 | .args(args) |
98 | .current_dir(cwd) | 111 | .current_dir(pwd()) |
99 | .stdin(Stdio::null()) | 112 | .stdin(Stdio::null()) |
100 | .stderr(Stdio::inherit()) | 113 | .stderr(Stdio::inherit()) |
101 | .output()?; | 114 | .output()?; |