git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: make '.hh' FFI files optional
commit36da2723ac7de615f463f4d60f37689ca45876d9 authorAndy Arvanitis <andyarvanitis@gmail.com> dateMon 12 Oct 2015, 15:26 (11 years ago) parent01592a6
1 file changed+12−11
pcc/Make.hs+12−11
pcc/Make.hs+12−11
@@ -131,18 +131,19 @@ buildMakeActions outputDir filePathMap usePrefix =
131131 writeTextFile (supportDir </> "map_key.hh") $ B.unpack $(embedFile "pcc/include/map_key.hh")
132132 writeTextFile (supportDir </> "hash.hh") $ B.unpack $(embedFile "pcc/include/hash.hh")
133133
134− when (requiresForeign m) $ do
135− let inputPath = dropExtension $ getInputFile mn
136− hfile = addExtension inputPath "hh"
137− sfile = addExtension inputPath "cc"
138− hfileExists <- textFileExists hfile
139− when (not hfileExists) (throwError . P.errorMessage $ P.MissingFFIModule mn)
140− text <- readTextFile hfile
134+ let inputPath = dropExtension $ getInputFile mn
135+ hfile = addExtension inputPath "hh"
136+ sfile = addExtension inputPath "cc"
137+ hfileExists <- textFileExists hfile
138+ when (hfileExists || requiresForeign m) $ do
139+ text <- if hfileExists
140+ then readTextFile hfile
141+ else pure []
141142 writeTextFile (addExtension (fileBase ++ "_ffi") "hh") text
142− sfileExists <- textFileExists sfile
143− when (sfileExists) $ do
144− text' <- readTextFile sfile
145− writeTextFile (addExtension (fileBase ++ "_ffi") "cc") text'
143+ sfileExists <- textFileExists sfile
144+ when (sfileExists) $ do
145+ text' <- readTextFile sfile
146+ writeTextFile (addExtension (fileBase ++ "_ffi") "cc") text'
146147
147148 requiresForeign :: CF.Module a -> Bool
148149 requiresForeign = not . null . CF.moduleForeign