obazl / rules_ocaml

A Bazel Language Support Package for OCaml
https://obazl.github.io/docs_obazl
Apache License 2.0
32 stars 7 forks source link

Documentation for basic OCaml project #52

Open tmcgilchrist opened 6 months ago

tmcgilchrist commented 6 months ago

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.

sibawayhi commented 6 months ago

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

mobileink commented 6 months ago

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: @.***>

tmcgilchrist commented 6 months ago

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?

mobileink commented 6 months ago

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 commented 5 months ago

working on it...

tmcgilchrist commented 2 months ago

@mobileink have you been able to work on this?

mobileink commented 1 month ago

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

tmcgilchrist commented 1 month ago

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