jordwalke / jordwalke/CommonML

Generate build script/Makefile that doesn't depend on node.

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
96
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Most of the commands for building a project with `CommonML` are recorded into a simple list that can be dumped to a make file and executed without node.

There's only a couple of parts of `CommonML` that makes this difficult:
- We currently discover the location of dependencies by executing a `findlib` command during the build process that uses `execSync` on the fly to get the exact location on the machine for certain libraries. Instead, you could imagine dumping to an environment variable in the script such as:

```
$LOC_OF_MY_DEPENDENCY=`findlib blah blah`
ocamlc $LOC_OF_MY_DEPENDENCY/path/to/blah.cmo -o blah.exe
```

That would work because it doesn't require that the `build.js` actually ever receive the result of the `findlib` command.
- `build.js` is geared towards local development so it assumes other `CommonML` dependencies are pulled down to a specific location `node_modules`. If distributing to `opam` (which is the primary use case for generating a node-free build script/Makefile), you don't even recompile your dependencies. In that case, you'd want the ability to have `build.js` have a special mode that doesn't search for dependencies' source in `node_modules` and doesn't recompile them, instead it needs to do something else to find the generated libraries/artifacts and their locations. If `build.js` just supported this mode regardless of if you're generating a node-free Makefile, then there's nothing special we'd have to do to support Makefile generation. Think of this mode as "promoting" your `dependencies` field to `findLibDependencies`.

If these could be fixed, then it would be much easier to generate a `Makefile` that does not rely at all on node. That means you could use `CommonML` for development, but then publish to `opam` a version of your package that can work regardless of if the client has node installed. (You would also need to generate a separate `opam` `instal` file, `opam` file and a bunch of other stuff, but that's fairly easy.).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading build.js and the code that records build commands and dumps them to a Makefile. Trace the findlib execSync dependency lookup and the handling of dependencies from node_modules, then compare those paths with the opam publishing use case. Done means a generated Makefile can build without Node and can use installed dependency artifacts rather than recompiling source dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, ocaml
Domain
build-system, release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.