From 4a1de42deba5340388a9caa779cb71b71f67cb91 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Thu, 4 Jun 2020 09:26:11 -0700 Subject: [PATCH] Move code generated from protos into separate package --- cabal.project | 5 +- script/protoc | 4 +- semantic-proto/LICENSE | 21 ++++++++ semantic-proto/README.md | 18 +++++++ semantic-proto/Setup.hs | 2 + semantic-proto/semantic-proto.cabal | 48 +++++++++++++++++++ {src => semantic-proto/src}/Proto/Semantic.hs | 0 .../src}/Proto/Semantic_Fields.hs | 0 .../src}/Proto/Semantic_JSON.hs | 0 semantic.cabal | 7 +-- 10 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 semantic-proto/LICENSE create mode 100644 semantic-proto/README.md create mode 100644 semantic-proto/Setup.hs create mode 100644 semantic-proto/semantic-proto.cabal rename {src => semantic-proto/src}/Proto/Semantic.hs (100%) rename {src => semantic-proto/src}/Proto/Semantic_Fields.hs (100%) rename {src => semantic-proto/src}/Proto/Semantic_JSON.hs (100%) diff --git a/cabal.project b/cabal.project index 5486ef3e6..488bc9754 100644 --- a/cabal.project +++ b/cabal.project @@ -11,13 +11,14 @@ packages: . semantic-json semantic-parse semantic-php + semantic-proto semantic-python semantic-ruby + semantic-rust semantic-scope-graph + semantic-tags semantic-tsx semantic-typescript - semantic-tags - semantic-rust -- Packages brought in from other repos instead of hackage -- ATTENTION: remember to update cabal.project.ci when bumping SHAs here! diff --git a/script/protoc b/script/protoc index 4498be504..4c0273402 100755 --- a/script/protoc +++ b/script/protoc @@ -16,6 +16,6 @@ export PROJECT="github.com/github/semantic" # Dockerfile for where the protoc pluggins are configured. docker run --rm --user $(id -u):$(id -g) -v $(pwd):/go/src/$PROJECT -w /go/src/$PROJECT \ semantic-protoc --proto_path=proto \ - --haskell_out=./src \ - --jsonpb_haskell_out=./src \ + --haskell_out=./semantic-proto/src \ + --jsonpb_haskell_out=./semantic-proto/src \ semantic.proto diff --git a/semantic-proto/LICENSE b/semantic-proto/LICENSE new file mode 100644 index 000000000..331b241b3 --- /dev/null +++ b/semantic-proto/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/semantic-proto/README.md b/semantic-proto/README.md new file mode 100644 index 000000000..dfc57df12 --- /dev/null +++ b/semantic-proto/README.md @@ -0,0 +1,18 @@ +# semantic-proto + +Datatypes generated from the protobuf schema + + +## Development + +This project consists of a Haskell package named `semantic-proto`. The library’s sources are in [`src`][]. + +Development of `semantic-proto` is typically done using `cabal v2-build`: + +```shell +cabal v2-build # build the library +cabal v2-repl # load the package into ghci +cabal v2-test # build and run the doctests +``` + +[`src`]: https://github.com/github/semantic/tree/master/semantic-proto/src diff --git a/semantic-proto/Setup.hs b/semantic-proto/Setup.hs new file mode 100644 index 000000000..9a994af67 --- /dev/null +++ b/semantic-proto/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/semantic-proto/semantic-proto.cabal b/semantic-proto/semantic-proto.cabal new file mode 100644 index 000000000..8763bc23a --- /dev/null +++ b/semantic-proto/semantic-proto.cabal @@ -0,0 +1,48 @@ +cabal-version: 2.4 + +name: semantic-proto +version: 0.0.0.0 +synopsis: Datatypes generated from protobuf schema +description: Datatypes generated from protobuf schema +homepage: https://github.com/github/semantic/tree/master/semantic-proto#readme +bug-reports: https://github.com/github/semantic/issues +license: MIT +license-file: LICENSE +author: The Semantic authors +maintainer: opensource+semantic@github.com +copyright: (c) 2019 GitHub, Inc. +category: Language +build-type: Simple +stability: alpha +extra-source-files: README.md + +tested-with: GHC == 8.6.5 + +library + exposed-modules: + Proto.Semantic + , Proto.Semantic_Fields + , Proto.Semantic_JSON + build-depends: + base >= 4.13 && < 5 + , aeson ^>= 1.4.2.0 + , text ^>= 1.2.3.1 + , proto-lens >= 0.5 && < 0.7 + , proto-lens-jsonpb + , proto-lens-runtime >= 0.5 && <0.7 + hs-source-dirs: src + default-language: Haskell2010 + ghc-options: + -Weverything + -Wno-missing-local-signatures + -Wno-missing-import-lists + -Wno-implicit-prelude + -Wno-safe + -Wno-unsafe + -Wno-name-shadowing + -Wno-monomorphism-restriction + -Wno-missed-specialisations + -Wno-all-missed-specialisations + -Wno-star-is-type + if (impl(ghc >= 8.8)) + ghc-options: -Wno-missing-deriving-strategies diff --git a/src/Proto/Semantic.hs b/semantic-proto/src/Proto/Semantic.hs similarity index 100% rename from src/Proto/Semantic.hs rename to semantic-proto/src/Proto/Semantic.hs diff --git a/src/Proto/Semantic_Fields.hs b/semantic-proto/src/Proto/Semantic_Fields.hs similarity index 100% rename from src/Proto/Semantic_Fields.hs rename to semantic-proto/src/Proto/Semantic_Fields.hs diff --git a/src/Proto/Semantic_JSON.hs b/semantic-proto/src/Proto/Semantic_JSON.hs similarity index 100% rename from src/Proto/Semantic_JSON.hs rename to semantic-proto/src/Proto/Semantic_JSON.hs diff --git a/semantic.cabal b/semantic.cabal index fc21d2368..b88729486 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -214,9 +214,6 @@ library -- High-level flow & operational functionality (logging, stats, etc.) , Semantic.Analysis -- API - , Proto.Semantic - , Proto.Semantic_Fields - , Proto.Semantic_JSON , Semantic.Api , Semantic.Api.Bridge , Semantic.Api.Diffs @@ -274,8 +271,6 @@ library , pretty-show ^>= 1.9.5 , profunctors ^>= 5.3 , proto-lens >= 0.5 && < 0.7 - , proto-lens-jsonpb - , proto-lens-runtime >= 0.5 && <0.7 , reducers ^>= 3.12.3 , semantic-go ^>= 0 , semantic-java ^>= 0 @@ -284,6 +279,7 @@ library , semantic-python ^>= 0 , semantic-codeql ^>= 0 , semantic-ruby ^>= 0 + , semantic-proto ^>= 0 , semantic-scope-graph ^>= 0 , semantic-tags ^>= 0 , semantic-tsx ^>= 0 @@ -381,6 +377,7 @@ test-suite parse-examples , foldl ^>= 1.4.5 , lens >= 4.17 && < 4.19 , resourcet ^>= 1.2 + , semantic-proto ^>= 0 , streaming , streaming-bytestring ^>= 0.1.6 , tasty