summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-25 16:13:14 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-25 16:13:14 +0800
commita2fc0567c434af1d5888db4f5c82df7f1e6b970f (patch)
treed72548d0b8a3aba415f7a09e3b19743781e19ccf /src
parent50b01c18df98c8502f823a4b9a9e347514870858 (diff)
downloadmrust-a2fc0567c434af1d5888db4f5c82df7f1e6b970f.tar.gz
Start on liblibc - Add cfg_attr support to LoadCrates
Diffstat (limited to 'src')
-rw-r--r--src/ast/crate.cpp11
-rw-r--r--src/main.cpp4
2 files changed, 15 insertions, 0 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index fc93a809..5f27e02f 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -59,6 +59,7 @@ void Crate::load_externs()
// Check for no_std or no_core, and load libstd/libcore
// - Duplicates some of the logic in "Expand", but also helps keep crate loading separate to most of expand
+ // NOTE: Not all crates are loaded here, any crates loaded by macro invocations will be done during expand.
bool no_std = false;
bool no_core = false;
@@ -68,6 +69,16 @@ void Crate::load_externs()
no_std = true;
if( a.name() == "no_core" )
no_core = true;
+ if( a.name() == "cfg_attr" && a.items().size() == 2 ) {
+ if( check_cfg(this->m_attrs.m_span, a.items().at(0)) )
+ {
+ const auto& a2 = a.items().at(1);
+ if( a2.name() == "no_std" )
+ no_std = true;
+ if( a2.name() == "no_core" )
+ no_core = true;
+ }
+ }
}
if( no_core ) {
diff --git a/src/main.cpp b/src/main.cpp
index b3425e0d..439ccbaf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -147,6 +147,7 @@ int main(int argc, char *argv[])
Cfg_SetValue("target_pointer_width", "64");
Cfg_SetValue("target_endian", "little");
Cfg_SetValue("target_arch", "x86-noasm"); // TODO: asm! macro
+ Cfg_SetValue("target_os", "foobar");
Cfg_SetValueCb("target_has_atomic", [](const ::std::string& s) {
if(s == "8") return true; // Has an atomic byte
if(s == "ptr") return true; // Has an atomic pointer-sized value
@@ -155,6 +156,9 @@ int main(int argc, char *argv[])
Cfg_SetValueCb("target_feature", [](const ::std::string& s) {
return false;
});
+ Cfg_SetValueCb("feature", [](const ::std::string& s) {
+ return false;
+ });
try