-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix include paths #263
Fix include paths #263
Changes from all commits
2508999
5767ddb
f3e5603
0521c69
251b978
fd743cb
d58ad43
d4666f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
from sphinx.util.docutils import switch_source_input, SphinxDirective | ||
from sphinx.util import logging | ||
|
||
from hawkmoth.util import compiler | ||
from hawkmoth.parser import parse, ErrorLevel | ||
from hawkmoth.util import strutil | ||
from hawkmoth import docstring | ||
|
@@ -54,16 +55,16 @@ def __display_parser_diagnostics(self, errors): | |
location=(self.env.docname, self.lineno)) | ||
|
||
def __get_clang_args(self): | ||
clang_args = [] | ||
|
||
clang_args.extend(self.env.config.hawkmoth_clang.copy()) | ||
clang_args = self.env.config.hawkmoth_clang.copy() | ||
|
||
BrunoMSantos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if self._domain == 'c': | ||
clang_args.extend(self.env.config.hawkmoth_clang_c.copy()) | ||
clang_args.extend(self.options.get('clang', [])) | ||
clang_args.extend(self.env.config._clang_args_post_c.copy()) | ||
else: | ||
clang_args.extend(self.env.config.hawkmoth_clang_cpp.copy()) | ||
|
||
clang_args.extend(self.options.get('clang', [])) | ||
clang_args.extend(self.options.get('clang', [])) | ||
clang_args.extend(self.env.config._clang_args_post_cpp.copy()) | ||
BrunoMSantos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return clang_args | ||
|
||
|
@@ -354,10 +355,31 @@ def _doctree_read(app, doctree): | |
onlynode += nodes.reference('', '', inline, internal=False, refuri=uri) | ||
signode += onlynode | ||
|
||
def _autoconf(app, config): | ||
logger = logging.getLogger(__name__) | ||
cpath = config.hawkmoth_compiler | ||
autoconf = config.hawkmoth_autoconf | ||
|
||
ignored_options = [x for x in autoconf if x not in ['stdinc']] | ||
if len(ignored_options) > 0: | ||
logger.warning(f'autoconf: {ignored_options} unsupported option(s) ignored') | ||
|
||
config._clang_args_post_c = [] | ||
config._clang_args_post_cpp = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the "post" refers to in the naming. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just me nitpicking... ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meant to denote that these are postfixed to all other ones. Any better suggestion with that in mind? |
||
|
||
if 'stdinc' in autoconf: | ||
if cpath: | ||
config._clang_args_post_c = compiler.get_include_args(cpath, 'c') | ||
config._clang_args_post_cpp = compiler.get_include_args(cpath, 'c++') | ||
else: | ||
logger.warning('autoconf: \'stdinc\' option ignored (missing compiler)') | ||
|
||
def setup(app): | ||
app.require_sphinx('3.0') | ||
|
||
app.add_config_value('hawkmoth_root', app.confdir, 'env', [str]) | ||
app.add_config_value('hawkmoth_compiler', 'clang', 'env', [str, type(None)]) | ||
app.add_config_value('hawkmoth_autoconf', ['stdinc'], 'env', [list]) | ||
app.add_config_value('hawkmoth_clang', [], 'env', [list]) | ||
app.add_config_value('hawkmoth_clang_c', [], 'env', [list]) | ||
app.add_config_value('hawkmoth_clang_cpp', [], 'env', [list]) | ||
|
@@ -387,6 +409,9 @@ def setup(app): | |
|
||
app.add_event('hawkmoth-process-docstring') | ||
|
||
# Auto configure once during initialization. | ||
app.connect('config-inited', _autoconf) | ||
|
||
# Source code link | ||
app.add_config_value('hawkmoth_source_uri', None, 'env', [str]) | ||
app.connect('doctree-read', _doctree_read) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WARNING: autoconf: ['invalid'] unsupported option(s) ignored |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
test: | ||
- extension | ||
directives: | ||
- domain: c | ||
directive: autodoc | ||
arguments: | ||
- doc.c | ||
conf-overrides: | ||
hawkmoth_autoconf: | ||
- 'invalid' | ||
errors: autoconf-invalid.stderr | ||
expected: doc.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test: | ||
- extension | ||
directives: | ||
- domain: c | ||
directive: autodoc | ||
arguments: | ||
- bool.c | ||
conf-overrides: | ||
hawkmoth_clang: -nostdinc | ||
hawkmoth_compiler: clang | ||
hawkmoth_autoconf: | ||
- 'stdinc' | ||
expected: bool.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
WARNING: autoconf: 'stdinc' option ignored (missing compiler) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test: | ||
- extension | ||
directives: | ||
- domain: c | ||
directive: autodoc | ||
arguments: | ||
- doc.c | ||
conf-overrides: | ||
hawkmoth_compiler: null | ||
hawkmoth_autoconf: | ||
- 'stdinc' | ||
errors: compiler-autoconf-mismatch.stderr | ||
expected: doc.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
WARNING: get_include_args: c compiler not found ('invalid') | ||
WARNING: get_include_args: c++ compiler not found ('invalid') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test: | ||
- extension | ||
directives: | ||
- domain: c | ||
directive: autodoc | ||
arguments: | ||
- doc.c | ||
conf-overrides: | ||
hawkmoth_compiler: invalid | ||
errors: compiler-not-found.stderr | ||
expected: doc.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
WARNING: get_include_args: incompatible c compiler ('false') | ||
WARNING: get_include_args: incompatible c++ compiler ('false') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test: | ||
- extension | ||
directives: | ||
- domain: c | ||
directive: autodoc | ||
arguments: | ||
- doc.c | ||
conf-overrides: | ||
hawkmoth_compiler: false | ||
errors: compiler-unknown.stderr | ||
expected: doc.rst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message should mention why. To the
clang
binary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dammit, good question. I know this was needed (at some point?), but can't figure it out. I'll push the branch without it to check where or if it still fails and work from there :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the issue is with the new
from hawkmoth.util import compiler
in testenv, which the example check depends on. In turn, hawkmoth imports the clang bindings in the init...The dependency is 'fake', but I'm not liking the alternatives as we'd need to nest the actual important bits of hawkmoth's API deeper within (e.g.
hawkmoth.directives.CAutoDocDirective
) or take the utils out (right?)... I'll push it again with a better commit message for now, let me know what you think.