tweag / inline-java

Haskell/Java interop via inline Java code in Haskell modules.
BSD 3-Clause "New" or "Revised" License
229 stars 15 forks source link

Language.Java.Inline.Plugin can only be compiled from top level directory #101

Closed Fuuzetsu closed 6 years ago

Fuuzetsu commented 6 years ago

This file includes a C header at compile time with TH:

    bctable_header :: String
    bctable_header = $(do
        let f = "cbits/bctable.h"
        TH.addDependentFile f
        TH.lift =<< TH.runIO (readFile f)
      )

This only works if we compile the file from the root of inline-java: this works fine for things like stack but does not work for things like bazel where the compilation might be occurring from "higher up". I don't know a good solution here.

facundominguez commented 6 years ago

I can think of two approaches:

1) Put cbits/bctable.h in the data files and define bctable_header = unsafePerformIO $ getDataFile "bctable.h" 2) Include the contents of cbits/bctable.h verbatim in the generated C stub so no file needs to be found at build or runtime.

Fuuzetsu commented 6 years ago
  1. Doesn't work for us as it requires on Paths_ which we don't support in bazel
  2. I don't know. I don't understand the details of why we're inlining it in the first place: clearly something to do with plugins. Are you suggesting that it's inlined in Plugin.hs? I'm not sure if it's that simple…
facundominguez commented 6 years ago

Are you suggesting that it's inlined in Plugin.hs? I'm not sure if it's that simple…

#include "path/to/bctable.h" is inserted in a C stub in the plugin. Instead of doing this, we could expand the include with the contents of bctable.h and remove bctable.h from the repo.