Coder Social home page Coder Social logo

obazl / tools_obazl Goto Github PK

View Code? Open in Web Editor NEW
4.0 6.0 0.0 2.23 MB

Tools for use with the OBazl Toolsuite

Home Page: https://obazl.github.io/docs_obazl/

License: Eclipse Public License 2.0

Starlark 3.64% Makefile 0.51% C 77.26% Shell 0.12% Emacs Lisp 0.22% Scheme 0.03% Lua 1.15% C++ 0.27% Yacc 0.68% HTML 15.76% CSS 0.11% Roff 0.25%
bazel dune ocaml opam

tools_obazl's Introduction

tools_obazl

WARNING: currently under heavy development, do not use.

A collection of Bazel tools, mainly for OCaml development using obazl_rules_ocaml.

WORKSPACE.bazel:

git_repository(
    name = "tools_bazel",
    remote = "https://github.com/obazl/tools_bazel",
    branch = "main",
)

Tools:

  • tokenize tokenizes a string. Default separator is whitespace.

    • load( "@tools_bazel//tools/functions:strings.bzl", "tokenize")
    • tokenize("foo bar") => ["foo", "bar"].
    • tokenize("foo_bar", sep="_") => ["foo", "bar"].
  • get_xdg(repo_ctx) returns multival: home, XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME


tools_obazl's People

Contributors

mobileink avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tools_obazl's Issues

@obazl//coswitch:refresh fails on local switch with system compiler

Use case: system compiler is 4.14.0. To create a local switch in ppx_assert: opam switch create . 4.14.0. This creates a new local switch using the system compiler (/usr/local/bin/ocamlc etc.), which means that ./_opam/ocaml will not have all the stuff it would have if the compiler is installed in the switch itself. Which means in turn that @obazl//coswitch:refresh will not know how to deal with it.

cleanup global vars

building with gcc 11 and gold linker we get stuff like:

/usr/bin/ld.gold: error:
bazel-out/k8-fastbuild/bin/external/mibl/src/_objs/opam_switch_converter/config_opam.pic.o:
multiple definition of 'rc'
/usr/bin/ld.gold:
bazel-out/k8-fastbuild/bin/external/mibl/src/_objs/opam_switch_converter/config_bazel.pic.o:
previous definition here

new tool to generate new projects etc.

Cmd: @obazl//new -- -p <projname> plus whatever other params.

Should generate:

  • .bazelignore
  • .bazelrc
  • .gitignore
  • ./private/.gitignore, ./private/bazelrc
  • .bazelversion?
  • .obazl.d/opam/local/BOOTSTRAP.bzl
  • BUILD.bazel
  • BUILD.bzl (dummy, for demo)
  • COSWITCH.bzl
  • WORKSPACE.bazel
  • WORKSPACE.bzl (with demo fetch/bootstrap function)
  • bzl/hosts/BUILD.bazel
  • src/BUILD.bazel and some source files to build
  • test/BUILD.bazel with some test targets

Maybe:

  • bin/
  • tools/ with some scripts like wss

parse dune-package instead of META?

It looks like dune-package files contain all the information in META files. Of course this would not work for packages that do not use dune, e.g. Zarith, pkgs from dbuenzli (fmt, cmdliner, etc.).

improve conversion of inline_test, expect testing, etc.

Currently @obazl//convert:dune can handle these in some cases but not all. Dependency on ppx_inline_test is not always directly expressed by dune stanzas. For example, ppx_bench/example/dune has:

(library (name ppx_bench_sample_lib) (libraries core)
 (preprocess (pps ppx_bench)))

and the ppx_bench library (//src:ppx_bench) depends on @ppx_inline_test//lib/libname. So in order to discover the dependency we would have to inspect everything in the (preprocess (pps ...)) directive. The mibl data has all the required info, but implementing the search will be a PITA.

That would work internally for ppx_bench. But if some other project were to depend on an opam package that depends on ppx_inline_test, we would have no way of discovering the dependency short of crawling around in the opam dependency graph.

We need to discover the dependency because it means we need to add ["-inline-test-lib", "foo"] to the ppx_args attribute wherever a ppx transform uses the lib in question. So we see module FOO needs ppx.exe, which depends on ppx_bench, which depends on ppx_inline_test.

We currently do not have this capability. To add it we would need a library, but if we used an ocaml lib we would have a bootstrapping problem. We do not want @obazl//convert to depend on an ocaml toolchain.

Ooops, spoke too soon. ppx_bench.opam does list ppx_inline_test in its depends: clause. So maybe we can address this by adding opam file parsing to the converter.

Another alternative is to inspect the dune-package file that gets added to the pkg directory in the switch. For ppx_bench it contains:

(library
 (name ppx_bench)
 (kind ppx_rewriter)
 (archives (byte ppx_bench.cma) (native ppx_bench.cmxa))
 (plugins (byte ppx_bench.cma) (native ppx_bench.cmxs))
 (native_archives ppx_bench.a)
 (requires ppxlib.ast ppxlib ppx_inline_test.libname)
 (ppx_runtime_deps ppx_bench.runtime-lib)
...

verify opam is installed

the coswitch cmd uses posix_spawn to run some opam cmds. Add code to verify the opam cmd is available first, and issue a helpful msg if not.

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.