Skip to content

Commit

Permalink
Makefile: add environment variable to specify Binary Ninja path (#81)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sweishen authored May 4, 2022
1 parent f15d8c3 commit b4fc219
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Makefile.venv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PYTHON_VERSION := 3.8
BINARY_NINJA_PATH := /opt/binaryninja
PREFIX := .

.PHONY: venv
Expand All @@ -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

0 comments on commit b4fc219

Please sign in to comment.