Skip to content

Commit

Permalink
Inline makecmd in make mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 13, 2023
1 parent 3d0110a commit 13da5d7
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions sphinx/cmd/make_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def __init__(self, srcdir: str, builddir: str, opts: Sequence[str]) -> None:
self.srcdir = srcdir
self.builddir = builddir
self.opts = [*opts]
self.makecmd = os.environ.get('MAKE', 'make') # refer $MAKE to determine make command

def builddir_join(self, *comps: str) -> str:
return path.join(self.builddir, *comps)
Expand Down Expand Up @@ -105,10 +104,11 @@ def build_latexpdf(self) -> int:
if self.run_generic_build('latex') > 0:
return 1

if sys.platform == 'win32':
makecmd = os.environ.get('MAKE', 'make.bat')
else:
makecmd = self.makecmd
# Use $MAKE to determine the make command
make_fallback = 'make.bat' if sys.platform == 'win32' else 'make'
makecmd = os.environ.get('MAKE', make_fallback)
if not makecmd.lower().startswith('make'):
raise RuntimeError('Invalid $MAKE command: %r' % makecmd)
try:
with chdir(self.builddir_join('latex')):
return subprocess.call([makecmd, 'all-pdf'])
Expand All @@ -120,10 +120,11 @@ def build_latexpdfja(self) -> int:
if self.run_generic_build('latex') > 0:
return 1

if sys.platform == 'win32':
makecmd = os.environ.get('MAKE', 'make.bat')
else:
makecmd = self.makecmd
# Use $MAKE to determine the make command
make_fallback = 'make.bat' if sys.platform == 'win32' else 'make'
makecmd = os.environ.get('MAKE', make_fallback)
if not makecmd.lower().startswith('make'):
raise RuntimeError('Invalid $MAKE command: %r' % makecmd)
try:
with chdir(self.builddir_join('latex')):
return subprocess.call([makecmd, 'all-pdf'])
Expand All @@ -134,11 +135,16 @@ def build_latexpdfja(self) -> int:
def build_info(self) -> int:
if self.run_generic_build('texinfo') > 0:
return 1

# Use $MAKE to determine the make command
makecmd = os.environ.get('MAKE', 'make')
if not makecmd.lower().startswith('make'):
raise RuntimeError('Invalid $MAKE command: %r' % makecmd)
try:
with chdir(self.builddir_join('texinfo')):
return subprocess.call([self.makecmd, 'info'])
return subprocess.call([makecmd, 'info'])
except OSError:
print('Error: Failed to run: %s' % self.makecmd)
print('Error: Failed to run: %s' % makecmd)
return 1

def build_gettext(self) -> int:
Expand Down

0 comments on commit 13da5d7

Please sign in to comment.