mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
feat: do not hardcode the platform path
This commit is contained in:
parent
4f19eedce4
commit
bddc69896c
1 changed files with 54 additions and 20 deletions
|
@ -20,7 +20,9 @@ use roc_mono::ir::{
|
|||
};
|
||||
use roc_mono::layout::{Layout, LayoutCache};
|
||||
use roc_parse::ast::{self, Attempting, StrLiteral, TypeAnnotation};
|
||||
use roc_parse::header::{ExposesEntry, ImportsEntry, PlatformHeader, TypedIdent};
|
||||
use roc_parse::header::{
|
||||
ExposesEntry, ImportsEntry, PackageEntry, PackageOrPath, PlatformHeader, TypedIdent,
|
||||
};
|
||||
use roc_parse::module::module_defs;
|
||||
use roc_parse::parser::{self, Fail, Parser};
|
||||
use roc_region::all::{Located, Region};
|
||||
|
@ -542,6 +544,7 @@ struct ModuleHeader<'a> {
|
|||
exposed_ident_ids: IdentIds,
|
||||
deps_by_name: MutMap<ModuleName, ModuleId>,
|
||||
imported_modules: MutSet<ModuleId>,
|
||||
imported_package_modules: MutSet<ModuleId>,
|
||||
exposes: Vec<Symbol>,
|
||||
exposed_imports: MutMap<Ident, (Symbol, Region)>,
|
||||
src: &'a [u8],
|
||||
|
@ -2036,9 +2039,33 @@ fn parse_header<'a>(
|
|||
module_timing,
|
||||
);
|
||||
|
||||
let opt_base_package = header.packages.iter().find(|loc_package_entry| {
|
||||
let Located { value, .. } = loc_package_entry;
|
||||
|
||||
match value {
|
||||
PackageEntry::Entry { shorthand, .. } => shorthand == &"base",
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
match opt_base_package {
|
||||
Some(Located {
|
||||
value:
|
||||
PackageEntry::Entry {
|
||||
package_or_path:
|
||||
Located {
|
||||
value: package_or_path,
|
||||
..
|
||||
},
|
||||
..
|
||||
},
|
||||
..
|
||||
}) => {
|
||||
match package_or_path {
|
||||
PackageOrPath::Path(StrLiteral::PlainLine(package)) => {
|
||||
// check whether we can find a Pkg-Config.roc file
|
||||
let mut pkg_config_roc = pkg_config_dir.clone();
|
||||
pkg_config_roc.push("platform");
|
||||
pkg_config_roc.push(package);
|
||||
pkg_config_roc.push(PKG_CONFIG_FILE_NAME);
|
||||
pkg_config_roc.set_extension(ROC_FILE_EXTENSION);
|
||||
|
||||
|
@ -2059,6 +2086,12 @@ fn parse_header<'a>(
|
|||
Ok((module_id, app_module_header_msg))
|
||||
}
|
||||
}
|
||||
_ => panic!("TODO not yet implement none path platform imports"),
|
||||
}
|
||||
}
|
||||
_ => panic!("could not find base"),
|
||||
}
|
||||
}
|
||||
Ok((ast::Module::Platform { header }, _parse_state)) => fabricate_effects_module(
|
||||
arena,
|
||||
module_ids,
|
||||
|
@ -2291,6 +2324,7 @@ fn send_header<'a>(
|
|||
exposed_ident_ids: ident_ids,
|
||||
module_name: loc_name.value,
|
||||
imported_modules,
|
||||
imported_package_modules,
|
||||
deps_by_name,
|
||||
exposes: exposed,
|
||||
src: parse_state.bytes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue