Skip to content

Commit

Permalink
Merge pull request #104 from clash-lang/103-move-plugin-to-a-separate…
Browse files Browse the repository at this point in the history
…-package

Move plugin to a separate package
  • Loading branch information
t-wallet authored Aug 19, 2024
2 parents 623ecd9 + 8f1f169 commit e2f4da3
Show file tree
Hide file tree
Showing 55 changed files with 217 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -xeou pipefail

# Build dependencies first, so they don't end up in logs
cabal build \
cabal v2-build \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
Expand All @@ -12,7 +12,7 @@ cabal build \
# other GHC version it supports is 8.6.5, but this GHC bundles a Haddock that
# cannot generate documentation for clash-prelude. Hence, we build docs with
# 8.10 and relax circuit-notation's ghc bounds
cabal haddock \
cabal v2-haddock \
--constraint=clash-prelude==$clash_version \
--enable-documentation \
--allow-newer=circuit-notation:ghc \
Expand Down
8 changes: 4 additions & 4 deletions .ci/test_cabal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -xeou pipefail

cabal build all --constraint=clash-prelude==$clash_version -fci
cabal run unittests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal run doctests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal sdist
cabal v2-build all --constraint=clash-prelude==$clash_version -fci
cabal v2-run unittests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-run doctests --constraint=clash-prelude==$clash_version -fci --enable-tests
cabal v2-sdist clash-protocols
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2020, Martijn Bastiaan
2020, QBayLogic B.V.
Copyright (c) 2024, Martijn Bastiaan
2024, QBayLogic B.V.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
13 changes: 12 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
packages:
clash-protocols.cabal
./clash-protocols-base
./clash-protocols

tests: True

Expand All @@ -15,6 +16,16 @@ source-repository-package
location: https://github.com/cchalmers/circuit-notation.git
tag: 19b386c4aa3ff690758ae089c7754303f3500cc9

package clash-protocols-base
-- Reduces compile times by ~20%
ghc-options: +RTS -qn4 -A128M -RTS -j4

-- Workaround for Haddock/CPP #if issues https://github.com/haskell/haddock/issues/1382
haddock-options: --optghc="-optP -P"

-- Don't pollute docs with large tuple instances
haddock-options: --optghc=-DHADDOCK_ONLY

package clash-protocols
-- Reduces compile times by ~20%
ghc-options: +RTS -qn4 -A128M -RTS -j4
Expand Down
23 changes: 23 additions & 0 deletions clash-protocols-base/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2024, Martijn Bastiaan
2024, QBayLogic B.V.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 changes: 5 additions & 0 deletions clash-protocols-base/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Distribution.Simple
import Prelude

main :: IO ()
main = defaultMain
125 changes: 125 additions & 0 deletions clash-protocols-base/clash-protocols-base.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
cabal-version: 2.4
name: clash-protocols-base
synopsis: a battery-included library for (dataflow) protocols
Homepage: https://gitlab.com/martijnbastiaan/clash-protocols
version: 0.1
category: Hardware
license: BSD-2-Clause
license-file: LICENSE
author: Martijn Bastiaan, QBayLogic B.V.
maintainer: Martijn Bastiaan <[email protected]>

flag ci
Description: Running on CI? Used to set fail-on-warning flag.
Manual: True
Default: False

flag large-tuples
description:
Generate instances for classes such as `Units` and `TaggedBundle` for tuples
up to and including 62 elements - the GHC imposed maximum. Note that this
greatly increases compile times for `clash-protocols-base`.
default: False
manual: True

common common-options
default-extensions:
BangPatterns
BinaryLiterals
ConstraintKinds
CPP
DataKinds
DefaultSignatures
DeriveAnyClass
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingStrategies
InstanceSigs
KindSignatures
LambdaCase
NoStarIsType
PolyKinds
RankNTypes
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
TypeFamilies
TypeOperators
ViewPatterns

-- TemplateHaskell is used to support convenience functions such as
-- 'listToVecTH' and 'bLit'.
TemplateHaskell
QuasiQuotes

-- Prelude isn't imported by default as Clash offers Clash.Prelude
-- NoImplicitPrelude
ghc-options:
-Wall -Wcompat

-- Plugins to support type-level constraint solving on naturals
-fplugin GHC.TypeLits.Extra.Solver
-fplugin GHC.TypeLits.Normalise
-fplugin GHC.TypeLits.KnownNat.Solver

-- Clash needs access to the source code in compiled modules
-fexpose-all-unfoldings

-- Worker wrappers introduce unstable names for functions that might have
-- blackboxes attached for them. You can disable this, but be sure to add
-- a no-specialize pragma to every function with a blackbox.
-fno-worker-wrapper

if flag(ci)
ghc-options: -Werror

default-language: Haskell2010
build-depends:
base >= 4.15.0.0,
Cabal,

clash-prelude >= 1.8.1 && < 1.10,
ghc-typelits-natnormalise,
ghc-typelits-extra,
ghc-typelits-knownnat

custom-setup
setup-depends:
base >= 4.11 && <5,
Cabal >= 2.4,

library
import: common-options
hs-source-dirs: src

