From 65c42cb3220b20c91ef4e346a885705f7151dadd Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Wed, 30 Oct 2019 10:56:52 -0400 Subject: [PATCH 01/26] Bump version to 0.9.0.0. --- script/publish | 2 +- semantic.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/publish b/script/publish index 63d1c6c28..e2bfe0b2e 100755 --- a/script/publish +++ b/script/publish @@ -6,7 +6,7 @@ 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 diff --git a/semantic.cabal b/semantic.cabal index 57a6efdc0..68686c085 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -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 From 4e17878d01010e2537e618d101d1770c12d5fd70 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 10:32:24 -0400 Subject: [PATCH 02/26] Stub in a script to return the flags for ghci. --- script/ghci-flags | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 script/ghci-flags diff --git a/script/ghci-flags b/script/ghci-flags new file mode 100755 index 000000000..51a80d953 --- /dev/null +++ b/script/ghci-flags @@ -0,0 +1,2 @@ +#!/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. From 35270bedde600fdb0276b688706cbaa9d3001566 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:01:17 -0400 Subject: [PATCH 03/26] Gather all the flags. --- script/ghci-flags | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/script/ghci-flags b/script/ghci-flags index 51a80d953..f66c92434 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -1,2 +1,49 @@ #!/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)" + +echo "--interactive" + +echo "-O0" +echo "-ignore-dot-ghci" + +echo "-i$root/dist-newstyle/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen" + +echo "-I$root/dist-newstyle/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/src" +echo "-i$root/bench" +echo "-i$root/test" + +echo "-optP-include" +echo "-optP$root/dist-newstyle/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h" + +# Emit package flags from the environment file, removing comments & prefixing with - +cabal exec -v0 bash -- -c 'cat $GHC_ENVIRONMENT | grep -v "^--" | sed -e "s/^/-/"' + +echo "-XHaskell2010" + +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" From ddff669740967ba854d4b7705c5dd025df295b66 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:02:44 -0400 Subject: [PATCH 04/26] Run the rest of it out of the cabal exec. --- script/ghci-flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/ghci-flags b/script/ghci-flags index f66c92434..a99d20aa6 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -32,7 +32,7 @@ echo "-optP-include" echo "-optP$root/dist-newstyle/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h" # Emit package flags from the environment file, removing comments & prefixing with - -cabal exec -v0 bash -- -c 'cat $GHC_ENVIRONMENT | grep -v "^--" | sed -e "s/^/-/"' +cabal exec -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/' echo "-XHaskell2010" From b2c8fd92dac2cd2ea263b77fa87f8f51dc5b0e9d Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:05:06 -0400 Subject: [PATCH 05/26] =?UTF-8?q?Don=E2=80=99t=20pass=20--interactive.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/ghci-flags | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/ghci-flags b/script/ghci-flags index a99d20aa6..96fffc428 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -8,8 +8,6 @@ cd $(dirname "$0")/.. root="$(pwd)" ghc_version="$(ghc --numeric-version)" -echo "--interactive" - echo "-O0" echo "-ignore-dot-ghci" From 63f9cdb0e7817a1b68f3f23e65954368bcf50f4a Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:12:03 -0400 Subject: [PATCH 06/26] Un-ignore hie.yaml. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index adba49752..50685cf3e 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,6 @@ tmp/ *.hp *.prof *.pyc -/hie.yaml /test.* /*.html From 1e0ec647312ca94cb560fca3783b6d27e858bf83 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:12:10 -0400 Subject: [PATCH 07/26] Add a hie.yaml using the ghci flags script. --- hie.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 hie.yaml diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 000000000..473bc3fc7 --- /dev/null +++ b/hie.yaml @@ -0,0 +1,3 @@ +cradle: + bios: + program: script/ghci-flags From 547617a3b9ff9c42aa5c2a8f20a98bf56e677295 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:16:30 -0400 Subject: [PATCH 08/26] Add a script to compute the files to watch for changes to the packages. --- script/ghci-flags-dependencies | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 script/ghci-flags-dependencies diff --git a/script/ghci-flags-dependencies b/script/ghci-flags-dependencies new file mode 100755 index 000000000..5581fbee2 --- /dev/null +++ b/script/ghci-flags-dependencies @@ -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" From 25419556349cdd2438a0508624c64057769263b6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:16:45 -0400 Subject: [PATCH 09/26] Tell hie-bios about the dependencies. --- hie.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/hie.yaml b/hie.yaml index 473bc3fc7..70b952c81 100644 --- a/hie.yaml +++ b/hie.yaml @@ -1,3 +1,4 @@ cradle: bios: program: script/ghci-flags + dependency-program: script/ghci-flags-dependencies From 3f69e09314f8728580ef0c000693b65e47c08c74 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:35:07 -0400 Subject: [PATCH 10/26] Enable strict data, in case it ever matters. --- script/ghci-flags | 1 + 1 file changed, 1 insertion(+) diff --git a/script/ghci-flags b/script/ghci-flags index 96fffc428..669f49593 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -33,6 +33,7 @@ echo "-optP$root/dist-newstyle/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0. cabal exec -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/' echo "-XHaskell2010" +echo "-XStrictData" echo "-Weverything" echo "-Wno-all-missed-specialisations" From 90bf61dede7abc516a8b164681942e4a2429c49f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:35:35 -0400 Subject: [PATCH 11/26] Warnings are warnings. --- script/ghci-flags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/ghci-flags b/script/ghci-flags index 669f49593..70cebf370 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -35,6 +35,8 @@ cabal exec -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" From c9cbc83ae3da82d0d1a56a14733458c71e0484c7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:38:41 -0400 Subject: [PATCH 12/26] =?UTF-8?q?Don=E2=80=99t=20forget=20app.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/ghci-flags | 1 + 1 file changed, 1 insertion(+) diff --git a/script/ghci-flags b/script/ghci-flags index 70cebf370..b25fba4d1 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -22,6 +22,7 @@ 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" From e6fc10b293d845021a336a8ca71090609ef26561 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:50:45 -0400 Subject: [PATCH 13/26] Work relative to a builddir. --- script/ghci-flags | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/script/ghci-flags b/script/ghci-flags index b25fba4d1..edaa09e4b 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -8,12 +8,19 @@ 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 "-i$root/dist-newstyle/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/dist-newstyle/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" @@ -28,10 +35,10 @@ echo "-i$root/bench" echo "-i$root/test" echo "-optP-include" -echo "-optP$root/dist-newstyle/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h" +echo "-optP$root/$repl_builddir/build/x86_64-osx/ghc-$ghc_version/semantic-0.8.0.0/build/autogen/cabal_macros.h" # Emit package flags from the environment file, removing comments & prefixing with - -cabal exec -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/' +cabal exec --builddir=$repl_builddir -v0 bash -- -c 'cat $GHC_ENVIRONMENT' | grep -v '^--' | sed -e 's/^/-/' echo "-XHaskell2010" echo "-XStrictData" From fbe02dab6438ca3d2781b2688c6ffff58000c4ff Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:50:51 -0400 Subject: [PATCH 14/26] Echo any remaining args. --- script/ghci-flags | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/ghci-flags b/script/ghci-flags index edaa09e4b..dcd8dae31 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -56,3 +56,7 @@ echo "-Wno-name-shadowing" echo "-Wno-safe" echo "-Wno-unsafe" echo "-Wno-star-is-type" + +for arg in "$@"; do + echo "$arg" +done From 978beb7a11c93917d009873f94759c1749123638 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:52:32 -0400 Subject: [PATCH 15/26] Revert "Echo any remaining args." This reverts commit fbe02dab6438ca3d2781b2688c6ffff58000c4ff. --- script/ghci-flags | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/ghci-flags b/script/ghci-flags index dcd8dae31..edaa09e4b 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -56,7 +56,3 @@ echo "-Wno-name-shadowing" echo "-Wno-safe" echo "-Wno-unsafe" echo "-Wno-star-is-type" - -for arg in "$@"; do - echo "$arg" -done From 09568bdbd5cb7415a5c37f24d4735fba5deeb0df Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:59:04 -0400 Subject: [PATCH 16/26] Use script/ghci-flags from script/repl. --- .ghci.semantic | 39 --------------------------------------- script/repl | 2 +- 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/.ghci.semantic b/.ghci.semantic index e34f0a0d5..dfa2827c4 100644 --- a/.ghci.semantic +++ b/.ghci.semantic @@ -5,9 +5,6 @@ -- Basic verbosity :set -v1 --- No optimizations -:set -O0 - -- Compile to object code :set -fwrite-interface -fobject-code @@ -17,45 +14,9 @@ :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 diff --git a/script/repl b/script/repl index e3b153a57..f8cc8754b 100755 --- a/script/repl +++ b/script/repl @@ -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") $@ fi From 88545759fc258838b90a40ffbddc6159e0018ff7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:59:30 -0400 Subject: [PATCH 17/26] =?UTF-8?q?Don=E2=80=99t=20ignore=20.ghci=20when=20u?= =?UTF-8?q?sing=20script/repl.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/repl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/repl b/script/repl index f8cc8754b..60ed3bc0e 100755 --- a/script/repl +++ b/script/repl @@ -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 $(script/ghci-flags --builddir "$repl_builddir") $@ + cabal exec --builddir=$repl_builddir ghci -- -ghci-script=.ghci.semantic $(script/ghci-flags --builddir "$repl_builddir") -no-ignore-dot-ghci $@ fi From 9a212db6230daa96eae3360646165de03ff7d2f3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 11:59:44 -0400 Subject: [PATCH 18/26] =?UTF-8?q?Note=20why=20the=20remaining=20flags=20ar?= =?UTF-8?q?en=E2=80=99t=20in=20script/ghci-flags.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ghci.semantic | 1 + 1 file changed, 1 insertion(+) diff --git a/.ghci.semantic b/.ghci.semantic index dfa2827c4..b0865a4db 100644 --- a/.ghci.semantic +++ b/.ghci.semantic @@ -1,6 +1,7 @@ -- 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 From d41961f193993ab34247133e3dc0a71d4b5dcb63 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 12:01:14 -0400 Subject: [PATCH 19/26] Move the build products dirs into script/ghci-flags. --- .ghci.semantic | 6 ------ script/ghci-flags | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.ghci.semantic b/.ghci.semantic index b0865a4db..bd2c752dd 100644 --- a/.ghci.semantic +++ b/.ghci.semantic @@ -9,12 +9,6 @@ -- 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 - -- Bonus: silence “add these modules to your .cabal file” warnings for files we :load :set -Wno-missing-home-modules diff --git a/script/ghci-flags b/script/ghci-flags index edaa09e4b..b2be45335 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -18,6 +18,11 @@ fi echo "-O0" echo "-ignore-dot-ghci" +echo "-outputdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-odir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-hidir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-stubdir dist-repl/build/x86_64-osx/ghc-8.6.5/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" From 8ef9e1434e87a80c2b960b6b7e3534b29a2c30af Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 12:01:42 -0400 Subject: [PATCH 20/26] Make the output dirs relative to the builddir. --- script/ghci-flags | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/ghci-flags b/script/ghci-flags index b2be45335..d7ee47a9c 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -18,10 +18,10 @@ fi echo "-O0" echo "-ignore-dot-ghci" -echo "-outputdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-odir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-hidir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-stubdir dist-repl/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-outputdir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-odir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-hidir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +echo "-stubdir $repl_builddir/build/x86_64-osx/ghc-8.6.5/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" From 110b1b69e812a71d23de1074a378fbcec3a6f6b4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 12:02:12 -0400 Subject: [PATCH 21/26] Make the output dirs relative to the ghc version. --- script/ghci-flags | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/ghci-flags b/script/ghci-flags index d7ee47a9c..164b6bce6 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -18,10 +18,10 @@ fi echo "-O0" echo "-ignore-dot-ghci" -echo "-outputdir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-odir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-hidir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" -echo "-stubdir $repl_builddir/build/x86_64-osx/ghc-8.6.5/semantic-0.8.0.0/build" +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" From 7662ee75f128ca190b1b94d03f20d54e4d57a6f3 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 1 Nov 2019 13:44:57 -0400 Subject: [PATCH 22/26] Take care not to load semantic-source twice. --- script/ghci-flags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/ghci-flags b/script/ghci-flags index 164b6bce6..6e3686fa0 100755 --- a/script/ghci-flags +++ b/script/ghci-flags @@ -42,6 +42,8 @@ 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/^/-/' From 52d021bcd69620d2c5f02beb481ad6a1a38f2cf1 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 1 Nov 2019 14:40:07 -0400 Subject: [PATCH 23/26] First attempt. --- Dockerfile | 1 + script/publish | 2 +- semantic.cabal | 4 ---- src/Semantic/Version.hs | 6 ++++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index adc3af597..3bc4f2bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,7 @@ COPY semantic-source semantic-source/ COPY semantic-tags semantic-tags/ COPY cabal.project . RUN cabal v2-update && \ + cabal configure --ghc-options="-D$GIT_COMMIT" cabal v2-build --flags="release" --only-dependencies # Build all of semantic diff --git a/script/publish b/script/publish index 63d1c6c28..bbb6a2590 100755 --- a/script/publish +++ b/script/publish @@ -11,7 +11,7 @@ BUILD_SHA=$(git rev-parse HEAD 2>/dev/null) DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic # Build -docker build -t $DOCKER_IMAGE . +docker build -t $DOCKER_IMAGE --build-arg BUILD_SHA=$BUILD_SHA. # Make sure semantic is in the image. docker run --rm $DOCKER_IMAGE --version diff --git a/semantic.cabal b/semantic.cabal index 0a843d020..725dd2e61 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -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 diff --git a/src/Semantic/Version.hs b/src/Semantic/Version.hs index 6a71f534f..3174453f4 100644 --- a/src/Semantic/Version.hs +++ b/src/Semantic/Version.hs @@ -17,10 +17,12 @@ import Paths_semantic (version) -- The SHA1 hash of this build of semantic. -- If compiled as a development build, this will be @@. buildSHA :: String -#ifdef COMPUTE_GIT_SHA +#if defined(GIT_COMMIT) +buildSHA = "GIT_COMMIT" +#elif defined(COMPUTE_GIT_SHA) buildSHA = $(gitHash) #else -buildSHA = "" +buildSHA = "unspecified" #endif -- The version string of this build of semantic. From f0956624a0149a81548b3af5737996c6fa7cd5ac Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Mon, 4 Nov 2019 14:33:57 -0500 Subject: [PATCH 24/26] closer --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3bc4f2bd8..b25450e77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,14 +31,17 @@ COPY semantic-json semantic-json/ COPY semantic-python semantic-python/ COPY semantic-source semantic-source/ COPY semantic-tags semantic-tags/ +COPY semantic-ast semantic-ast/ COPY cabal.project . RUN cabal v2-update && \ - cabal configure --ghc-options="-D$GIT_COMMIT" - cabal v2-build --flags="release" --only-dependencies + cabal v2-configure --flags="release" --ghc-options="-D$GIT_COMMIT" +COPY cabal.project.local . +RUN cabal v2-build --only-dependencies + # Build all of semantic COPY . . -RUN cabal v2-build --flags="release" semantic:exe:semantic +RUN 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 From 1ab38e297a9e2f636bcc22ee85d3359191e06deb Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 6 Nov 2019 16:20:14 -0800 Subject: [PATCH 25/26] Try a different approach for embedding the git commit sha --- .dockerignore | 1 + .gitignore | 1 + Dockerfile | 21 +++------------------ script/publish | 3 ++- src/Semantic/Version.hs | 24 +++++------------------- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/.dockerignore b/.dockerignore index 619162c4f..bdb208923 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ Dockerfile /.licenses +/.git .ghc.environment.x86_64-darwin-8.6.5 /bin diff --git a/.gitignore b/.gitignore index 0a5922aab..47833ee4c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ dist-repl tmp/ /bin/ +/src/Semantic/Version.hs.bak /semanticd/test/current /semanticd/test/rover-example-config/semantic.log /test/fixtures/*/examples diff --git a/Dockerfile b/Dockerfile index b25450e77..8249fa34e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,26 +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-core semantic-core/ -COPY semantic-java semantic-java/ -COPY semantic-json semantic-json/ -COPY semantic-python semantic-python/ -COPY semantic-source semantic-source/ -COPY semantic-tags semantic-tags/ -COPY semantic-ast semantic-ast/ -COPY cabal.project . -RUN cabal v2-update && \ - cabal v2-configure --flags="release" --ghc-options="-D$GIT_COMMIT" -COPY cabal.project.local . -RUN cabal v2-build --only-dependencies - - # Build all of semantic COPY . . -RUN cabal v2-build 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 diff --git a/script/publish b/script/publish index bbb6a2590..9c6286062 100755 --- a/script/publish +++ b/script/publish @@ -11,7 +11,8 @@ BUILD_SHA=$(git rev-parse HEAD 2>/dev/null) DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic # Build -docker build -t $DOCKER_IMAGE --build-arg BUILD_SHA=$BUILD_SHA. +sed -i .bak "s/buildSHA =.*/buildSHA = \"$BUILD_SHA\"/" src/Semantic/Version.hs +docker build -t $DOCKER_IMAGE . # Make sure semantic is in the image. docker run --rm $DOCKER_IMAGE --version diff --git a/src/Semantic/Version.hs b/src/Semantic/Version.hs index 3174453f4..3a05699f2 100644 --- a/src/Semantic/Version.hs +++ b/src/Semantic/Version.hs @@ -1,30 +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 @@. -buildSHA :: String -#if defined(GIT_COMMIT) -buildSHA = "GIT_COMMIT" -#elif defined(COMPUTE_GIT_SHA) -buildSHA = $(gitHash) -#else -buildSHA = "unspecified" -#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 @@. +buildSHA :: String +buildSHA = "" From 8f4d405070d935c4b495130fcb57849696347889 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Thu, 7 Nov 2019 10:00:01 -0800 Subject: [PATCH 26/26] Various versions of sed and prompt before push --- script/publish | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/script/publish b/script/publish index 9c6286062..1058ac640 100755 --- a/script/publish +++ b/script/publish @@ -10,18 +10,28 @@ VERSION="0.8.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 -sed -i .bak "s/buildSHA =.*/buildSHA = \"$BUILD_SHA\"/" src/Semantic/Version.hs 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