From 30333e7b0236e49a8b99893ce2ce1a9faee8dad7 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:02:09 +0100 Subject: [PATCH 1/7] use forked niv --- nix/sources.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 1d90464d5d..e92397eecb 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,14 +1,14 @@ { "niv": { "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", + "description": "Niv fork using unstable nix packages.", + "homepage": "https://github.com/Anton-4/niv", + "owner": "Anton-4", "repo": "niv", - "rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070", - "sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx", + "rev": "c372f966c69b0b93803587218feb80e54d82dacf", + "sha256": "1p0cha414mmhys3zzk7m27ybjd2iaawyhpbncjiifynqa1g5g7ql", "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz", + "url": "https://github.com/Anton-4/niv/archive/c372f966c69b0b93803587218feb80e54d82dacf.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { From 197970185dd952e05765e4ce11808092269a8bbe Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:20:55 +0100 Subject: [PATCH 2/7] actually use unstable packages for niv --- nix/sources.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index e92397eecb..af0f2976ba 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://github.com/Anton-4/niv", "owner": "Anton-4", "repo": "niv", - "rev": "c372f966c69b0b93803587218feb80e54d82dacf", - "sha256": "1p0cha414mmhys3zzk7m27ybjd2iaawyhpbncjiifynqa1g5g7ql", + "rev": "f292d8d149a0e5d1e7fdd0ef68d5dde75814ef7e", + "sha256": "0lf52chvqfl5jq09sc2k9vg8faqnd27f3ic5cgzp68jk036bax7r", "type": "tarball", - "url": "https://github.com/Anton-4/niv/archive/c372f966c69b0b93803587218feb80e54d82dacf.tar.gz", + "url": "https://github.com/Anton-4/niv/archive/f292d8d149a0e5d1e7fdd0ef68d5dde75814ef7e.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { From 8580fb41a1ce0331b6144efa120000aa0e80a381 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 5 Nov 2021 12:27:17 +0100 Subject: [PATCH 3/7] put editor sound behind feature --- Earthfile | 6 +++--- editor/Cargo.toml | 6 +++++- editor/src/editor/mod.rs | 1 + editor/src/editor/mvc/ed_update.rs | 13 +++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Earthfile b/Earthfile index 9ef2fb0183..ec7e562204 100644 --- a/Earthfile +++ b/Earthfile @@ -79,11 +79,11 @@ test-rust: # not pre-compiling the host can cause race conditions RUN echo "4" | cargo run --release examples/benchmarks/NQueens.roc RUN --mount=type=cache,target=$SCCACHE_DIR \ - cargo test --release && sccache --show-stats + cargo test --release --features with_sound && sccache --show-stats # run i386 (32-bit linux) cli tests RUN echo "4" | cargo run --release -- --backend=x86_32 examples/benchmarks/NQueens.roc RUN --mount=type=cache,target=$SCCACHE_DIR \ - cargo test --release --test cli_run i386 --features="i386-cli-run" && sccache --show-stats + cargo test --release --features with_sound --test cli_run i386 --features="i386-cli-run" && sccache --show-stats verify-no-git-changes: FROM +test-rust @@ -109,7 +109,7 @@ build-nightly-release: # version.txt is used by the CLI: roc --version RUN printf "nightly pre-release, built from commit " > version.txt RUN git log --pretty=format:'%h' -n 1 >> version.txt - RUN cargo build --release + RUN cargo build --features with_sound --release RUN cd ./target/release && tar -czvf roc_linux_x86_64.tar.gz ./roc SAVE ARTIFACT ./target/release/roc_linux_x86_64.tar.gz AS LOCAL roc_linux_x86_64.tar.gz diff --git a/editor/Cargo.toml b/editor/Cargo.toml index 83f5d387d2..278bc4d0eb 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -12,6 +12,10 @@ normal = ["confy"] #development = [] #build = [] +[features] +default = [] +with_sound = ["rodio"] + [dependencies] roc_ast = { path = "../ast" } roc_collections = { path = "../compiler/collections" } @@ -54,7 +58,7 @@ confy = { git = 'https://github.com/rust-cli/confy', features = [ serde = { version = "1.0.123", features = ["derive"] } nonempty = "0.6.0" fs_extra = "1.2.0" -rodio = "0.14.0" +rodio = { version = "0.14.0", optional = true } # to play sounds threadpool = "1.8.1" [dependencies.bytemuck] diff --git a/editor/src/editor/mod.rs b/editor/src/editor/mod.rs index 775e2606d6..23d273400d 100644 --- a/editor/src/editor/mod.rs +++ b/editor/src/editor/mod.rs @@ -8,6 +8,7 @@ mod mvc; mod render_ast; mod render_debug; mod resources; +#[cfg(feature = "with_sound")] mod sound; mod theme; mod util; diff --git a/editor/src/editor/mvc/ed_update.rs b/editor/src/editor/mvc/ed_update.rs index 9e12f1ae3d..7f1f2b6d44 100644 --- a/editor/src/editor/mvc/ed_update.rs +++ b/editor/src/editor/mvc/ed_update.rs @@ -22,6 +22,7 @@ use crate::editor::mvc::string_update::start_new_string; use crate::editor::mvc::string_update::update_small_string; use crate::editor::mvc::string_update::update_string; use crate::editor::mvc::tld_value_update::{start_new_tld_value, update_tld_val_name}; +#[cfg(feature = "with_sound")] use crate::editor::sound::play_sound; use crate::ui::text::caret_w_select::CaretWSelect; use crate::ui::text::lines::MoveCaretFun; @@ -521,7 +522,7 @@ impl<'a> EdModel<'a> { &mut self, modifiers: &Modifiers, virtual_keycode: VirtualKeyCode, - sound_thread_pool: &mut ThreadPool, + _sound_thread_pool: &mut ThreadPool, ) -> EdResult<()> { match virtual_keycode { Left => self.move_caret_left(modifiers)?, @@ -560,9 +561,13 @@ impl<'a> EdModel<'a> { self.dirty = true; } F12 => { - sound_thread_pool.execute(move || { - play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3"); - }); + #[cfg(feature = "with_sound")] + { + println!("playing sound..."); + _sound_thread_pool.execute(move || { + play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3"); + }); + } } _ => (), } From 8729ed449fe392766956d3cbf117e464d4c9595c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 5 Nov 2021 13:21:09 +0100 Subject: [PATCH 4/7] fmt+clippy --- editor/src/editor/mvc/ed_update.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/editor/src/editor/mvc/ed_update.rs b/editor/src/editor/mvc/ed_update.rs index 7f1f2b6d44..f897575730 100644 --- a/editor/src/editor/mvc/ed_update.rs +++ b/editor/src/editor/mvc/ed_update.rs @@ -562,12 +562,9 @@ impl<'a> EdModel<'a> { } F12 => { #[cfg(feature = "with_sound")] - { - println!("playing sound..."); - _sound_thread_pool.execute(move || { - play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3"); - }); - } + _sound_thread_pool.execute(move || { + play_sound("./editor/src/editor/resources/sounds/bell_sound.mp3"); + }); } _ => (), } From 1c80b0db7d6b752d324db9354f1a726699f630e9 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 5 Nov 2021 13:30:02 +0100 Subject: [PATCH 5/7] Removed "nix is not working on MacOS" --- BUILDING_FROM_SOURCE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BUILDING_FROM_SOURCE.md b/BUILDING_FROM_SOURCE.md index 35df489a83..2503197514 100644 --- a/BUILDING_FROM_SOURCE.md +++ b/BUILDING_FROM_SOURCE.md @@ -82,8 +82,6 @@ There are also alternative installation options at http://releases.llvm.org/down ## Using Nix -:exclamation: **Our Nix setup is not yet working on MacOS, you'll have to install manually for now** :exclamation: - ### Install Using [nix](https://nixos.org/download.html) is a quick way to get an environment bootstrapped with a single command. @@ -124,6 +122,7 @@ If you plan on using `nix-shell` regularly, check out [direnv](https://direnv.ne ### Editor +The editor is a WIP and not ready yet to replace your favorite editor, although if you want to try it out on nix, read on. `cargo run edit` should work from NixOS, if you use a nix-shell from inside another OS, follow the instructions below. #### Nvidia GPU From 03f76dfa3736dfa78a627b19296181b4ee67e54b Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 6 Nov 2021 16:21:35 +0100 Subject: [PATCH 6/7] fixed ld warning --- compiler/build/src/link.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index aa91a5954e..ae546f789c 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -811,7 +811,7 @@ fn link_macos( "-arch", &arch, "-macos_version_min", - "10.15", + &get_macos_version(), ]) .args(input_paths); @@ -852,6 +852,23 @@ fn link_macos( } } +fn get_macos_version() -> String { + let cmd_stdout = Command::new("sw_vers") + .arg("-productVersion") + .output() + .expect("Failed to execute command 'sw_vers -productVersion'") + .stdout; + + let full_version_string = String::from_utf8(cmd_stdout) + .expect("Failed to convert output of command 'sw_vers -productVersion' into a utf8 string"); + + full_version_string + .split('.') + .take(2) + .collect::>() + .join(".") +} + fn link_wasm32( _target: &Triple, output_path: PathBuf, From 6930d9ba2235e975aab76f603e3b4731e2d8cd33 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 6 Nov 2021 16:32:07 +0100 Subject: [PATCH 7/7] added less for git diff --- shell.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell.nix b/shell.nix index 3df6678197..9902d2bd73 100644 --- a/shell.nix +++ b/shell.nix @@ -65,6 +65,9 @@ let # note: niv manages its own nixpkgs so it doesn't need pkgs.callPackage. Do # `cachix use niv` to get cached builds! (import sources.niv { }).niv + + # tools for development environment + less ]; in pkgs.mkShell { buildInputs = inputs ++ darwinInputs ++ linuxInputs;