Comments (5)
As of now, exts
is only used when a Cabal file is read. It contains the extension names that are not in the code, that is, those that are activated in some other way (e.g. from a Cabal file). We could also add a -X
command line option to add custom extensions from the command line, and they would end up in exts
. The extensions that are specified in the file are activated automatically by the GHC parser, so there is no need to keep track of them.
You can check that headers
and includeDirs
are directly passed to the preprocessor at Parser.hs#L51
.
The former contains the paths of additional header files that have to be included before performing the preprocessing, while the latter contains the paths of additional directories which contain additional header files. You'd use headers
if you want to include a file which contains macros and definitions referenced in your code, and includeDirs
to specify where to find certain headers you've used in the code. As you can see at Preprocess.hs#L48
, those two config values directly map to the preprocessor's (e.g. gcc) -include
and -I
options.
As you can see at Main.hs#L30
, the --cabal-macros
is nothing but a synonym for headers
.
Thanks for creating this issue. It made it possible to see where we can improve the command line options. We can now
- make it possible to specify more that one
-I, --include-dir
option (just as GCC does); - add an
--include-header
option that can be specified multiple times (but leaving--cabal-macros
because I still find it clearer); - add a
--define
option, because currently there's no way to specify those; - add an
-X, --extension
option that an be specified more than once in order to load additional extensions.
In order to do that we'll have to ditch Docopt, because the last time I checked it does not support options that can be specified more than once. There's a list here (I'm not sure if it's up-to-date) with various alternatives for option parsing.
from argon.
Thanks, this makes things clearer. Can I ask why the cabal file is not searched/included automatically? It seems to me that the most common use case for argon is the parsing of an entire project.
Could you make an actual example of an use case in which new headers files are included via headers
and includeDirs
? It never happened to me and I'd like to get a better picture.
Regarding the command line options, it seems to me that the best solution for this use case is Gabriel's optparse-generic
(besides, you talked about it here, come say hi on the irc channel sometimes xD).
from argon.
The Cabal file could definitely be searched automatically, I just haven't done it yet. I've opened #30 about that.
If your preprocessing is somewhat advanced and/or complicated it makes sense to modularize it with headers. Personally, I'd steer clear from that, as I think preprocessing makes sense for very simple tasks, without introducing unneeded complexity.
In some cases preprocessing is an absolute necessity. For example, Argon makes use of the GHC API, and sometimes of its internals. Since those can (and do) change with time, there is no way other than CPP to support multiple versions. See, for instance, SYB/Utils.hs
.
As I said, I wouldn't like to make my CPP much complicated, so apart from cabal_macros.h
I don't have any other examples to make. Since Argon strives to support every file that can be compiled by GHC, it supports this feature even though it's rarely used.
optparse-generic
is awesome, but it seems to me that right now positional and optional arguments are mutually exclusive. I'll see what can be done about it.
I don't use IRC that much, but I'll make sure to drop by sometimes
from argon.
Can I close this issue? Or if you have other questions I'm happy to answer them.
from argon.
Sure, this issue can be closed. I'll probably ask a few more questions in another one though ;)
Thanks!
from argon.
Related Issues (20)
- It doesn't seem to like signatures on pattern synonyms: HOT 5
- fails to parse CPP testing MIN_VERSION... HOT 3
- ScopedTypeVariables does not work with GHC 7.8
- Add -I --include option HOT 3
- Use a streaming library to export parsed data HOT 2
- Add -c, --cabal option
- Solve TypeFamilies and Foreign Import GHC panics
- Increase test coverage
- Add filesystem traversal to the pipeline
- Extensions from the cabal file are not picked up HOT 6
- CPP preprocessing error in the hint library HOT 7
- ExplicitForAll errors, even when RankNTypes is enabled HOT 10
- Search cabal file automatically
- Stack Support HOT 1
- Provide an explanation about how cyclomatic complexity is measured HOT 5
- Odd error about 'DatatypeContexts'
- Cyclomatic Complexity calculation error HOT 5
- Unsupported extension: TypeApplications HOT 1
- Cannnot compile HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argon.