piston/packages/CONTRIBUTING.MD

62 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2021-02-20 06:37:55 +01:00
# Contributing packages to the Piston Repository
## Naming Languages
2021-02-27 06:28:08 +01:00
Languages should be named after their interpreters, and the command line binaries you call.
For example, the full name of the standard python interpreter is `CPython`, however we would name it `python`, after the main binary which it provides.
In the example of NodeJS, we would call this `node`, after the main binary.
2021-02-27 06:28:08 +01:00
2021-02-20 06:37:55 +01:00
## Creating new languages
2021-03-13 07:50:05 +01:00
See [deno/1.7.5/](deno/1.7.5/) or any other directory for examples.
2021-02-27 06:28:08 +01:00
1. Create a new branch on your fork of engineer-man/piston
2021-03-13 07:50:05 +01:00
2. Create directories named `[language]/[version]`. See Naming Languages for how to determine the name for your language
2021-02-20 06:37:55 +01:00
3. Create a file named `build.sh`, adding a shebang for bash `#!/bin/bash` on the first line.
In this file put any steps to compile the specified langauge.
This script should download sources, compile sources and output binaries. They should be dumped into the current working directory, removing any files which aren't required in the process.
2021-02-20 06:37:55 +01:00
4. Create a file named `run`, containing bash script to run the interpreter.
The first argument given to this script (`$1`) is the name of the main file, with the remaining ones as program arguments.
STDIN is piped directly into the run file, and as such nothing special is required to deal with STDIN, except leaving it open.
2021-02-20 06:37:55 +01:00
5. Create a file named `compile`, containing bash script to compile sources into binaries. This is only required if the language requires a compling stage.
The first argument is always the main file, followed the names of the other files as additional arguements. If the language does not require a compile stage, don't create a compile file.
2021-02-20 06:37:55 +01:00
6. Create a file named `environment`, containing `export` statements which edit the environment variables accordingly. The `$PWD` variable should be used, and is set inside the package directory when running on the target system.
2021-02-20 06:37:55 +01:00
7. Create a test script starting with test, with the file extension of the language. This script should simply output the phrase `OK`. For example, for mono we would create `test.cs` with the content:
```cs
using System;
public class Test
{
public static void Main(string[] args)
{
Console.WriteLine("OK");
}
}
```
8. Create a `metadata.json` file which contains metadata about the language and interpreter. This simply contains the language name, as in the folder name, the version as in the folder name, the author's name and email address, aliases that can be used to call this package, and finally a dependencies map.
The dependencies map contains the keys as language names, and the values as semver selectors for packages.
```json
{
"language": "deno",
"version": "1.7.5",
"author": "Thomas Hobson <thomas@hexf.me>",
"dependencies": {},
"aliases": ["deno-ts", "deno-js"]
}
```
9. Test your package builds with running `make [language]-[version].pkg.tar.gz`.
If it all goes to plan, you should have a file named `[language]-[version].pkg.tar.gz`, in this case your good to go!
10. Commit your changes, using message format of `pkg([language]-[version]): Added [language] [version]`
Any additional commits regarding this package should start with `pkg([language]-[version]): `
2021-02-27 06:28:18 +01:00
11. Create a pull request (currently to v3 branch), referencing an Issue number (if there is one associated).