mirror of
https://github.com/github/semantic.git
synced 2024-12-28 09:21:35 +03:00
Merge branch 'master' into json-output
This commit is contained in:
commit
6957168faa
@ -1,61 +1,17 @@
|
||||
-- GHCI settings for semantic, collected by running cabal repl -v and checking out the flags cabal passes to ghc.
|
||||
-- These live here instead of script/repl for ease of commenting.
|
||||
-- These live here instead of .ghci so cabal repl remains unaffected.
|
||||
-- These live here instead of script/ghci-flags so ghcide remains unaffected.
|
||||
|
||||
-- Basic verbosity
|
||||
:set -v1
|
||||
|
||||
-- No optimizations
|
||||
:set -O0
|
||||
|
||||
-- Compile to object code
|
||||
:set -fwrite-interface -fobject-code
|
||||
|
||||
-- Write build products to dist-repl (so that we don’t clobber 'cabal build' outputs)
|
||||
:set -outputdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
|
||||
:set -odir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
|
||||
:set -hidir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
|
||||
:set -stubdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build
|
||||
|
||||
-- Look for autogen’d files in dist-repl
|
||||
:set -idist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build/autogen
|
||||
|
||||
-- Load all our sources… remember to keep this up to date when we add new packages!
|
||||
-- But don’t add semantic-source, it’s important that we get that from hackage.
|
||||
:set -isemantic-analysis/src
|
||||
:set -isemantic-ast/src
|
||||
:set -isemantic-core/src
|
||||
:set -isemantic-java/src
|
||||
:set -isemantic-json/src
|
||||
:set -isemantic-python/src
|
||||
:set -isemantic-tags/src
|
||||
:set -iapp
|
||||
:set -isrc
|
||||
:set -ibench
|
||||
:set -itest
|
||||
|
||||
-- Default language mode & extensions
|
||||
:set -XHaskell2010
|
||||
:set -XStrictData
|
||||
|
||||
-- Warnings for compiling .hs files
|
||||
:set -Weverything
|
||||
:set -Wno-all-missed-specialisations
|
||||
:set -Wno-implicit-prelude
|
||||
:set -Wno-missed-specialisations
|
||||
:set -Wno-missing-import-lists
|
||||
:set -Wno-missing-local-signatures
|
||||
:set -Wno-monomorphism-restriction
|
||||
:set -Wno-name-shadowing
|
||||
:set -Wno-safe
|
||||
:set -Wno-unsafe
|
||||
:set -Wno-star-is-type
|
||||
-- Bonus: silence “add these modules to your .cabal file” warnings for files we :load
|
||||
:set -Wno-missing-home-modules
|
||||
|
||||
-- Don’t fail on warnings when in the repl
|
||||
:set -Wwarn
|
||||
|
||||
-- Warnings for code written in the repl
|
||||
:seti -Weverything
|
||||
:seti -Wno-all-missed-specialisations
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -19,6 +19,7 @@ dist-repl
|
||||
tmp/
|
||||
/bin/
|
||||
|
||||
/src/Semantic/Version.hs.bak
|
||||
/semanticd/test/current
|
||||
/semanticd/test/rover-example-config/semantic.log
|
||||
/test/fixtures/*/examples
|
||||
@ -26,7 +27,6 @@ tmp/
|
||||
*.hp
|
||||
*.prof
|
||||
*.pyc
|
||||
/hie.yaml
|
||||
|
||||
/test.*
|
||||
/*.html
|
||||
|
17
Dockerfile
17
Dockerfile
@ -22,22 +22,11 @@ ENTRYPOINT ["/protobuf/bin/protoc", "-I/protobuf", "--plugin=protoc-gen-haskell=
|
||||
FROM haskell:8.6 as build
|
||||
WORKDIR /build
|
||||
|
||||
# Build just the dependencies so that this layer can be cached
|
||||
COPY semantic.cabal .
|
||||
COPY semantic-analysis semantic-analysis/
|
||||
COPY semantic-ast semantic-ast/
|
||||
COPY semantic-core semantic-core/
|
||||
COPY semantic-java semantic-java/
|
||||
COPY semantic-json semantic-json/
|
||||
COPY semantic-python semantic-python/
|
||||
COPY semantic-tags semantic-tags/
|
||||
COPY cabal.project .
|
||||
RUN cabal v2-update && \
|
||||
cabal v2-build --flags="release" --only-dependencies
|
||||
|
||||
# Build all of semantic
|
||||
COPY . .
|
||||
RUN cabal v2-build --flags="release" semantic:exe:semantic
|
||||
RUN cabal v2-update && \
|
||||
cabal v2-configure --flags="release" && \
|
||||
cabal v2-build semantic:exe:semantic
|
||||
|
||||
# A fake `install` target until we can get `cabal v2-install` to work
|
||||
RUN cp $(find dist-newstyle/build/x86_64-linux -name semantic -type f -perm -u=x) /usr/local/bin/semantic
|
||||
|
4
hie.yaml
Normal file
4
hie.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
cradle:
|
||||
bios:
|
||||
program: script/ghci-flags
|
||||
dependency-program: script/ghci-flags-dependencies
|
65
script/ghci-flags
Executable file
65
script/ghci-flags
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
# Computes the flags for ghcide to pass to ghci. You probably won’t be running this yourself, but rather ghcide will via configuration in hie.yaml.
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname "$0")/..
|
||||
|
||||
root="$(pwd)"
|
||||
ghc_version="$(ghc --numeric-version)"
|
||||
|
||||
if [ "$1" == "--builddir" ]; then
|
||||
repl_builddir="$2"
|
||||
shift 2
|
||||
else
|
||||
repl_builddir=dist-newstyle
|
||||
fi
|
||||
|
||||
echo "-O0"
|
||||
echo "-ignore-dot-ghci"
|
||||
|
||||
echo "-outputdir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
|
||||
echo "-odir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
|
||||
echo "-hidir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
|
||||
echo "-stubdir $repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build"
|
||||
|
||||
echo "-i$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen"
|
||||
|
||||
echo "-I$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen"
|
||||
|
||||
echo "-i$root/semantic-analysis/src"
|
||||
echo "-i$root/semantic-ast/src"
|
||||
echo "-i$root/semantic-core/src"
|
||||
echo "-i$root/semantic-java/src"
|
||||
echo "-i$root/semantic-json/src"
|
||||
echo "-i$root/semantic-python/src"
|
||||
echo "-i$root/semantic-tags/src"
|
||||
echo "-i$root/app"
|
||||
echo "-i$root/src"
|
||||
echo "-i$root/bench"
|
||||
echo "-i$root/test"
|
||||
|
||||
echo "-optP-include"
|
||||
echo "-optP$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h"
|
||||
|
||||
echo "-hide-all-packages"
|
||||
|
||||
# Emit package flags from the environment file, removing comments & prefixing with -
|
||||
cabal exec --builddir=$repl_builddir -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/'
|
||||
|
||||
echo "-XHaskell2010"
|
||||
echo "-XStrictData"
|
||||
|
||||
echo "-Wwarn"
|
||||
|
||||
echo "-Weverything"
|
||||
echo "-Wno-all-missed-specialisations"
|
||||
echo "-Wno-implicit-prelude"
|
||||
echo "-Wno-missed-specialisations"
|
||||
echo "-Wno-missing-import-lists"
|
||||
echo "-Wno-missing-local-signatures"
|
||||
echo "-Wno-monomorphism-restriction"
|
||||
echo "-Wno-name-shadowing"
|
||||
echo "-Wno-safe"
|
||||
echo "-Wno-unsafe"
|
||||
echo "-Wno-star-is-type"
|
17
script/ghci-flags-dependencies
Executable file
17
script/ghci-flags-dependencies
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Computes the paths to files causing changes to the ghci flags. You probably won’t be running this yourself, but rather ghcide will via configuration in hie.yaml.
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname "$0")/..
|
||||
|
||||
echo "cabal.project"
|
||||
|
||||
echo "semantic.cabal"
|
||||
echo "semantic-analysis/semantic-analysis.cabal"
|
||||
echo "semantic-ast/semantic-ast.cabal"
|
||||
echo "semantic-core/semantic-core.cabal"
|
||||
echo "semantic-java/semantic-java.cabal"
|
||||
echo "semantic-json/semantic-json.cabal"
|
||||
echo "semantic-python/semantic-python.cabal"
|
||||
echo "semantic-tags/semantic-tags.cabal"
|
@ -6,21 +6,32 @@
|
||||
set -e
|
||||
cd $(dirname "$0")/..
|
||||
|
||||
VERSION="0.8.0.0"
|
||||
VERSION="0.9.0.0"
|
||||
BUILD_SHA=$(git rev-parse HEAD 2>/dev/null)
|
||||
DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic
|
||||
|
||||
# Set the version to the current commit sha
|
||||
SED_ARGS="-i"
|
||||
if [[ "$(uname -s)" = "Darwin" ]]; then
|
||||
SED_ARGS="$SED_ARGS .bak"
|
||||
fi
|
||||
sed $SED_ARGS "s/buildSHA =.*/buildSHA = \"$BUILD_SHA\"/" src/Semantic/Version.hs
|
||||
|
||||
# Build
|
||||
docker build -t $DOCKER_IMAGE .
|
||||
|
||||
# Make sure semantic is in the image.
|
||||
docker run --rm $DOCKER_IMAGE --version
|
||||
|
||||
# Requires that you've logged in to the GPR (e.g. `docker login docker.pkg.github.com`)
|
||||
# https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$VERSION
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:sha_$BUILD_SHA
|
||||
docker push $DOCKER_IMAGE:sha_$BUILD_SHA
|
||||
docker push $DOCKER_IMAGE:$VERSION
|
||||
docker push $DOCKER_IMAGE:latest
|
||||
read -p "Do you want to publish to the GitHub Registry [y/n]? " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
# Requires that you've logged in to the GPR (e.g. `docker login docker.pkg.github.com`)
|
||||
# https://help.github.com/en/articles/configuring-docker-for-use-with-github-package-registry
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:latest
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:$VERSION
|
||||
docker tag $DOCKER_IMAGE $DOCKER_IMAGE:sha_$BUILD_SHA
|
||||
docker push $DOCKER_IMAGE:sha_$BUILD_SHA
|
||||
docker push $DOCKER_IMAGE:$VERSION
|
||||
docker push $DOCKER_IMAGE:latest
|
||||
fi
|
||||
|
@ -11,5 +11,5 @@ repl_builddir=dist-repl
|
||||
if [[ ! -d $repl_builddir ]]; then
|
||||
echo "$repl_builddir does not exist, first run 'cabal repl --builddir=$repl_builddir', exit, and then re-run $0"
|
||||
else
|
||||
cabal exec --builddir=$repl_builddir ghci -- -ghci-script=.ghci.semantic $@
|
||||
cabal exec --builddir=$repl_builddir ghci -- -ghci-script=.ghci.semantic $(script/ghci-flags --builddir "$repl_builddir") -no-ignore-dot-ghci $@
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
cabal-version: 2.4
|
||||
|
||||
name: semantic
|
||||
version: 0.8.0.0
|
||||
version: 0.9.0.0
|
||||
synopsis: Framework and executable for analyzing and diffing untrusted code.
|
||||
description: Semantic is a library for parsing, analyzing, and comparing source code across many languages.
|
||||
homepage: http://github.com/github/semantic#readme
|
||||
@ -303,15 +303,11 @@ library
|
||||
, tree-sitter-ruby ^>= 0.2
|
||||
, tree-sitter-typescript ^>= 0.2.1
|
||||
, tree-sitter-tsx ^>= 0.2.1
|
||||
if flag(release)
|
||||
cpp-options: -DCOMPUTE_GIT_SHA
|
||||
|
||||
executable semantic
|
||||
import: haskell, dependencies, executable-flags
|
||||
hs-source-dirs: app
|
||||
main-is: Main.hs
|
||||
if flag(release)
|
||||
cpp-options: -DCOMPUTE_GIT_SHA
|
||||
build-depends: base
|
||||
, semantic
|
||||
|
||||
|
@ -1,28 +1,16 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
{-# OPTIONS_GHC -fforce-recomp #-} -- So that gitHash is correct.
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
#endif
|
||||
module Semantic.Version
|
||||
( buildSHA
|
||||
, buildVersion
|
||||
) where
|
||||
|
||||
import Data.Version (showVersion)
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
import Development.GitRev
|
||||
#endif
|
||||
import Paths_semantic (version)
|
||||
|
||||
-- The SHA1 hash of this build of semantic.
|
||||
-- If compiled as a development build, this will be @<development>@.
|
||||
buildSHA :: String
|
||||
#ifdef COMPUTE_GIT_SHA
|
||||
buildSHA = $(gitHash)
|
||||
#else
|
||||
buildSHA = "<development>"
|
||||
#endif
|
||||
|
||||
-- The version string of this build of semantic.
|
||||
buildVersion :: String
|
||||
buildVersion = showVersion version
|
||||
|
||||
-- The SHA1 hash of this build of semantic.
|
||||
-- If compiled as a development build, this will be @<development>@.
|
||||
buildSHA :: String
|
||||
buildSHA = "<development>"
|
||||
|
Loading…
Reference in New Issue
Block a user