Skip to content

Commit

Permalink
[build] Restore help metadata, to translate to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy C committed Aug 9, 2023
1 parent 7ba1609 commit 2bf0578
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/NINJA_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def NinjaGraph(ru):

'//frontend/arg_types',
'//frontend/consts',
#'//frontend/help_meta',
'//frontend/help_meta',
'//frontend/id_kind.asdl',
'//frontend/option.asdl',
'//frontend/signal',
Expand Down
14 changes: 8 additions & 6 deletions core/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,11 @@
from core import optview
from frontend.py_readline import Readline

TOPIC_META = {} # type: Dict[str, str]

if mylib.PYTHON:
try:
from _devbuild.gen import help_meta # type: ignore
TOPIC_META = help_meta.TopicMetadata()
except ImportError:
# This happens in the 'minimal' dev build
pass
help_meta = None


def MakeBuiltinArgv(argv1):
Expand Down Expand Up @@ -626,7 +622,13 @@ def Main(lang, arg_r, environ, login_shell, loader, readline):
AddProcess(builtins, mem, shell_ex, ext_prog, fd_state, job_control,
job_list, waiter, tracer, search_path, errfmt)

help_data = TOPIC_META
if mylib.PYTHON:
if help_meta:
help_data = help_meta.TopicMetadata()
else:
help_data = {} # minimal build
else:
help_data = help_meta.TopicMetadata()
builtins[builtin_i.help] = builtin_misc.Help(lang, loader, help_data,
errfmt)

Expand Down
3 changes: 1 addition & 2 deletions cpp/preamble.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include "_gen/core/runtime.asdl.h"
#include "_gen/frontend/arg_types.h"
#include "_gen/frontend/consts.h"
// TODO: restore this
// #include "_gen/frontend/help_meta.h"
#include "_gen/frontend/help_meta.h"
#include "_gen/frontend/id_kind.asdl.h" // syntax.asdl depends on this
#include "_gen/frontend/option.asdl.h"
#include "_gen/frontend/signal.h"
Expand Down
4 changes: 2 additions & 2 deletions doctools/help_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def TopicMetadata():
#include "mycpp/runtime.h"
namespace help_meta {
List<Str*>* TopicMetadata();
Dict<Str*, Str*>* TopicMetadata();
}
''')

Expand All @@ -515,7 +515,7 @@ def TopicMetadata():
#include "mycpp/runtime.h"
namespace help_meta {
List<Str*>* TopicMetadata() {
Dict<Str*, Str*>* TopicMetadata() {
return nullptr;
}
}
Expand Down
4 changes: 4 additions & 0 deletions mycpp/cppgen_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def __init__(self,

self.imported_names = set() # MemberExpr -> module::Foo() or self->foo

# HACK for conditional import inside mylib.PYTHON
# in core/shell.py
self.imported_names.add('help_meta')

# So we can report multiple at once
# module path, line number, message
self.errors_keep_going: List[Tuple[str, int, str]] = []
Expand Down

0 comments on commit 2bf0578

Please sign in to comment.