Skip to content

Commit

Permalink
Merge pull request #355 from well-typed/rename-runtime
Browse files Browse the repository at this point in the history
Rename to `hs-bindgen-runtime`
  • Loading branch information
edsko authored Jan 9, 2025
2 parents 043f1a2 + cb54298 commit 69d1a02
Show file tree
Hide file tree
Showing 44 changed files with 77 additions and 110 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
- name: initial cabal.project for sdist
run: |
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/hs-bindgen-patterns" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/hs-bindgen-runtime" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/hs-bindgen" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/hs-bindgen-libclang" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/ansi-diff" >> cabal.project
Expand All @@ -165,8 +165,8 @@ jobs:
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
- name: generate cabal.project
run: |
PKGDIR_hs_bindgen_patterns="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hs-bindgen-patterns-[0-9.]*')"
echo "PKGDIR_hs_bindgen_patterns=${PKGDIR_hs_bindgen_patterns}" >> "$GITHUB_ENV"
PKGDIR_hs_bindgen_runtime="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hs-bindgen-runtime-[0-9.]*')"
echo "PKGDIR_hs_bindgen_runtime=${PKGDIR_hs_bindgen_runtime}" >> "$GITHUB_ENV"
PKGDIR_hs_bindgen="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hs-bindgen-[0-9.]*')"
echo "PKGDIR_hs_bindgen=${PKGDIR_hs_bindgen}" >> "$GITHUB_ENV"
PKGDIR_hs_bindgen_libclang="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hs-bindgen-libclang-[0-9.]*')"
Expand All @@ -176,11 +176,11 @@ jobs:
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_hs_bindgen_patterns}" >> cabal.project
echo "packages: ${PKGDIR_hs_bindgen_runtime}" >> cabal.project
echo "packages: ${PKGDIR_hs_bindgen}" >> cabal.project
echo "packages: ${PKGDIR_hs_bindgen_libclang}" >> cabal.project
echo "packages: ${PKGDIR_ansi_diff}" >> cabal.project
echo "package hs-bindgen-patterns" >> cabal.project
echo "package hs-bindgen-runtime" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
echo "package hs-bindgen" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
Expand All @@ -195,13 +195,13 @@ jobs:
package hs-bindgen-libclang
ghc-options: -Werror
package hs-bindgen-patterns
package hs-bindgen-runtime
ghc-options: -Werror
package ansi-diff
ghc-options: -Werror
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(ansi-diff|hs-bindgen|hs-bindgen-libclang|hs-bindgen-patterns)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(ansi-diff|hs-bindgen|hs-bindgen-libclang|hs-bindgen-runtime)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_hs_bindgen_patterns} || false
cd ${PKGDIR_hs_bindgen_runtime} || false
${CABAL} -vnormal check
cd ${PKGDIR_hs_bindgen} || false
${CABAL} -vnormal check
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ When hand-writing high-level bindings, there are undoubtedly a lot of patterns
that emerge. We should [capture these as Haskell functions or type
classes](https://github.com/well-typed/hs-bindgen/issues/27) and [release this
as a separate library
`hs-bindgen-patterns`](https://github.com/well-typed/hs-bindgen/issues/28).
`hs-bindgen-runtime`](https://github.com/well-typed/hs-bindgen/issues/28).

### [Milestone 3: High-level API](https://github.com/well-typed/hs-bindgen/milestone/4)

Even in the ideal case that _all_ patterns that are used in the construction
of the high-level bindings can be expressed using the patterns provided by the
`hs-bindgen-patterns` library from milestone 2.5, it might still be cumbersome
`hs-bindgen-runtime` library from milestone 2.5, it might still be cumbersome
to have to write them all out, and so some generation might still be useful.

This is all the more important for data type declarations (as opposed to
Expand All @@ -161,7 +161,7 @@ files themselves, or through using `hs-bindgen` as a library with customizations
as regular Haskell code. It is conceivable that in cases that would require
extensive customization, perhaps the most direct way to do that customization is
not to use generation at all, but simply write bindings manually, provided that
the `hs-bindgen-patterns` library provides sufficient support.
the `hs-bindgen-runtime` library provides sufficient support.

Nonetheless, there will probably be scenarios where a [set of defaults and
heuristics](https://github.com/well-typed/hs-bindgen/issues/32) can do a good
Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages: hs-bindgen-patterns
packages: hs-bindgen-runtime
packages: hs-bindgen
packages: hs-bindgen-libclang
packages: hs-bindgen-bootstrap
Expand All @@ -12,6 +12,6 @@ package hs-bindgen

package hs-bindgen-libclang

package hs-bindgen-patterns
package hs-bindgen-runtime

package hs-bindgen-testlib
4 changes: 2 additions & 2 deletions cabal.project.ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages: hs-bindgen-patterns
packages: hs-bindgen-runtime
packages: hs-bindgen
packages: hs-bindgen-libclang
packages: ansi-diff
Expand All @@ -9,7 +9,7 @@ package hs-bindgen
package hs-bindgen-libclang
ghc-options: -Werror

package hs-bindgen-patterns
package hs-bindgen-runtime
ghc-options: -Werror

package ansi-diff
Expand Down
3 changes: 2 additions & 1 deletion hs-bindgen-libclang/clang-ast-dump/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import HsBindgen.Clang.HighLevel qualified as HighLevel
import HsBindgen.Clang.HighLevel.Types
import HsBindgen.Clang.LowLevel.Core
import HsBindgen.Clang.LowLevel.Doxygen
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Bitfield
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Options
Expand Down
3 changes: 2 additions & 1 deletion hs-bindgen-libclang/clang-tutorial/clang-tutorial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import System.Environment

import HsBindgen.Clang.Args
import HsBindgen.Clang.LowLevel.Core
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Bitfield
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Reproduce the clang tutorial in Haskell
Expand Down
6 changes: 3 additions & 3 deletions hs-bindgen-libclang/hs-bindgen-libclang.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ library
HsBindgen.Clang.HighLevel.UserProvided
build-depends:
-- Internal dependencies
, hs-bindgen-patterns
, hs-bindgen-runtime
build-depends:
-- External dependencies
, filepath >= 1.4.2.2 && < 1.6
Expand All @@ -110,7 +110,7 @@ executable clang-ast-dump
build-depends:
-- Internal dependencies
, hs-bindgen-libclang
, hs-bindgen-patterns
, hs-bindgen-runtime
build-depends:
-- Inherited dependencies
, text
Expand All @@ -127,4 +127,4 @@ test-suite clang-tutorial
build-depends:
-- Internal dependencies
, hs-bindgen-libclang
, hs-bindgen-patterns
, hs-bindgen-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Foreign.C
import HsBindgen.Clang.LowLevel.Core
import HsBindgen.Clang.HighLevel.SourceLoc (MultiLoc, Range)
import HsBindgen.Clang.HighLevel.SourceLoc qualified as SourceLoc
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Bitfield
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import GHC.Stack

import HsBindgen.Clang.LowLevel.Core
import HsBindgen.Clang.LowLevel.Doxygen
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Definition
Expand Down
2 changes: 1 addition & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/HighLevel/Fold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Data.IORef (IORef, writeIORef, readIORef, modifyIORef, newIORef)

import HsBindgen.Clang.LowLevel.Core hiding (clang_visitChildren)
import HsBindgen.Clang.LowLevel.Core qualified as Core
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Text.Show.Pretty (PrettyVal(..))

import HsBindgen.Clang.HighLevel.SourceLoc (Range, MultiLoc, SingleLoc)
import HsBindgen.Clang.HighLevel.SourceLoc qualified as SourceLoc
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

import HsBindgen.Clang.LowLevel.Core qualified as Core
import HsBindgen.Clang.LowLevel.Core hiding (clang_tokenize)
Expand Down
3 changes: 2 additions & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/Internal/Results.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import Foreign
import GHC.Stack

import HsBindgen.Clang.LowLevel.Core.Instances ()
import HsBindgen.Patterns
import HsBindgen.Runtime.Backtrace
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Failed calls
Expand Down
3 changes: 2 additions & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/LowLevel/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ import HsBindgen.Clang.Internal.CXString ()
import HsBindgen.Clang.Internal.FFI
import HsBindgen.Clang.Internal.Results
import HsBindgen.Clang.Version
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Bitfield
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Top-level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module HsBindgen.Clang.LowLevel.Core.Instances () where
import HsBindgen.Clang.LowLevel.Core.Enums
import HsBindgen.Clang.LowLevel.Core.Structs
import HsBindgen.Clang.Internal.ByValue
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Bitfield
import HsBindgen.Runtime.Enum.Simple

#include <clang-c/Index.h>
#include "clang_wrappers.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import HsBindgen.Clang.LowLevel.Doxygen.Structs
import HsBindgen.Clang.Internal.ByValue
import HsBindgen.Clang.Internal.CXString ()
import HsBindgen.Clang.Internal.Results
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

{-------------------------------------------------------------------------------
Top-level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module HsBindgen.Clang.LowLevel.Doxygen.Instances () where
import HsBindgen.Clang.LowLevel.Doxygen.Enums
import HsBindgen.Clang.LowLevel.Doxygen.Structs
import HsBindgen.Clang.Internal.ByValue
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

#include <clang-c/Documentation.h>

Expand Down
2 changes: 1 addition & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/LowLevel/FFI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foreign.C.Types
import HsBindgen.Clang.Internal.ByValue
import HsBindgen.Clang.LowLevel.Core.Enums
import HsBindgen.Clang.LowLevel.Core.Structs
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple
-- Type information for CXCursors https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html

foreign import capi unsafe "clang_wrappers.h"
Expand Down
2 changes: 1 addition & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/Version.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Text.Show.Pretty (PrettyVal)
import System.IO.Unsafe (unsafePerformIO)

import HsBindgen.Clang.Internal.Results (callFailed)
import HsBindgen.Patterns
import HsBindgen.Runtime.Enum.Simple

#include "clang_wrappers.h"

Expand Down

This file was deleted.

This file was deleted.

39 changes: 0 additions & 39 deletions hs-bindgen-patterns/src/HsBindgen/Patterns.hs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Revision history for hs-bindgen-patterns
# Revision history for hs-bindgen-runtime

## 0.1.0 -- YYYY-mm-dd

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cabal-version: 3.0
name: hs-bindgen-patterns
name: hs-bindgen-runtime
version: 0.1.0
synopsis: Design patterns for writing high-level FFI bindings
license: BSD-3-Clause
Expand Down Expand Up @@ -36,16 +36,15 @@ library
import:
lang
exposed-modules:
HsBindgen.ConstantArray
HsBindgen.Patterns
HsBindgen.Patterns.FlexibleArrayMember
HsBindgen.Patterns.LibC
HsBindgen.Runtime.Arithmetic
HsBindgen.Runtime.Backtrace
HsBindgen.Runtime.ConstantArray
HsBindgen.Runtime.Enum.Bitfield
HsBindgen.Runtime.Enum.Simple
HsBindgen.Runtime.FlexibleArrayMember
HsBindgen.Runtime.LibC
other-modules:
HsBindgen.Patterns.Arithmetic
HsBindgen.Patterns.Backtrace
HsBindgen.Patterns.Enum.Bitfield
HsBindgen.Patterns.Enum.Simple
HsBindgen.Patterns.LibC.Arch
HsBindgen.Runtime.LibC.Arch
hs-source-dirs:
src
if arch(x86_64)
Expand Down
2 changes: 2 additions & 0 deletions hs-bindgen-runtime/src-aarch64/HsBindgen/Runtime/LibC/Arch.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HsBindgen.Runtime.LibC.Arch (
) where
2 changes: 2 additions & 0 deletions hs-bindgen-runtime/src-x86_64/HsBindgen/Runtime/LibC/Arch.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HsBindgen.Runtime.LibC.Arch (
) where
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE DerivingVia #-}

module HsBindgen.Patterns.Arithmetic
module HsBindgen.Runtime.Arithmetic
( Div(..) ) where

import Data.Kind
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE CPP #-}

-- | Shim to provide backtrace support
module HsBindgen.Patterns.Backtrace (
module HsBindgen.Runtime.Backtrace (
Backtrace
, prettyBacktrace
, collectBacktrace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HsBindgen.ConstantArray (
module HsBindgen.Runtime.ConstantArray (
ConstantArray,
) where

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HsBindgen.Patterns.Enum.Bitfield (
module HsBindgen.Runtime.Enum.Bitfield (
BitfieldEnum(..)
, IsSingleFlag(..)
-- * API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}

module HsBindgen.Patterns.Enum.Simple (
module HsBindgen.Runtime.Enum.Simple (
SimpleEnum(..)
, IsSimpleEnum(..)
, SimpleEnumOutOfRange(..)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE MagicHash #-}
module HsBindgen.Patterns.FlexibleArrayMember (
module HsBindgen.Runtime.FlexibleArrayMember (
HasFlexibleArrayMember (..),
HasFlexibleArrayLength (..),
WithFlexbileArrayMember (..),
Expand Down
Loading

0 comments on commit 69d1a02

Please sign in to comment.