tweag/inline-java

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

Fuuzetsu opened this issue · 3 comments

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.

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.
  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…

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.