Skip to content

Commit

Permalink
Add spacegrep to the main makefile and to the docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jambon authored and Martin Jambon committed Oct 14, 2020
1 parent da4231b commit 7cd5a0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# of the 'semgrep' wrapping.
#

FROM returntocorp/ocaml:alpine-2020-09-11 as build-semgrep-core
FROM returntocorp/ocaml:alpine-2020-10-07 as build-semgrep-core

USER user
WORKDIR /home/user

COPY --chown=user .gitmodules /semgrep/.gitmodules
COPY --chown=user .git/ /semgrep/.git/
COPY --chown=user semgrep-core/ /semgrep/semgrep-core/
COPY --chown=user spacegrep/ /semgrep/spacegrep/
COPY --chown=user scripts /semgrep/scripts

WORKDIR /semgrep
Expand All @@ -26,11 +27,15 @@ RUN git submodule foreach --recursive git clean -dfX
RUN git submodule update --init --recursive

RUN eval "$(opam env)" && ./scripts/install-ocaml-tree-sitter
RUN eval "$(opam env)" && opam install --deps-only -y spacegrep/
RUN eval "$(opam env)" && opam install --deps-only -y semgrep-core/pfff/
RUN eval "$(opam env)" && opam install --deps-only -y semgrep-core/
RUN eval "$(opam env)" && DUNE_PROFILE=static make -C spacegrep/
RUN eval "$(opam env)" && make -C semgrep-core/ all

# Sanity check
# Sanity checks
RUN test -x ./spacegrep/_build/install/default/bin/spacecat
RUN test -x ./spacegrep/_build/install/default/bin/spacegrep
RUN ./semgrep-core/_build/install/default/bin/semgrep-core -version

#
Expand All @@ -48,6 +53,13 @@ COPY --from=build-semgrep-core \
/semgrep/semgrep-core/_build/install/default/bin/semgrep-core /usr/local/bin/semgrep-core
RUN semgrep-core -version

COPY --from=build-semgrep-core \
/semgrep/spacegrep/_build/install/default/bin/spacecat \
/usr/local/bin/spacecat
COPY --from=build-semgrep-core \
/semgrep/spacegrep/_build/install/default/bin/spacegrep \
/usr/local/bin/spacegrep

COPY semgrep /semgrep
RUN HOMEBREW_SYSTEM='NOCORE' python -m pip install /semgrep
RUN semgrep --version
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
.PHONY: build
build:
$(MAKE) build-spacegrep
$(MAKE) build-core
cd semgrep && pipenv install --dev

Expand All @@ -26,6 +27,10 @@ build-ocaml-tree-sitter:
$(MAKE) -C ocaml-tree-sitter
$(MAKE) -C ocaml-tree-sitter install

.PHONY: build-spacegrep
build-spacegrep:
$(MAKE) -C spacegrep

# Update and rebuild everything within the project.
#
# At the moment, this is useful when ocaml-tree-sitter get updated,
Expand All @@ -49,6 +54,7 @@ setup:
cd ocaml-tree-sitter && ./scripts/install-tree-sitter-lib
opam install -y --deps-only ./ocaml-tree-sitter
opam install -y --deps-only ./semgrep-core
opam install -y --deps-only ./spacegrep

# This needs to run initially or when something changed in the external
# build environment. This typically looks for the location of libraries
Expand Down

0 comments on commit 7cd5a0a

Please sign in to comment.