Skip to content

Commit 76effc6

Browse files
committed
Add multi include path feature for bundling c++ code
1 parent ec1809d commit 76effc6

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

onlinejudge_bundle/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ def main(args: Optional[List[str]] = None) -> None:
2222
# parse command-line arguments
2323
parser = argparse.ArgumentParser()
2424
parser.add_argument('path', type=pathlib.Path)
25-
parser.add_argument('-I', metavar='dir', type=pathlib.Path, dest='iquote', default=pathlib.Path.cwd(), help='add the directory dir to the list of directories to be searched for header files during preprocessing (default: ".")')
25+
parser.add_argument('-I', metavar='dir', action='append', type=pathlib.Path, dest='iquote', default=[pathlib.Path.cwd()], help='add the directory dir to the list of directories to be searched for header files during preprocessing (default: ".")')
2626
parsed = parser.parse_args(args)
2727

2828
language = onlinejudge_verify.languages.list.get(parsed.path)
2929
assert language is not None
30-
sys.stdout.buffer.write(language.bundle(parsed.path, basedir=parsed.iquote))
30+
sys.stdout.buffer.write(language.bundle(parsed.path, options={'include_paths': parsed.iquote}))
3131

3232

3333
if __name__ == "__main__":

onlinejudge_verify/languages/cplusplus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def list_dependencies(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Lis
186186
joined_CXXFLAGS = ' '.join(map(shlex.quote, [*env.CXXFLAGS, '-I', str(basedir)]))
187187
return _cplusplus_list_depending_files(path.resolve(), CXX=env.CXX, joined_CXXFLAGS=joined_CXXFLAGS)
188188

189-
def bundle(self, path: pathlib.Path, *, basedir: pathlib.Path) -> bytes:
190-
bundler = Bundler(iquotes=[basedir])
189+
def bundle(self, path: pathlib.Path, *, basedir: pathlib.Path=pathlib.Path.cwd(), options: Dict[str, Any]) -> bytes:
190+
bundler = Bundler(iquotes=options['include_paths'])
191191
bundler.update(path)
192192
return bundler.get()
193193

onlinejudge_verify/languages/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def list_dependencies(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Lis
4040
raise NotImplementedError
4141

4242
@abc.abstractmethod
43-
def bundle(self, path: pathlib.Path, *, basedir: pathlib.Path) -> bytes:
43+
def bundle(self, path: pathlib.Path, *, basedir: pathlib.Path, options: Dict[str, Any]) -> bytes:
4444
"""
4545
:throws Exception:
4646
:throws NotImplementedError:

0 commit comments

Comments
 (0)