Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / compiler-cli / src / shell.rs
1.7 kB 52 lines
1// SPDX-License-Identifier: Apache-2.0 2// SPDX-FileCopyrightText: 2020 The Gleam contributors 3 4use gleam_core::{ 5 analyse::TargetSupport, 6 build::{Codegen, Compile, Mode, Options, Target}, 7 error::{Error, ShellCommandFailureReason}, 8 paths::ProjectPaths, 9}; 10use std::process::Command; 11 12pub fn command(paths: &ProjectPaths) -> Result<(), Error> { 13 // Build project 14 let _ = crate::build::main( 15 paths, 16 Options { 17 root_target_support: TargetSupport::Enforced, 18 warnings_as_errors: false, 19 codegen: Codegen::All, 20 compile: Compile::All, 21 mode: Mode::Dev, 22 target: Some(Target::Erlang), 23 no_print_progress: false, 24 }, 25 crate::build::download_dependencies(paths, crate::cli::Reporter::new())?, 26 )?; 27 28 // Don't exit on ctrl+c as it is used by child erlang shell 29 ctrlc::set_handler(move || {}).expect("Error setting Ctrl-C handler"); 30 31 // Prepare the Erlang shell command 32 let mut command = Command::new("erl"); 33 34 // Print character lists as lists 35 let _ = command.arg("-stdlib").arg("shell_strings").arg("false"); 36 37 // Specify locations of .beam files 38 let packages = paths.build_directory_for_target(Mode::Dev, Target::Erlang); 39 for entry in crate::fs::read_dir(packages)?.filter_map(Result::ok) { 40 let _ = command.arg("-pa").arg(entry.path().join("ebin")); 41 } 42 43 crate::cli::print_running("Erlang shell"); 44 45 // Run the shell 46 tracing::info!("Running OS process {:?}", command); 47 let _ = command.status().map_err(|e| Error::ShellCommand { 48 program: "erl".into(), 49 reason: ShellCommandFailureReason::IoError(e.kind()), 50 })?; 51 Ok(()) 52}