Giter Club home page Giter Club logo

ppx_blob's Introduction

ppx_blob

This is an OCaml PPX to include a binary blob from a file as a string. Writing [%blob "filename"] will replace the string with the contents of the file at compile time. This allows the inclusion of arbitrary, possibly compressed, data, without the need to respect OCaml's lexical conventions.

The filename can be relative to either the source file where [%blob] appears, or relative to the current working directory. If both files exist, the former takes precedence.

Integration with build systems

Dune

Add (preprocessor_deps (file path/to/file)) to your library or executable stanza. See test/dune for an example. This will make sure the file is copied to the build directory and therefore visible to ppx_blob.

Development

Requirements:

Run make and make test.

ppx_blob's People

Contributors

aantron avatar actionshrimp avatar andreas avatar bbc2 avatar copy avatar hcarty avatar jberdine avatar johnwhitington avatar kit-ty-kate avatar leonidas-from-xiv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ppx_blob's Issues

ppx_blob and the compilation chain

When using ppx_blob, the compilation chain has to know the included file is now a dependency of the file that includes it (so that the including file gets recompiled when the included file is modified). Is there another means than tagging dependencies manually?

relative path doesn't work with dune 3.0

If we change (lang dune 1.0) to (lang dune 3.0) (https://github.com/johnwhitington/ppx_blob/blob/0.7.2/dune-project#L1
the build will failed with following error.

$ make all
dune build @install @example
File "example/quine.ml", line 1, characters 13-31:
1 | print_string [%blob "quine.ml"]
                 ^^^^^^^^^^^^^^^^^^
Error: [%blob] could not find or load file quine.ml

I found that Ocaml_common.Location.absolute_path path no longer return a real path but prefix the argument with /workspace_root/.
Since there is no /workspace_root/example/quine.ml, a Not_found is thrown.

Publish new version

The latest published version still depends on jbuilder. Can you publish a new version that uses dune? Thanks.

Not compatible with 4.03

Due to usage of Const_string, which in 4.03 is replaced by Pconst_string (and perhaps other minor differences).

I would submit a PR, but do you prefer:

  • depending on ppx_tools, which has an Ast_convenience module (in part for) dealing with this sort of thing, or
  • maintaining two branches, one for 4.03+, and one for 4.02?

Warnings about compiler-libs when using ppx_blob

I'm not sure if this is an issue with ppx_blob or elsewhere. I get these warnings when compiling anything using ppx_blob using OCaml 4.02.1/4.02.2 and ppx_blob 0.1. Everything else is the latest from opam.

$ cat test.ml

let () =
  let s = [%blob "test.ml"] in
  print_endline s
$ ocamlbuild -use-ocamlfind -package ppx_blob test.native
+ ocamlfind ocamlc -c -package ppx_blob -o test.cmo test.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/hcarty/.opam/4.02.2/lib/ocaml, /home/hcarty/.opam/4.02.2/lib/ocaml/compiler-libs
+ ocamlfind ocamlopt -c -package ppx_blob -o test.cmx test.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/hcarty/.opam/4.02.2/lib/ocaml, /home/hcarty/.opam/4.02.2/lib/ocaml/compiler-libs
+ ocamlfind ocamlopt -linkpkg -package ppx_blob test.cmx -o test.native
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/hcarty/.opam/4.02.2/lib/ocaml, /home/hcarty/.opam/4.02.2/lib/ocaml/compiler-libs
Finished, 4 targets (0 cached) in 00:00:00.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.