Skip to content

Commit

Permalink
Bring in a Shakefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfine committed Jul 29, 2017
1 parent 01ca96b commit 5393e58
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 30 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Expand Up @@ -71,7 +71,5 @@ RELEASE-VERSION

# Haskell
.stack-work/
.cabal-sandbox/
cabal.sandbox.config
dist/
.build/

1 change: 0 additions & 1 deletion generator/sbpg/generator.py
Expand Up @@ -132,7 +132,6 @@ def main():
c.render_version(output_dir, args.release[0])
elif args.haskell:
parsed = [yaml.parse_spec(spec) for spec in file_index.values()]
hs.render_cabal(output_dir, parsed, args.release[0])
hs.render_sbp(output_dir, parsed)
elif args.java:
parsed = [yaml.parse_spec(spec) for spec in file_index.values()]
Expand Down
17 changes: 0 additions & 17 deletions generator/sbpg/targets/haskell.py
Expand Up @@ -18,7 +18,6 @@
from sbpg.targets.templating import *

MESSAGES_TEMPLATE_NAME = "SbpMessagesTemplate.hs"
CABAL_TEMPLATE_NAME = "sbp-template.cabal"
SBP_TEMPLATE_NAME = "SbpTemplate.hs"
MESSAGE_TEMPLATE_NAME = "SbpMessageTemplate.hs"

Expand Down Expand Up @@ -176,22 +175,6 @@ def render_source(output_dir, package_spec):
module_name=full_module_name,
module_includes=module_includes))

def render_cabal(output_dir, package_specs, release):
modules = []
module_prefix = "SwiftNav.SBP"
for package_spec in package_specs:
if not package_spec.render_source:
continue
path, name = package_spec.filepath
module_name = camel_case(name)
full_module_name = ".".join([module_prefix, module_name])
modules.append(full_module_name)
destination_filename = "%s/sbp.cabal" % output_dir
py_template = JENV.get_template(CABAL_TEMPLATE_NAME)
with open(destination_filename, 'w') as f:
f.write(py_template.render(modules=sorted(modules),
release=release))

def render_sbp(output_dir, package_specs):
modules = []
msgs = []
Expand Down
45 changes: 45 additions & 0 deletions haskell/Shakefile.hs
@@ -0,0 +1,45 @@
#!/usr/bin/env stack
{- stack
runghc
--package shakers
-}

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Shake makefile for project.
--
import Development.Shakers

-- | Main entry point.
--
main :: IO ()
main = shakeMain $ do
let pats =
[ "stack*.yaml"
, "Shakefile.hs"
, "main//*.hs"
, "src//*.hs"
]
pats' = delete "stack*.yaml" pats

-- | Haskell rules.
--
hsRules "." pats'

-- | Cabal rules.
--
cabalRules "." "sbp.cabal"

-- | Stack rules.
--
stackRules "." pats

-- | sanity
--
fake "." pats "sanity" $ const $
need [ "tests-error", "lint" ]

-- | Default things to run.
--
want [ "sanity", "format" ]
125 changes: 125 additions & 0 deletions haskell/sbp.cabal.m4
@@ -0,0 +1,125 @@
name: sbp
version: VERSION
synopsis: SwiftNav's SBP Library
homepage: https://github.com/swift-nav/libsbp
license: LGPL-3
author: Swift Navigation Inc.
maintainer: Mark Fine <dev@swiftnav.com>
copyright: Copyright (C) 2015 Swift Navigation, Inc.
category: Network
build-type: Simple
cabal-version: >= 1.22
extra-source-files: README.md
description:
Haskell bindings for Swift Navigation Binary Protocol (SBP), a fast,
simple, and minimal binary protocol for communicating with Swift
devices. It is the native binary protocol used by the Piksi GPS
receiver to transmit solutions, observations, status and debugging
messages, as well as receive messages from the host operating
system, such as differential corrections and the almanac.

source-repository head
type: git
location: git@github.com:swift-nav/libsbp.git

library
exposed-modules: SwiftNav.CRC16
, SwiftNav.SBP
other-modules: SwiftNav.SBP.Msg
, SwiftNav.SBP.TH
, SwiftNav.SBP.Types
, SwiftNav.SBP.Acquisition
, SwiftNav.SBP.Bootload
, SwiftNav.SBP.ExtEvents
, SwiftNav.SBP.FileIo
, SwiftNav.SBP.Flash
, SwiftNav.SBP.Gnss
, SwiftNav.SBP.Imu
, SwiftNav.SBP.Logging
, SwiftNav.SBP.Navigation
, SwiftNav.SBP.Ndb
, SwiftNav.SBP.Observation
, SwiftNav.SBP.Piksi
, SwiftNav.SBP.Settings
, SwiftNav.SBP.System
, SwiftNav.SBP.Tracking
, SwiftNav.SBP.User
default-language: Haskell2010
hs-source-dirs: src
ghc-options: -Wall
build-depends: aeson
, array
, base >= 4.8 && < 5
, base64-bytestring
, basic-prelude
, binary
, bytestring
, data-binary-ieee754
, lens
, lens-aeson
, monad-loops
, template-haskell
, text
, unordered-containers

executable sbp2json
hs-source-dirs: main
main-is: SBP2JSON.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends: aeson
, base
, basic-prelude
, binary-conduit
, bytestring
, conduit
, conduit-extra
, resourcet
, sbp
default-language: Haskell2010

executable json2sbp
hs-source-dirs: main
main-is: JSON2SBP.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends: aeson
, base
, basic-prelude
, binary-conduit
, conduit
, conduit-extra
, resourcet
, sbp
default-language: Haskell2010

executable sbp2yaml
hs-source-dirs: main
main-is: SBP2YAML.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends: base
, basic-prelude
, binary-conduit
, bytestring
, conduit
, conduit-extra
, resourcet
, sbp
, yaml
default-language: Haskell2010

test-suite test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Test.hs
other-modules: Test.SwiftNav.CRC16
build-depends: aeson
, base
, base64-bytestring
, basic-prelude
, bytestring
, QuickCheck
, sbp
, tasty
, tasty-hunit
, tasty-quickcheck
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
default-language: Haskell2010
5 changes: 1 addition & 4 deletions haskell/stack-lts-6.yaml
@@ -1,6 +1,3 @@
resolver: lts-6.35
flags: {}
packages:
- '.'
extra-deps: []
pvp-bounds: lower
- .
7 changes: 2 additions & 5 deletions haskell/stack-lts-8.yaml
@@ -1,6 +1,3 @@
resolver: lts-8.23
flags: {}
resolver: lts-8.24
packages:
- '.'
extra-deps: []
pvp-bounds: lower
- .

0 comments on commit 5393e58

Please sign in to comment.