Skip to content

Commit

Permalink
OS-8366 Platform build needs more python2.7 nudging
Browse files Browse the repository at this point in the history
Portions by: Brian Bennett <[email protected]>
Reviewed by: Brian Bennett <[email protected]>
Approved by: Brian Bennett <[email protected]>
  • Loading branch information
Dan McDonald authored Mar 21, 2022
1 parent c76f480 commit f9079d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
37 changes: 31 additions & 6 deletions tools/javascriptlint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,38 @@ CPPFLAGS += -DNDEBUG -D_REENTRANT \
-Ispidermonkey/src -Ispidermonkey/src/build \
-I/usr/include \


PY_PYTHON=$(shell python -c "import sys; print(sys.executable)")
PY_PREFIX=$(shell $(PY_PYTHON) -c "import sys; print(sys.prefix)")
# Try to get a Python 2. On macOS there isn't a "python2". On
# SmartOS pkgsrc 2019Q2 minimal "python" is v3.
ifeq ($(BUILDOS),Darwin)
# As of macOS 12, we can't use the system python anymore, so take the
# first one that's not in /usr/bin.
PY_EXEC=$(shell which -a python2.7 | grep -v /usr/bin/python | head -1)
else
PY_EXEC=$(shell which python2.7)
endif
ifndef PY_EXEC
# If we get here, there wasn't a python2.7 binary. It's getting pretty
# untennable at this point, because even as it is, python2.7 isn't
# supported anymore, and anything older than that is even worse off, but
# at least we won't break anybody who was previously working.
#
# For macOS 12 that gets here, this will pick up the system python which
# will refuse to link later because linking against system python is
# no longer allowed. That means that while it's still broken, there's
# nothing we can do about it and we're no worse off than before. If you're
# reading this trying to figure out how to compile this on macOS 12+,
# you need to install your own python2.7 and have that in your PATH.
PY_EXEC=$(shell which python2)
endif
ifndef PY_EXEC
PY_EXEC=python
endif
PY_PYTHON=$(shell $(PY_EXEC) -c "import sys; print(sys.executable)")
PY_PREFIX=$(shell $(PY_PYTHON) -c "import sys; print(sys.real_prefix)" || $(PY_PYTHON) -c "import sys; print(sys.prefix)")
PY_VERSION=$(shell $(PY_PYTHON) -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
ifeq ($(BUILDOS),Darwin)
PY_ARCH=$(shell $(PY_PYTHON) -c 'import sys; print (sys.maxint > 2**32 and "x86_64" or "i386")')
SOLDFLAGS += $(PY_PREFIX)/Python
PY_ARCH=$(shell $(PY_PYTHON) -c 'import platform; print platform.machine()')
SOLDFLAGS += -lpython$(PY_VERSION)
CC=gcc -arch $(PY_ARCH)
else
PY_BIT=$(shell $(PY_PYTHON) -c 'import sys; print (sys.maxint > 2**32 and "64" or "32")')
Expand All @@ -40,7 +65,7 @@ $(BUILDDIR) $(INSTALLDIRS):
$(OBJECTS): spidermonkey/src/build/libjs.a spidermonkey/src/build/js_operating_system.h

$(SOFILE): $(OBJECTS)
$(CC) $(CFLAGS) $(SOLDFLAGS) $(LDFLAGS) $(OBJECTS) -Lspidermonkey/src/build -ljs -o $@
$(CC) $(CFLAGS) $(SOLDFLAGS) $(LDFLAGS) $(OBJECTS) -L$(PY_PREFIX)/lib -Lspidermonkey/src/build -ljs -o $@

$(BUILDDIR)/%.o: javascriptlint/pyspidermonkey/%.c | $(BUILDDIR)
$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
Expand Down
6 changes: 5 additions & 1 deletion tools/sorter
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python2.7
# vi: expandtab ts=4 sw=4
#
# Takes a 'manifest' style file and outputs a sorted version. It will emit
Expand All @@ -10,6 +10,10 @@
#
# Dev Note: This should work with any Python >= 2.6 (including Python 3).
#
# Dev Note 2: Sometimes pkgsrc zones don't deliver "python" so the above
# has been hardwired to Python 2.7, which other components (e.g. our old
# Node.JS) require anyway.
#

import os
import sys
Expand Down

0 comments on commit f9079d8

Please sign in to comment.