Giter Site home page Giter Site logo

configurator's Introduction

Configurator

Configurator is a small library that helps writing OCaml scripts that test features available on the system, in order to generate config.h files for instance.

Configurator allows one to:

  • test if a C program compiles
  • query pkg-config
  • import #define from OCaml header files
  • generate config.h file

For instance:

open Base
module C = Configurator

let clock_gettime_code = {|
#include <time.h>

int main()
{
  struct timespec ts;
  clock_gettime(CLOCK_REALTIME, &ts);
  return 0;
}
|}

let () =
  C.main ~name:"foo" (fun c ->
    let has_clock_gettime = C.c_test c clock_gettime_code ~link_flags:["-lrt"] in

    C.C_define.gen_header_file c ~fname:"config.h"
      [ "HAS_CLOCK_GETTIME", Switch has_clock_gettime ]);

configurator's People

Contributors

avsm avatar jeremiedimino avatar trefis avatar xclerc avatar yomimono avatar

Stargazers

 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  avatar  avatar

configurator's Issues

Specify custom PKG_CONFIG_PATH

It would be useful if I could specify a custom PKG_CONFIG_PATH when querying a package; perhaps add an optional parameter to Pkg_config.query.

Linux Executables with .exe suffix are killed running in Window Subsystem for Linux

In configurator.ml, in the compile_c_prog function, there is the line:

let exe_fname = base ^ ".exe" in

which gives the executable a ".exe" suffix even if running on linux. When the linux is running as part of Windows Subsystem for Linux, Windows is apparently trying to run the program as a windows program and the result is that the program is "killed" on startup before reaching the main program.

I'm running the beta version of WSL that comes with the Creator's Update, (windows version 1703) which is running ubuntu 16.04.

To test this out, I took the failing executable and renamed it to a name not ending with .exe and it executes file.

I suggest the following change:

type t on line 16 already has a field "ext_obj" for the object file extension. A "ext_exe" field should be added as well (the ocaml config already has this) and it should be used instead of the hardwired ".exe".

Drop the dependency on ppx

configurator seems like a quite low level package that is useful in many situations where ppx isn't desirable (low dep footprint) or available (windows, some rare BSD's). Would it be possible to get rid of the few minor uses of ppx in configurator?

Seems like there's only a couple of simple uses of ppx_sexp_conv and ppx_compare. It would be easy enough to write those out manually. Or if something more future proof is necessary, perhaps implement the same system that base uses?

Enable running programs

It would be useful if Configurator could also run C code and either check the return value or even return the output. This would enable getting a version of a library, checking that C enum values reported as variants on the OCaml side are in sync,...

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.