if flag(large-tuples)
CPP-Options: -DLARGE_TUPLES

build-depends:
, circuit-notation
, data-default
, deepseq
, extra
, ghc >= 8.7 && < 9.7
, hashable
, tagged
, template-haskell

exposed-modules:
Protocols.Cpp
Protocols.Internal
Protocols.Internal.Classes
Protocols.Internal.TaggedBundle
Protocols.Internal.TaggedBundle.TH
Protocols.Internal.TH
Protocols.Internal.Units
Protocols.Internal.Units.TH
Protocols.Plugin
Protocols.Plugin.Internal

default-language: Haskell2010
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module Protocols.Plugin (
import Prelude

-- clash-protocols
import Protocols
import Protocols.Internal
import Protocols.Internal.TaggedBundle
import Protocols.Internal.Units
import Protocols.Plugin.Internal

-- circuit-notation
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions clash-protocols/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2024, Martijn Bastiaan
2024, QBayLogic B.V.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.
39 changes: 4 additions & 35 deletions clash-protocols.cabal → clash-protocols/clash-protocols.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ common common-options

default-language: Haskell2010
build-depends:
-- GHC >= 9.0
base >= 4.15.0.0,
Cabal,

Expand All @@ -106,26 +105,6 @@ custom-setup
Cabal >= 2.4,
cabal-doctest >= 1.0.1 && <1.1

-- library inline-circuit-notation
-- visibility: private
-- hs-source-dirs: deps/circuit-notation/src
-- build-depends:
-- , base
-- , clash-prelude >= 1.0
-- , containers
-- , data-default
-- , ghc >=8.6
-- , syb
-- , lens
-- , mtl
-- , pretty
-- , parsec
-- , pretty-show
-- , template-haskell
-- exposed-modules:
-- CircuitNotation
-- default-language: Haskell2010

library
import: common-options
hs-source-dirs: src
Expand All @@ -134,7 +113,7 @@ library
CPP-Options: -DLARGE_TUPLES

build-depends:
-- inline-circuit-notation
, clash-protocols-base
, circuit-notation
, clash-prelude-hedgehog
, data-default
Expand Down Expand Up @@ -165,20 +144,11 @@ library
Protocols.Axi4.WriteAddress
Protocols.Axi4.WriteData
Protocols.Axi4.WriteResponse
Protocols.Cpp
Protocols.Df
Protocols.DfConv
Protocols.Hedgehog
Protocols.Hedgehog.Internal
Protocols.Idle
Protocols.Internal
Protocols.Internal.TaggedBundle
Protocols.Internal.TaggedBundle.TH
Protocols.Internal.TH
Protocols.Internal.Units
Protocols.Internal.Units.TH
Protocols.Plugin
Protocols.Plugin.Internal
Protocols.Wishbone
Protocols.Wishbone.Standard
Protocols.Wishbone.Standard.Hedgehog
Expand All @@ -190,9 +160,7 @@ library
autogen-modules: Paths_clash_protocols

other-modules:
Data.Bifunctor.Extra
Paths_clash_protocols
Protocols.Internal.Classes

default-language: Haskell2010

Expand All @@ -210,12 +178,12 @@ test-suite unittests
Tests.Protocols.Axi4
Tests.Protocols.Plugin
Tests.Protocols.Wishbone

Util

build-depends:
clash-protocols-base,
clash-protocols,
clash-prelude-hedgehog,
data-default,
unordered-containers,
deepseq,
extra,
Expand All @@ -236,6 +204,7 @@ test-suite doctests

build-depends:
base,
clash-protocols-base,
clash-protocols,
process,
doctest
1 change: 0 additions & 1 deletion src/Protocols.hs → clash-protocols/src/Protocols.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ module Protocols (
import Data.Default (def)
import Protocols.Df (Df)
import Protocols.Internal

import Protocols.Internal.TaggedBundle
import Protocols.Internal.Units
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
with nixpkgs.pkgs;
with gitignore;

haskellPackages.callCabal2nix "clash-protocols" (gitignoreSource ./.) {}
haskellPackages.callCabal2nix "clash-protocols" (gitignoreSource ./clash-protocols) {}
4 changes: 2 additions & 2 deletions format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [[ "$#" -eq 0 || "$1" == "-h" || "$1" == "--help" ]]; then
fi

exclude_files=(
"src/Protocols/Cpp.hs"
"clash-protocols-base/src/Protocols/Cpp.hs"
)

# Make sure it doesn't matter from where this script is executed
Expand All @@ -34,7 +34,7 @@ cd $DIR
if [ $1 == "diff" ] ; then
src_files=$(git diff --cached --name-only --diff-filter=ACMR -- '*.hs')
else
src_files=$(find Setup.hs src tests -type f -name "*.hs")
src_files=$(find clash-protocols-base/Setup.hs clash-protocols/Setup.hs clash-protocols-base/src clash-protocols/src clash-protocols/tests -type f -name "*.hs")
fi

src_files_str=$(printf "%s\n" "${src_files[@]}" | sed 's| |\\ |g')
Expand Down
Loading

0 comments on commit e2f4da3

Please sign in to comment.