-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C.includes
does not track changes
#152
Comments
Hi @MathiasSven , |
@junjihashimoto I have made a minimal rep repo with nix at https://github.com/MathiasSven/inline-c-152-rep, perhaps I am missing some configuration, but from looking at the Steps I took: > nix develop
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.3
> cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library
>
> cabal run -v0
2
> sed -i 's/1/5/g' src/test.hpp
> cabal run -v0
2 # Should have been 6, no recompilation happend
> echo "" >> src/Main.hs
> cabal run -v0
6 |
@MathiasSven Thank you for creating the example. Cabal detects updating src/test.hpp, and it reruns ghc, but the binary is not updated. So it seems that the issue is ghc not cabal. |
When you pass the |
@junjihashimoto That would make so whenever there are any changes in an included file, all modules would be recompiled. Couldn't $(addDependentFile "/tmp/tmp.foSjrQBSoX/inline-c-152-rep/src/test.hpp" >> return []) I have added a branch to the example repo which uses
|
For my use case, it seems to work just fine to simply add {-# LANGUAGE PackageImports #-}
module Language.C.Inline.Cpp
( module Upstream
, include
)
where
import "inline-c-cpp" Language.C.Inline.Cpp as Upstream hiding (include)
import Language.Haskell.TH.Syntax (addDependentFile)
import Language.Haskell.TH (DecsQ, runIO, location, loc_filename)
import System.FilePath ((</>), takeDirectory)
import System.Directory (getCurrentDirectory)
import Control.Monad (void)
include :: String -> DecsQ
include s
| null s = fail "inline-c: empty string (include)"
| head s == '<' = verbatim $ "#include " ++ s
| otherwise = do
void $ addDependentFileRelative s
verbatim $ "#include \"" ++ s ++ "\""
addDependentFileRelative :: FilePath -> DecsQ
addDependentFileRelative relativeFile = do
currentFilename <- loc_filename <$> location
pwd <- runIO getCurrentDirectory
let invocationRelativePath = takeDirectory (pwd </> currentFilename) </> relativeFile
addDependentFile invocationRelativePath
return [] branch for reference |
@MathiasSven Thank you for finding the solution! |
I will make a draft PR, although this works for my use case specifically, I don't know if it would be appropriate for every use case. |
I am not sure if this is a cabal only issue or if it is an issue with
inline-c
too, but like withtest.h
underinline-c-cpp/test
, I have a local header file that I include in myhs
file, however when I make changes to it, there is no recompilation.There seems to be an open issue for "cabal new-build does not track files added via TH’s addDependentFile", but in it there is also a comment that says that even if the issue is closed, that wouldn't fix
inline-c
's use case.What is the best solution at the moment to deal with this issue? Is there a manual way that users of
inline-c
can tell cabal to watch specific files for changes?The text was updated successfully, but these errors were encountered: