Patchwork D10252: fuzz: use Python 3 in makefile

login
register
mail settings
Submitter phabricator
Date March 22, 2021, 10:35 p.m.
Message ID <differential-rev-PHID-DREV-7ccbe2kiwcbxbk6l7rbx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48568/
State Superseded
Headers show

Comments

phabricator - March 22, 2021, 10:35 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As in the previous patch, I copied the snippet defining `PYTHON` from
  the root Makefile.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10252

AFFECTED FILES
  contrib/fuzz/Makefile

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/fuzz/Makefile b/contrib/fuzz/Makefile
--- a/contrib/fuzz/Makefile
+++ b/contrib/fuzz/Makefile
@@ -10,6 +10,15 @@ 
 # OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
 LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
 
+# Default to Python 3.
+#
+# Windows ships Python 3 as `python.exe`, which may not be on PATH.  py.exe is.
+ifeq ($(OS),Windows_NT)
+PYTHON?=py -3
+else
+PYTHON?=python3
+endif
+
 PYTHON_CONFIG ?= $$OUT/sanpy/bin/python-config
 PYTHON_CONFIG_FLAGS ?= --ldflags --embed
 
@@ -20,7 +29,7 @@ 
 standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cc
 
 $$OUT/%_fuzzer_seed_corpus.zip: %_corpus.py
-	python $< $@
+	$(PYTHON) $< $@
 
 pyutil.o: pyutil.cc pyutil.h
 	$(CXX) $(CXXFLAGS) -g -O1 \