Skip to content

Commit 0693fb0

Browse files
WizKidfacebook-github-bot
authored andcommitted
If asked to build type scanners and none exists then we fail!
Summary: - This makes it so we only build type scanners when we can - But also if you try to build them and it fails it will fail the build - That way if it breaks we will know about it. - Also change so we don't put type scanner stuff in dynamic functions if we aren't going to use them. Reviewed By: jtwarren Differential Revision: D67114451 fbshipit-source-id: fb15c146bb72fc19657ac6890599d2d6643870ee
1 parent 2e17159 commit 0693fb0

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

hphp/hhvm/dynamic-functions renamed to hphp/hhvm/generate-dynamic-functions.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
#!/bin/bash
2+
3+
FILE="${OUT}"
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "Usage $0 on|off"
7+
exit 1
8+
fi
9+
10+
cat > "$FILE" <<- EOM
111
{
12+
EOM
13+
if [ "$1" = "on" ]; then
14+
cat >> "$FILE" <<- EOM
215
extern "C++" {
316
HPHP::type_scan::detail::Indexer*;
417
*::_type_scan_custom_*;
518
};
19+
EOM
20+
fi
21+
cat >> "$FILE" <<- EOM
622
extern "C" {
723
hphp_type_scan_module_init;
824
g_member_reflection_vtable_impl;
@@ -21,3 +37,4 @@
2137
xallocx;
2238
};
2339
};
40+
EOM

hphp/tools/type-info-gens/gen-type-scanners.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct Generator {
245245
explicit Generator(const std::string&, bool skip);
246246

247247
// Turn the layouts into C++ code, writing to the specified ostream.
248-
void operator()(std::ostream&) const;
248+
void operator()(std::ostream&, bool skip) const;
249249
private:
250250
static bool isTemplateName(const std::string& candidate,
251251
const std::string& name);
@@ -687,9 +687,8 @@ Generator::Generator(const std::string& filename, bool skip) {
687687
// Complain if it looks like we don't have any debug info enabled.
688688
// (falls back to conservative scanning for everything)
689689
if (collectable_markers.empty() && indexer_types.empty()) {
690-
std::cerr << "gen-type-scanners: warning: "
691-
"No collectable or indexed types found. "
692-
"Is debug-info enabled?" << std::endl;
690+
throw Exception("No collectable or indexed types found. "
691+
"Is debug-info enabled?");
693692
}
694693

695694
// Extract all the types that Mark[Scannable]Collectable<> was instantiated on
@@ -3224,7 +3223,11 @@ void Generator::genMetrics(std::ostream& os) const {
32243223
}
32253224

32263225
// Generate the entire C++ file.
3227-
void Generator::operator()(std::ostream& os) const {
3226+
void Generator::operator()(std::ostream& os, bool skip) const {
3227+
if (!skip && m_layouts.empty()) {
3228+
throw Exception{"No layouts generated"};
3229+
}
3230+
32283231
os << "#include <limits>\n\n";
32293232

32303233
os << "#include \"hphp/util/assertions.h\"\n";
@@ -3449,7 +3452,7 @@ int main(int argc, char** argv) {
34493452
}
34503453
Generator generator{source_executable, skip};
34513454
std::ofstream output_file{output_filename};
3452-
generator(output_file);
3455+
generator(output_file, skip);
34533456
} catch (const debug_parser::Exception& exn) {
34543457
std::cerr << "\nError generating type scanners:\n"
34553458
<< exn.what() << std::endl << std::endl;

0 commit comments

Comments
 (0)