Repository navigation
Conversation
…of bootstrap script
| ALEX_PATH="$(pwd)/$(find . -name alex -perm 755 | tail -n1)" | ||
| echo "Cabal-${CABAL_VER} will be installed from the local Git clone." | ||
| (cd ../Cabal && install_pkg ${CABAL_VER} ${CABAL_VER_REGEXP}) | ||
| (cd ../Cabal && ${ALEX_PATH} -g Distribution/C2Hs/Lexer.x && install_pkg ${CABAL_VER} ${CABAL_VER_REGEXP}) |
There was a problem hiding this comment.
I'm on the fence with these. The lexer for .cabal files is generated in manual preprocessing step (see Makefile). And rather keep it that way, i.e. let's not have compile-time dependency on alex.
| .PHONY : cabal-install-dev cabal-install-prod | ||
|
|
||
| LEXER_HS:=Cabal/Distribution/Fields/Lexer.hs | ||
| LEXER_CHS:=Cabal/Distribution/C2Hs/Lexer.hs |
There was a problem hiding this comment.
We still need to commit in Lexer.hs file too. So the people who do not modify Lexer.x shouldn't need to be aware of it.
|
CI is acting up, but this should be ready to merge. |
| {-# LANGUAGE RankNTypes #-} | ||
| {-# LANGUAGE FlexibleContexts #-} | ||
|
|
||
| -- Based on https://github.com/gtk2hs/gtk2hs/blob/master/tools/src/Gtk2HsSetup.hs#L414 |
There was a problem hiding this comment.
That's GPLd repository, we cannot "base" anything on that code.
|
|
||
| $module = [A-Za-z\.] | ||
|
|
||
| tokens :- |
There was a problem hiding this comment.
This file needs comments, what it does. Is there a reason why you chose alex, and not writing something using parsec?
There was a problem hiding this comment.
I used alex because it seems to be the best choice for lexers and I've used it in the past for identifying dependencies in e.g. C.
There was a problem hiding this comment.
Well, I don't agree that we need to write any new alex code. It's write-only for almost any other contributor. You should been asked before making tech choice
| import Distribution.Simple.Utils (dieNoVerbosity, findFileWithExtension, withUTF8FileContents) | ||
| import System.FilePath (joinPath) | ||
|
|
||
| reorderC2Hs :: [FilePath] -> [ModuleName] -> IO [ModuleName] |
There was a problem hiding this comment.
This need a proper comment, what it does, and why.
| mods <- case getImports con of | ||
| Right ms -> case traverse simpleParsec ms of | ||
| Just ms' -> pure ms' | ||
| Nothing -> dieNoVerbosity ("Cannot parse module name in c2hs file " ++ f) |
There was a problem hiding this comment.
This dieing here feels wrong. There should be way to fail in pure way...
We need tests.
There was a problem hiding this comment.
I have changed the dieNoVerbosity to a warn.
I've added some tests to ensure it works as I need it to.
| Left err -> dieNoVerbosity ("Cannot parse c2hs import in " ++ f ++ ": " ++ err) | ||
| pure (md { moduleRequires = mods }) | ||
|
|
||
| sortTopological :: [ModDep] -> [ModDep] |
There was a problem hiding this comment.
Is there a way to Distribution.Compat.Graph to not reinvent the wheel?
There was a problem hiding this comment.
Yes; I've fixed this.
| let dirs = hsSourceDirs bi ++ [autogenComponentModulesDir lbi clbi | ||
| ,autogenPackageModulesDir lbi] | ||
| for_ (map ModuleName.toFilePath $ allLibModules lib clbi) $ | ||
| mods <- reorderC2Hs dirs (allLibModules lib clbi) |
There was a problem hiding this comment.
Why only for librayr components, shouldn't this be done for all components?
There was a problem hiding this comment.
Yes, this should be fixed now.
|
@phadej is this ready to be merged? |
phadej
left a comment
There was a problem hiding this comment.
I'm sorry to say no to this.
There are issues I commented inline. Also I'd personally expect a single comment with a good commit message explaining what and why that commit does. There're plenty of code.
But I'm not familiar with issue #55, and maybe someone talked you already to do this PR this way.
Please find someone else to review this. as said, I don't feel this is right, but I cannot explain myself better.
If someone else want to take responsibility of merging this, I won't be offended.
|
|
||
| $module = [A-Za-z\.] | ||
|
|
||
| tokens :- |
There was a problem hiding this comment.
Well, I don't agree that we need to write any new alex code. It's write-only for almost any other contributor. You should been asked before making tech choice
| @@ -0,0 +1,119 @@ | |||
| {-# LANGUAGE DeriveAnyClass #-} | |||
| {-# LANGUAGE DeriveGeneric #-} | |||
There was a problem hiding this comment.
Is this file actually compiled, or is it only an input for tests?
Can we place it's somewhere where it doesn't look like real file.
I value that we have "real life" tests inputs, but we also should have something more minimal.
Also negative examples.
|
/cc @dcoutts |
|
@hvr thoughts? I'm quite keen on getting this merged (/fixed), and I'm open to rearranging most of it based on the experience of others (I am quite partial to the alex-based lexer, though). |
|
(Also, if someone else wants to rewrite the lexer I would not be offended - but I would not know how to do this without alex or a similar tool/library for lexers) |
|
@vmchale I'm also interested in improving dependency tracking for cabal preprocessors, but in general, not just for c2hs. I don't really understand in detail what exactly c2hs needs here, maybe you cain explain what is going on? Also is there a reason you can see that would prevent doing this more generally, by say adding an eplicit interface for any preprocessors to communicate dependencies to Cabal instead of Cabal having to parse the preprocessor's input which seems like a pretty nasty violation of the separation of concerns? |
|
@DanielG That's a good point. It might be better to expose a general interface to allow preprocessors to reorder dependencies. As for what Briefly, If you have any more questions about the specific My 2¢ is that |
|
I'm not against shipping special support code for the builtin preprocessors, I just think it should be possible for external ones to work to the same extent. Possibly with some custom Setup.hs code but ideally I'd like to just have some protocol that preprocessors can choose to expose which Cabal can automatically use to give you improved dependency tracking. |
|
Right, my guess is it's easier to require custom |
|
I have thinking about this, and I won't accept this approach. There are two options:
cf. that with To say it directly: I won't accept |
|
@phadej So you think it would be sensible to provide build tools a mechanism to pass dependency reorderings to cabal-install? Should a spec be decided on on the cabal side before making PRs to c2hs and so on?: |
|
Marking this PR as draft 🙂 |
|
Hello, I am going through old PRs to check whether they are stale. If this PR is still “live”, write a comment and I will remove the |
This fixes a 13 year-old bug, viz. #55 aka #1906
[ci skip]is used to avoid triggering the build bots.I tested it by building my own library.