Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCaml script for bootstrap build #14

Closed
wants to merge 21 commits into from

Conversation

nshibano
Copy link

This patch adds one new OCaml script for bootstrap build, boot.ml.

Following command performs bootstrap build:
$ ocaml boot.ml

This bootstrap script has several good points:

  • It is straightforward
  • It depends on just only OCaml. So it works on any platform that OCaml is available
  • Easy to maintain. Re-generation or learning other Make/Shell language is not required. We can focus on OCaml and OMake
  • No dependency on working OMake(for re-generation)

Comments and suggestions are welcome!

@gerdstolpmann
Copy link
Collaborator

I'm not completely opposed to using ocaml for bootstrapping, but this script looks hardly maintainable. In particular there is no dependency management, so far any bigger change we would have to figure out the deps manually again. (Note that boot/Makefile is generated.)

Also, there is no easy to way to change configurations on the fly.

I'm proposing something different: The Makefile format is easy enough to parse, even with Str. Why don't we provide a simple "make" script for Windows that does the dependency management, and substitutes the variables? I guess this could be a implemented with around the same number of lines (when done in a clever way and w/o any optimizations). Some years ago I implemented a make utility with a lot of bells and whistles (https://godirepo.camlcity.org/svn/godi-bootstrap/godi-tools/trunk/console-src/godi-pkg/godi_make.ml), and this took 4500 lines, but a simple version without DSL would need only a fraction of that.

I mean we mainly need something that:

  • parses variable assignments
  • parses variable occurrences and (recursively) substitutes variables
  • gathers up the deps and commands
  • runs through the deps tree and executes the commands
  • provides a command-line interface with Arg.parse

That cannot be that much.

@nshibano
Copy link
Author

Thank you for reviewing my PR.

My motivation to implement this boot script was that I need something work today to build OMake from source on Windows. More advanced solution for bootstrapping would be great. But it is not provided at this point. And we can do such smart thing in OMake, I think.

At least merging this script breaks nothing. This can be exist in source tree in parallel with other way for boot. Please let me know merging this can cause any trouble. I welcome this one is replaced with more advanced one in the future.

In my understanding, changing configuration is not needed for boot because we do configured build using omake-boot.exe later. Please correct me if that was wrong.

I thought this is maintainable because it was easy to create from scratch, and easy to adapt to Cygwin and Linux (I have tested in Windows, Cygwin, and Debian Linux). I created this using command log generated by Make running on Linux. But this is only my point of view. The real test about maintainability is that it will be maintained or not by users. If this script will be deprecated or unmaintained, we can remove this at that time. (Or, just leave unmaintained.)

Thanks for your link to godi_make.ml. It is interesting but also too advanced to me. I can't comment about it today because I need take time to learn from it.

@gerdstolpmann
Copy link
Collaborator

Find in the branch "homemade" a little utility I wrote today, make.ml. So far the following works: Under Linux:

ocaml make.ml -C boot omake

successfully bootstraps omake without using GNU make. For doing the same under Windows, a couple of things are still missing:

  • We need some emulations for cp, rm, ln, echo
  • The file boot/Makefile initializes the variables for Unix. A few things need to be changed for Windows, e.g. slash=. These settings could be read in from another file, say config.mk
  • We need an ocaml script creating config.mk

But anyway, this is pretty close already.

@nshibano
Copy link
Author

nshibano commented Mar 7, 2016

Great job! It is still too advanced to me but looks much simpler than previous one. I am reading this now.

@rgrinberg
Copy link
Collaborator

Just an FYI, this issue has real world consequence for some users:

ocaml-cross/opam-cross-windows#2

@gerdstolpmann
Copy link
Collaborator

We picked up the general idea, but implemented it differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants