rules_ocaml icon indicating copy to clipboard operation
rules_ocaml copied to clipboard

Documentation for basic OCaml project

Open tmcgilchrist opened this issue 1 year ago • 10 comments

As a new user of Bazel it would be extremely helpful to have an example of how to build a plain OCaml project using rules_ocaml. Similar to how https://bazel.build/start/java shows building a basic Java project. Using the Java example with a BUILD file of

load("@rules_java//java:defs.bzl", "java_binary", "java_library")

package(default_visibility = ["//visibility:public"])

java_library(
    name = "project",
    srcs = glob(["com/project/*.java"]),
)

java_binary(
    name = "project-repl",
    srcs = glob(["com/project/Repl.java"]),
    main_class = "com.project.Repl",
    deps = [":project"]
)

I was able to get some Java code compiling with minimal knowledge of Bazel.
How can I achieve something similar with rules_ocaml?

The blog post on https://www.tweag.io/blog/2021-07-01-obazl/ describes a more complicated build setup which might also be out of date since it's from 2021. The OBazl Book has lots of documentation but is not clear what the basics pieces are I would need. Thanks in advance for the work on this project, I'm looking forward to using it.

tmcgilchrist avatar May 08 '24 01:05 tmcgilchrist

Hi Tim!

Thanks for posting this issue. FYI, after several years working on the OCaml bazel stuff I hit the burnout wall a few months ago. Not a whole lot of demand for it, so ...

But now I have an incentive! Oh boy! Seriously, I do have a bunch of stuff that makes life easier, I just have to kick myself in the butt to make it usable to others, which includes documentation. So I'll plan to resume development activity asap, probably this weekend. With luck I'll have something useful to say within a week or two...

Cheers,

Gregg

sibawayhi avatar May 09 '24 01:05 sibawayhi

On Wed, May 8, 2024 at 8:20 PM Gregg Reynolds @.***> wrote:

Hi Tim!

Thanks for posting this issue. FYI, after several years working on the OCaml bazel stuff I hit the burnout wall a few months ago. Not a whole lot of demand for it, so ...

But now I have an incentive! Oh boy! Seriously, I do have a bunch of stuff that makes life easier, I just have to kick myself in the butt to make it usable to others, which includes documentation. So I'll plan to resume development activity asap, probably this weekend. With luck I'll have something useful to say within a week or two...

Cheers,

Gregg ?

PS. In the meantime, have you looked at https://github.com/obazl/demos_obazl/tree/main/rules_ocaml ?

Also, this is the magic bullet: https://github.com/obazl/coswitch which sadly lacks the documentation.

— Reply to this email directly, view it on GitHub https://github.com/obazl/rules_ocaml/issues/52#issuecomment-2101754136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES2NBBNWO5PVOURRNPQ23ZBLFOXAVCNFSM6AAAAABHMAPU66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBRG42TIMJTGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mobileink avatar May 09 '24 01:05 mobileink

I have looked at both of those projects. I'm new to Bazel and it's likely I'm missing the key configuration (aka holding it wrong).

What I initially want is something like this or even simpler like so:

load(
    "@rules_ocaml//build:rules.bzl",
    "ocaml_binary",
    "ocaml_module",
)

ocaml_binary(
    name = "hello",
    main = ":Main",
)

ocaml_module(
    name = "Main",
    struct = "main.ml",
    deps = [":Hello"],
)

from which I get an error

 Unable to find package for @@[unknown repo 'rules_ocaml' requested from @@]//build:rules.bzl: The repository '@@[unknown repo 'rules_ocaml' requested from @@]' could not be resolved: No repository visible as '@rules_ocaml' from main repository.

It seems like I need to install those rules somewhere?

tmcgilchrist avatar May 09 '24 01:05 tmcgilchrist

Yep, sorry, that's a documentation problem. I'll get something written this weekend.

On Wed, May 8, 2024 at 8:40 PM Tim McGilchrist @.***> wrote:

I have looked at both of those projects. I'm new to Bazel and it's likely I'm missing the key configuration (aka holding it wrong).

What I initially want is something like this https://github.com/obazl/demos_obazl/blob/main/rules_ocaml/executables/ocaml_executable/BUILD.bazel or even simpler like so:

load( @.***_ocaml//build:rules.bzl", "ocaml_binary", "ocaml_module", )

ocaml_binary( name = "hello", main = ":Main", )

ocaml_module( name = "Main", struct = "main.ml", deps = [":Hello"], )

from which I get an error

Unable to find package for @@[unknown repo 'rules_ocaml' requested from @@]//build:rules.bzl: The repository '@@[unknown repo 'rules_ocaml' requested from @@]' could not be resolved: No repository visible as @.***_ocaml' from main repository.

It seems like I need to install those rules somewhere?

— Reply to this email directly, view it on GitHub https://github.com/obazl/rules_ocaml/issues/52#issuecomment-2101774598, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES2NANXCCKWACZUPOGJBLZBLHZDAVCNFSM6AAAAABHMAPU66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBRG43TINJZHA . You are receiving this because you commented.Message ID: @.***>

mobileink avatar May 09 '24 02:05 mobileink

working on it...

mobileink avatar May 19 '24 18:05 mobileink

@mobileink have you been able to work on this?

tmcgilchrist avatar Sep 10 '24 09:09 tmcgilchrist

@mobileink have you been able to work on this?

Deepest apologies. I guess I was more burned out than I realized - got started on other stuff and completely forgot about this.

Looking at it now. Might take a few days to get back into the swing of things though.

Again, very sorry I dropped the ball on this.

mobileink avatar Sep 11 '24 14:09 mobileink

All good mate, get in touch if I can help out with it.

tmcgilchrist avatar Sep 13 '24 01:09 tmcgilchrist