From b4fc219dec5f1425face7904b8be9de203b1a8fd Mon Sep 17 00:00:00 2001 From: Nicholas Sim <95901680+sweishen@users.noreply.github.com> Date: Wed, 4 May 2022 19:19:56 +0800 Subject: [PATCH] Makefile: add environment variable to specify Binary Ninja path (#81) * Makefile: add environment variable to specify Binary Ninja path * Makefile: restore missing line * Makefile: use install_api from binja, not bundled * Makefile: use BINARY_NINJA_PATH correctly * Makefile.venv: error out and set deps correctly * Makefile.venv: use python -mpip, not pip --- Makefile.venv | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile.venv b/Makefile.venv index 150cf6349..2ff00cb26 100644 --- a/Makefile.venv +++ b/Makefile.venv @@ -1,4 +1,5 @@ PYTHON_VERSION := 3.8 +BINARY_NINJA_PATH := /opt/binaryninja PREFIX := . .PHONY: venv @@ -8,17 +9,20 @@ venv: $(VENV_PATH) $(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binary .ONESHELL: $(VENV_PATH) $(VENV_PATH): virtualenv -ppython$(PYTHON_VERSION) $(VENV_PATH) - . $(VENV_PATH)/bin/activate - pip install -r $(PREFIX)/requirements.txt - pip install -r $(PREFIX)/requirements-compiler-idioms.txt + $(VENV_PATH)/bin/python -mpip install -r $(PREFIX)/requirements.txt + $(VENV_PATH)/bin/python -mpip install -r $(PREFIX)/requirements-compiler-idioms.txt -$(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binaryninja.pth: -ifneq ($(wildcard $(PREFIX)/install_api.py),"") - . $(VENV_PATH)/bin/activate && \ - $(VENV_PATH)/bin/python $$(readlink -f $(PREFIX)/install_api.py) && \ - echo "/opt/binaryninja/python" > $(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binaryninja.pth -else +$(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binaryninja.pth: $(BINARY_NINJA_PATH)/python $(BINARY_NINJA_PATH)/scripts/install_api.py + $(VENV_PATH)/bin/python $$(readlink -f $(BINARY_NINJA_PATH)/scripts/install_api.py) + echo "$(BINARY_NINJA_PATH)/python" > $(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binaryninja.pth + + +$(BINARY_NINJA_PATH)/python: + @$(error Failed to find Binary Ninja at '$(BINARY_NINJA_PATH)'. \ + Please set the BINARY_NINJA_PATH variable manually, e.g. \ + make ... BINARY_NINJA_PATH=/your/path/to/binja) + +$(BINARY_NINJA_PATH)/scripts/install_api.py: @$(error install_api.py not found. Please install the Binary Ninja API package manually using \ the install_api.py script from Binary Ninja.) -endif