2013-04-27 6 views
5

* .tsファイルの* .hsファイルを作成するカスタムプリプロセッサを実装しました。 Build-Type: Customを使用してSetup.hsに指定されています。すべて正常に動作しますが、私はそれからcabal sdistを使用してtar.gzパッケージを作成することはできません。Haskell - カスタムプリプロセッサを使ったパッケージ化パッケージ

Cabalは、プリプロセッサによって生成された公開モジュールを見つけることができないと文句を言う。エラーメッセージは、どのように私は、モジュールが不足している、または多分知られているファイル拡張子、または何かにTPLを追加されていないという事実の陰謀団に認識させることができ

cabal: Error: Could not find module with any 
suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs"] 

のですか?

+0

あなたは私達にあなたの '.cabal'ファイルを表示することができます:ここで

は例ですか? –

+0

あなたが必要と思うのは、カスタムsdistフックを書いてから、 'Setup sdist'(https://github.com/haskell/cabal/issues/403のため)でtarballをビルドすることです。 –

+1

実際には、 'Setup sdist'を実行するだけでうまくいくと思います。 –

答えて

3

これはa known issue with cabal sdistです。代わりに./dist/setup/setup sdistを使用してください。

$ cat preprocessor-test.cabal 
name:    preprocessor-test 
version:    0.1.0.0 
build-type:   Custom 
cabal-version:  >=1.10 
extra-source-files: PreprocessorTest/*.prepro 

library 
    exposed-modules:  PreprocessorTest.PreprocessorTest 
    build-depends:  base ==4.5.* 
    -- hs-source-dirs: 
    default-language: Haskell2010 

$ cat Setup.hs 
#!/usr/bin/env runhaskell 

import Distribution.Simple 
import Distribution.Simple.PreProcess 
import Distribution.Simple.Utils 
import Distribution.PackageDescription 
import Distribution.Simple.LocalBuildInfo 
import System.Cmd (rawSystem) 
import System.FilePath ((</>)) 

main = let hooks = simpleUserHooks 
      dummy = ("prepro", dummyPreprocessor) 
     in defaultMainWithHooks hooks 
      { hookedPreProcessors = dummy:knownSuffixHandlers } 

dummyPreprocessor :: BuildInfo -> LocalBuildInfo -> PreProcessor 
dummyPreprocessor build local = PreProcessor { 
    platformIndependent = True, 
    runPreProcessor = 
    mkSimplePreProcessor $ \inFile outFile verbosity -> do 
     notice verbosity (inFile ++ " is being preprocessed to " ++ outFile) 
     rawSystem "cp" [inFile, outFile] 
     return() 
    } 
$ cat PreprocessorTest/PreprocessorTest.prepro 
module PreprocessorTest.PreprocessorTest 
     where 

preprocessorTest :: Int 
preprocessorTest = 1 

$ cabal configure 
Resolving dependencies... 
[1 of 1] Compiling Main    (Setup.hs, dist/setup/Main.o) 
Linking ./dist/setup/setup ... 
Configuring preprocessor-test-0.1.0.0... 

$ cabal build  
Building preprocessor-test-0.1.0.0... 
Preprocessing library preprocessor-test-0.1.0.0... 
PreprocessorTest/PreprocessorTest.prepro is being preprocessed to 
dist/build/PreprocessorTest/PreprocessorTest.hs 
[1 of 1] Compiling PreprocessorTest.PreprocessorTest (dist/build/PreprocessorTest/PreprocessorTest.hs, dist/build/PreprocessorTest/PreprocessorTest.o) 
Registering preprocessor-test-0.1.0.0... 

$ ./dist/setup/setup sdist 
Distribution quality errors: 
No 'synopsis' or 'description' field. 
The 'license' field is missing or specified as AllRightsReserved. 
Distribution quality warnings: 
No 'category' field. 
No 'maintainer' field. 
Note: the public hackage server would reject this package. 
Building source dist for preprocessor-test-0.1.0.0... 
Preprocessing library preprocessor-test-0.1.0.0... 
PreprocessorTest/PreprocessorTest.prepro is being preprocessed to 
dist/src/sdist.-6767/preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/PreprocessorTest.hs 
Source tarball created: dist/preprocessor-test-0.1.0.0.tar.gz 

$ tar tzf dist/preprocessor-test-0.1.0.0.tar.gz 
preprocessor-test-0.1.0.0/ 
preprocessor-test-0.1.0.0/dist/ 
preprocessor-test-0.1.0.0/dist/build/ 
preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/ 
preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/PreprocessorTest.hs 
preprocessor-test-0.1.0.0/Setup.hs 
preprocessor-test-0.1.0.0/PreprocessorTest/ 
preprocessor-test-0.1.0.0/PreprocessorTest/PreprocessorTest.prepro 
preprocessor-test-0.1.0.0/preprocessor-test.cabal 
+0

ありがとう、それは動作します。 – scravy

関連する問題