mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Add no_build_rs
feature
This commit is contained in:
parent
a1688b972b
commit
afd8d33d49
4 changed files with 35 additions and 21 deletions
|
@ -22,6 +22,7 @@ traditional_chinese = [
|
|||
"erg_common/traditional_chinese",
|
||||
"erg_parser/traditional_chinese",
|
||||
]
|
||||
no_build_rs = []
|
||||
|
||||
[dependencies]
|
||||
erg_common = { version = "0.5.9", path = "../erg_common" }
|
||||
|
|
|
@ -5,6 +5,9 @@ use std::fs;
|
|||
use std::path;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
if cfg!(feature = "no_build_rs") {
|
||||
return Ok(());
|
||||
}
|
||||
// Create a ".erg" directory
|
||||
let erg_path = env::home_dir()
|
||||
.expect("failed to get the location of the home dir")
|
||||
|
|
|
@ -2051,27 +2051,36 @@ impl CodeGenerator {
|
|||
}
|
||||
|
||||
fn load_prelude_py(&mut self) {
|
||||
self.emit_global_import_items(
|
||||
Identifier::public("sys"),
|
||||
vec![(
|
||||
Identifier::public("path"),
|
||||
Some(Identifier::private("#path")),
|
||||
)],
|
||||
);
|
||||
self.emit_load_name_instr(Identifier::private("#path"));
|
||||
self.emit_load_method_instr("Array!", None, Identifier::public("push!"));
|
||||
self.emit_load_const(env!("ERG_STD_PATH"));
|
||||
self.write_instr(CALL_METHOD);
|
||||
self.write_arg(1u8);
|
||||
self.stack_dec();
|
||||
self.emit_pop_top();
|
||||
self.emit_global_import_items(
|
||||
Identifier::public("_erg_std_prelude"),
|
||||
vec![(
|
||||
Identifier::public("in_operator"),
|
||||
Some(Identifier::private("#in_operator")),
|
||||
)],
|
||||
);
|
||||
if let Some(std_path) = option_env!("ERG_STD_PATH") {
|
||||
self.emit_global_import_items(
|
||||
Identifier::public("sys"),
|
||||
vec![(
|
||||
Identifier::public("path"),
|
||||
Some(Identifier::private("#path")),
|
||||
)],
|
||||
);
|
||||
self.emit_load_name_instr(Identifier::private("#path"));
|
||||
self.emit_load_method_instr("Array!", None, Identifier::public("push!"));
|
||||
self.emit_load_const(std_path);
|
||||
self.write_instr(CALL_METHOD);
|
||||
self.write_arg(1u8);
|
||||
self.stack_dec();
|
||||
self.emit_pop_top();
|
||||
self.emit_global_import_items(
|
||||
Identifier::public("_erg_std_prelude"),
|
||||
vec![(
|
||||
Identifier::public("in_operator"),
|
||||
Some(Identifier::private("#in_operator")),
|
||||
)],
|
||||
);
|
||||
} else {
|
||||
self.emit_load_name_instr(Identifier::private("exec"));
|
||||
self.emit_load_const(include_str!("std/_erg_std_prelude.py"));
|
||||
self.write_instr(CALL_FUNCTION);
|
||||
self.write_arg(1u8);
|
||||
self.stack_dec();
|
||||
self.emit_pop_top();
|
||||
}
|
||||
}
|
||||
|
||||
fn load_record_type(&mut self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue