git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: make '.hh' FFI files optional
36da272Andy Arvanitis
pcc/Make.hs+12−11
@@ -131,18 +131,19 @@ buildMakeActions outputDir filePathMap usePrefix =
131 writeTextFile (supportDir </> "map_key.hh") $ B.unpack $(embedFile "pcc/include/map_key.hh")
131 writeTextFile (supportDir </> "map_key.hh") $ B.unpack $(embedFile "pcc/include/map_key.hh")
132 writeTextFile (supportDir </> "hash.hh") $ B.unpack $(embedFile "pcc/include/hash.hh")
132 writeTextFile (supportDir </> "hash.hh") $ B.unpack $(embedFile "pcc/include/hash.hh")
133
133
134− when (requiresForeign m) $ do
135− let inputPath = dropExtension $ getInputFile mn
134+ let inputPath = dropExtension $ getInputFile mn
136− hfile = addExtension inputPath "hh"
135+ hfile = addExtension inputPath "hh"
137− sfile = addExtension inputPath "cc"
136+ sfile = addExtension inputPath "cc"
138− hfileExists <- textFileExists hfile
137+ hfileExists <- textFileExists hfile
139− when (not hfileExists) (throwError . P.errorMessage $ P.MissingFFIModule mn)
138+ when (hfileExists || requiresForeign m) $ do
139+ text <- if hfileExists
140− text <- readTextFile hfile
140+ then readTextFile hfile
141+ else pure []
141 writeTextFile (addExtension (fileBase ++ "_ffi") "hh") text
142 writeTextFile (addExtension (fileBase ++ "_ffi") "hh") text
142− sfileExists <- textFileExists sfile
143+ sfileExists <- textFileExists sfile
143− when (sfileExists) $ do
144+ when (sfileExists) $ do
144− text' <- readTextFile sfile
145+ text' <- readTextFile sfile
145− writeTextFile (addExtension (fileBase ++ "_ffi") "cc") text'
146+ writeTextFile (addExtension (fileBase ++ "_ffi") "cc") text'
146
147
147 requiresForeign :: CF.Module a -> Bool
148 requiresForeign :: CF.Module a -> Bool
148 requiresForeign = not . null . CF.moduleForeign
149 requiresForeign = not . null . CF.moduleForeign