GithubHelp home page GithubHelp logo

samplecount / shake-language-c Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 6.0 247 KB

Cross-compilation framework based on the Shake Haskell library.

Home Page: https://github.com/samplecount/shake-language-c#shake-language-c

License: Apache License 2.0

Haskell 99.15% Shell 0.14% Nix 0.71%

shake-language-c's People

Contributors

clowcay avatar kaoskorobase avatar mokus0 avatar ndmitchell avatar smunix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

shake-language-c's Issues

src/Development/Shake/Language/C/Config.hs:76:12: error: • Couldn't match type ‘RuleResult Config’ with ‘Maybe String’

For Stackage Nightly:

src/Development/Shake/Language/C/Config.hs:76:12: error:
    • Couldn't match type ‘RuleResult Config’ with ‘Maybe String’
        arising from a use of ‘addOracle’
    • In a stmt of a 'do' block:
        query <- addOracle
                   $ \ (Config (deps, file, env, key))
                       -> Map.lookup key <$> fileCache (deps, file, env)
      In the expression:
        do fileCache <- newCache $ \ (deps, file, env) -> do ...
           query <- addOracle
                      $ \ (Config (deps, file, env, key))
                          -> Map.lookup key <$> fileCache (deps, file, env)
           return
             $ \ deps file env key -> query (Config (deps, file, env, key))
      In an equation for ‘mkConfig’:
          mkConfig
            = do fileCache <- newCache $ \ (deps, file, env) -> ...
                 query <- addOracle
                            $ \ (Config (deps, file, env, key))
                                -> Map.lookup key <$> fileCache ...
                 return $ \ deps file env key -> query (Config ...)
   |
76 |   query <- addOracle $ \(Config (deps, file, env, key)) -> Map.lookup key <$> fileCache (deps, file, env)
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Change build product rule signature

Change signature of build rules in Shake.Development.Language.C.Rules to

buildProduct ::
   Action ToolChain -- ^ Action returning a target 'ToolChain'
-> Action (BuildFlags -> BuildFlags) -- ^ Action returning a 'BuildFlags' modifier
-> Action [FilePath] -- ^ Action returning a list of input source files
-> Rules (FilePath -> Action()) -- ^ Rule returning an action that produces the given output file

This would allow for further build product processing without introducing intermediate (phony) targets. The old rules functions can still be provided as trivial wrappers of the new ones:

buildProcuct_ toolChain flags sources output =
  (output *>) =<< buildProduct toolChain flags sources

ARM Linux support

Trying to build Methcla on an ARMv7 running Linux:

./shake .update
Unknown host architecture armv7l
CallStack (from HasCallStack):
error, called at src/Development/Shake/Language/C/Host/Linux.hs:33:14 in shake-language-c-0.10.0-3OxHz2LdZSyIlVaBYgvPMo:Development.Shake.Language.C.Host.Linux

Make default build flags part of toolchain

The default build flags for each target/platform/toolchain combination should be part of the toolchain record. The library/executable rules wouldn't need a build flags argument anymore, but directly apply the source tree to the toolchain build flags.

Pass ToolChain around in a Configure monad

This could be something like type Configure a = Action (Maybe a) and would allow the toolchain to depend on the contents of a configuration file (as in Development.Shake.Config).

The downside is that the toolchain is only defined when executing the actions for a rule and cannot be inspected before.

Executable with both source and static lib inputs

Was playing around, and couldn't figure out the rules to apply for the following situation:

test_lib.[h, cc]
bin1.cc (includes test_lib.h, should link against test_lib)
build/ (dir to be used by shake)

I tried the following rules (omitting toolchain, flags):

lib1 <- staticLibrary "build/libtest_lib.a" (pure ["test_lib.cc"])
bin1 <- executable "build/bin1" (pure ["bin1.cc", "build/libtest_lib.a"])
want [bin1]

I'm sure I'm missing something. This is the output:

# gcc (for build/libtest_lib_a_obj/test_lib.cc.rel.o)
# ar (for build/libtest_lib.a)
# ranlib (for build/libtest_lib.a)
# gcc (for build/bin1_obj/build/libtest_lib.a.rel.o)
gcc: warning: build/libtest_lib.a: linker input file unused because linking not done
Error when running Shake build system:
* build/bin1
* build/bin1_obj/build/libtest_lib.a.rel.o
build/bin1_obj/build/libtest_lib.a.rel.o.d: openBinaryFile: does not exist (No such file or directory)
build/
├── bin1_obj
│   └── build
├── libtest_lib.a
└── libtest_lib_a_obj
    ├── test_lib.cc.rel.o
    └── test_lib.cc.rel.o.d

Thanks!

Allow to use Actions in config file environment

Allow to use actions in config file environment, i.e. change withConfig signature to

withConfig :: [FilePath]
           -> Rules (   [(String, Action String)]
                     -> FilePath
                     -> String
                     -> Action (Maybe String))

Use case: Pass toolchain variant determined from host toolchain (returned in Action monad) to config file environment.

hake-language-c-0.8.1 test suite fails on NixOS because of undeclared system dependencies

Citing from http://hydra.cryp.to/build/1330346/nixlog/1/raw:

Test suite spectests: RUNNING...

Host toolchain
  compiles a C file to an executable FAILED [1]
  compiles a C++ file to an executable FAILED [2]

Failures:

  tests/spectests.hs:51:
  1) Host toolchain compiles a C file to an executable
       uncaught exception: ShakeException (Error when running Shake build system:
       * tests/build/host_toolchain_compile_c/output/result.txt
       * tests/build/host_toolchain_compile_c/output/result
       arch: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
       )

  tests/spectests.hs:71:
  2) Host toolchain compiles a C++ file to an executable
       uncaught exception: ShakeException (Error when running Shake build system:
       * tests/build/host_toolchain_compile_cpp/output/result.txt
       * tests/build/host_toolchain_compile_cpp/output/result
       arch: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
       )

Randomized with seed 123489781

Finished in 0.0144 seconds
2 examples, 2 failures
Test suite spectests: FAIL

Build failure with GHC 7.10

Unpacking to shake-language-c-0.6.4/
Resolving dependencies...
Configuring shake-language-c-0.6.4...
Building shake-language-c-0.6.4...
Preprocessing library shake-language-c-0.6.4...
[ 1 of 19] Compiling Development.Shake.Language.C.Util ( src/Development/Shake/Language/C/Util.hs, dist/build/Development/Shake/Language/C/Util.o )
[ 2 of 19] Compiling Development.Shake.Language.C.Config ( src/Development/Shake/Language/C/Config.hs, dist/build/Development/Shake/Language/C/Config.o )

src/Development/Shake/Language/C/Config.hs:15:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[ 3 of 19] Compiling Development.Shake.Language.C.Label ( src/Development/Shake/Language/C/Label.hs, dist/build/Development/Shake/Language/C/Label.o )

src/Development/Shake/Language/C/Label.hs:30:1: Warning:
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
[ 4 of 19] Compiling Development.Shake.Language.C.Language ( src/Development/Shake/Language/C/Language.hs, dist/build/Development/Shake/Language/C/Language.o )
[ 5 of 19] Compiling Development.Shake.Language.C.BuildFlags ( src/Development/Shake/Language/C/BuildFlags.hs, dist/build/Development/Shake/Language/C/BuildFlags.o )

src/Development/Shake/Language/C/BuildFlags.hs:57:1: Warning:
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
[ 6 of 19] Compiling Development.Shake.Language.C.ToolChain ( src/Development/Shake/Language/C/ToolChain.hs, dist/build/Development/Shake/Language/C/ToolChain.o )

src/Development/Shake/Language/C/ToolChain.hs:57:1: Warning:
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
[ 7 of 19] Compiling Development.Shake.Language.C.Rules ( src/Development/Shake/Language/C/Rules.hs, dist/build/Development/Shake/Language/C/Rules.o )

src/Development/Shake/Language/C/Rules.hs:94:10:
    Ambiguous occurrence ‘*>’
    It could refer to either ‘Prelude.*>’,
                             imported from ‘Prelude’ at src/Development/Shake/Language/C/Rules.hs:57:8-41
                             (and originally defined in ‘GHC.Base’)
                          or ‘Development.Shake.*>’,
                             imported from ‘Development.Shake’ at src/Development/Shake/Language/C/Rules.hs:65:1-24

src/Development/Shake/Language/C/Rules.hs:104:53:
    Ambiguous occurrence ‘*>’
    It could refer to either ‘Prelude.*>’,
                             imported from ‘Prelude’ at src/Development/Shake/Language/C/Rules.hs:57:8-41
                             (and originally defined in ‘GHC.Base’)
                          or ‘Development.Shake.*>’,
                             imported from ‘Development.Shake’ at src/Development/Shake/Language/C/Rules.hs:65:1-24
[ 8 of 19] Compiling Development.Shake.Language.C.Target ( src/Development/Shake/Language/C/Target.hs, dist/build/Development/Shake/Language/C/Target.o )
[ 9 of 19] Compiling Development.Shake.Language.C.Target.Android ( src/Development/Shake/Language/C/Target/Android.hs, dist/build/Development/Shake/Language/C/Target/Android.o )

src/Development/Shake/Language/C/Target/Android.hs:112:18: Warning:
    This binding for ‘target’ shadows the existing binding
      defined at src/Development/Shake/Language/C/Target/Android.hs:65:1
[10 of 19] Compiling Development.Shake.Language.C.Target.Linux ( src/Development/Shake/Language/C/Target/Linux.hs, dist/build/Development/Shake/Language/C/Target/Linux.o )
[11 of 19] Compiling Development.Shake.Language.C.Host.Linux ( src/Development/Shake/Language/C/Host/Linux.hs, dist/build/Development/Shake/Language/C/Host/Linux.o )
[12 of 19] Compiling Development.Shake.Language.C.Host.Windows ( src/Development/Shake/Language/C/Host/Windows.hs, dist/build/Development/Shake/Language/C/Host/Windows.o )
[13 of 19] Compiling Development.Shake.Language.C.Target.OSX ( src/Development/Shake/Language/C/Target/OSX.hs, dist/build/Development/Shake/Language/C/Target/OSX.o )

src/Development/Shake/Language/C/Target/OSX.hs:41:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[14 of 19] Compiling Development.Shake.Language.C.Host.OSX ( src/Development/Shake/Language/C/Host/OSX.hs, dist/build/Development/Shake/Language/C/Host/OSX.o )

src/Development/Shake/Language/C/Host/OSX.hs:19:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[15 of 19] Compiling Development.Shake.Language.C.Host ( src/Development/Shake/Language/C/Host.hs, dist/build/Development/Shake/Language/C/Host.o )
[16 of 19] Compiling Development.Shake.Language.C.Target.Windows ( src/Development/Shake/Language/C/Target/Windows.hs, dist/build/Development/Shake/Language/C/Target/Windows.o )

Make target part of toolchain

The target passed to create a particular toolchain should be part of the toolchain record. This saves one argument in most rule functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.