Skip to content

Commit

Permalink
fix(build): Fix running build scripts on Windows.
Browse files Browse the repository at this point in the history
Fixes #2988

Change-Id: I09b1fad048da5172281db52cc0e2b615955a2b19
  • Loading branch information
TheModMaker committed Nov 13, 2020
1 parent 57d11d1 commit 0bd4c69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ def generate(self, force=False):

def_generator = _get_source_path('build/generateTsDefs.py')

cmd_line = [def_generator, '--output', self.output]
cmd_line = [sys.executable or 'python', def_generator, '--output',
self.output]
cmd_line += self.source_files

if shakaBuildHelpers.execute_get_code(cmd_line) != 0:
Expand Down
7 changes: 7 additions & 0 deletions build/shakaBuildHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ def execute_subprocess(args, **kwargs):
Returns:
The same value as subprocess.Popen.
"""
# Windows can't run scripts directly, even if executable. We need to
# explicitly run the interpreter.
if args[0].endswith('.js'):
raise ValueError('Use "node" to run JavaScript scripts')
if args[0].endswith('.py'):
raise ValueError('Use sys.executable to run Python scripts')

if os.environ.get('PRINT_ARGUMENTS'):
logging.info(' '.join([quote_argument(x) for x in args]))
try:
Expand Down

0 comments on commit 0bd4c69

Please sign in to comment.