diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-05-15 21:19:57 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-05-15 21:19:57 +0800 |
commit | 0f59ded4389202468dd5bcb420724395afbfe1f7 (patch) | |
tree | 9c8058e576d1cf03e1dd05757d70a028e69250f4 /src | |
parent | 894950e87dc8c7631fe38cdfe47170ce1f94c062 (diff) | |
download | mrust-0f59ded4389202468dd5bcb420724395afbfe1f7.tar.gz |
Expand - Track include!/include_str!/include_bytes! files for dependencies
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/crate.hpp | 3 | ||||
-rw-r--r-- | src/expand/include.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/ast/crate.hpp b/src/ast/crate.hpp index 11fba9c0..79cb9cd7 100644 --- a/src/ast/crate.hpp +++ b/src/ast/crate.hpp @@ -57,7 +57,8 @@ public: bool m_test_harness = false; ::std::vector<TestDesc> m_tests; - //::std::vector<::std::string> m_extra_files; + /// Files loaded using things like include! and include_str! + mutable ::std::vector<::std::string> m_extra_files; // Procedural macros! ::std::vector<ProcMacroDef> m_proc_macros; diff --git a/src/expand/include.cpp b/src/expand/include.cpp index 59f33d47..8078d5d0 100644 --- a/src/expand/include.cpp +++ b/src/expand/include.cpp @@ -12,6 +12,7 @@ #include <parse/ttstream.hpp> #include <parse/lex.hpp> // Lexer (new files) #include <ast/expr.hpp> +#include <ast/crate.hpp> namespace { @@ -75,6 +76,7 @@ class CIncludeExpander: GET_CHECK_TOK(tok, lex, TOK_EOF); ::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path)); + crate.m_extra_files.push_back(file_path); try { return box$( Lexer(file_path) ); @@ -101,6 +103,7 @@ class CIncludeBytesExpander: GET_CHECK_TOK(tok, lex, TOK_EOF); ::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path)); + crate.m_extra_files.push_back(file_path); ::std::ifstream is(file_path); if( !is.good() ) { @@ -130,6 +133,7 @@ class CIncludeStrExpander: GET_CHECK_TOK(tok, lex, TOK_EOF); ::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path)); + crate.m_extra_files.push_back(file_path); ::std::ifstream is(file_path); if( !is.good() ) { |