Skip to content

Commit

Permalink
[Makefile] Adjust to encounter requirements of compiler idioms (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: Steffen Enders <[email protected]>
  • Loading branch information
github-actions[bot] and steffenenders authored Aug 2, 2022
1 parent bf72c29 commit c6549e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ COPY license.txt /root/.binaryninja/license.dat
RUN mkdir -p /opt/dewolf && test -f /opt/dewolf/install_api.py || ln -s /opt/binaryninja/scripts/install_api.py /opt/dewolf/install_api.py

# update binja and cache this docker image
COPY Makefile.venv requirements.txt update_binja.py /opt/dewolf/
COPY ./dewolf-idioms/requirements.txt /opt/dewolf/requirements-compiler-idioms.txt
RUN make -f /opt/dewolf/Makefile.venv venv VENV_PATH=/opt/dewolf/.venv PREFIX=/opt/dewolf

COPY . /opt/dewolf
RUN cd /opt/dewolf & make -f /opt/dewolf/Makefile.venv venv VENV_PATH=/opt/dewolf/.venv PREFIX=/opt/dewolf

RUN mkdir -p /root/.binaryninja/plugins/ && cp -r /opt/dewolf/dewolf-idioms/ /root/.binaryninja/plugins/
WORKDIR /opt/dewolf
9 changes: 6 additions & 3 deletions Makefile.venv
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
PYTHON_VERSION := 3.8
BINARY_NINJA_PATH := /opt/binaryninja
PREFIX := .
DEWOLF_IDIOMS_PATH := $(shell find $(PREFIX)/.. $(PREFIX)/. $(BINARY_NINJA_PATH)/plugins -maxdepth 2 -name "dewolf-idioms" -print 2>/dev/null | head -n 1)

.PHONY: venv
venv: $(VENV_PATH) $(VENV_PATH)/lib/python$(PYTHON_VERSION)/site-packages/binaryninja.pth


.ONESHELL: $(VENV_PATH)
$(VENV_PATH):
$(VENV_PATH): $(DEWOLF_IDIOMS_PATH)/requirements.txt
virtualenv -ppython$(PYTHON_VERSION) $(VENV_PATH)
$(VENV_PATH)/bin/python -mpip install -r $(PREFIX)/requirements.txt
$(VENV_PATH)/bin/python -mpip install -r $(PREFIX)/requirements-compiler-idioms.txt
$(VENV_PATH)/bin/python -mpip install -r $(DEWOLF_IDIOMS_PATH)/requirements.txt


$(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


$(DEWOLF_IDIOMS_PATH)/requirements.txt:
@$(error requirements.txt of dewolf-idioms not found. Please make sure you have cloned the repository and optionally set the DEWOLF_IDIOMS_PATH variable manually.)

$(BINARY_NINJA_PATH)/python:
@$(error Failed to find Binary Ninja at '$(BINARY_NINJA_PATH)'. \
Please set the BINARY_NINJA_PATH variable manually, e.g. \
Expand Down

0 comments on commit c6549e6

Please sign in to comment.