mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 14:04:04 -05:00
2.6 KiB
2.6 KiB
Adding a new language
-
Add a
etc/config/language.defaults.propertiesfile -
Add a
etc/config/language.local.propertiesfile with the first compiler- make sure the path is correct, and during launch of CE (
make dev) check to see if CE agrees with you - test the command line options of the language compilers outside of CE
- make sure the path is correct, and during launch of CE (
-
Add language to
lib/languages.js- if you use a built-in monaco language you must also add it to the list of languages inside the
MonacoEditorWebpackPluginconfig inwebpack.config.js - if you don't use a built-in monaco language you will need to implement your own language mode; see
static/modes/asm-mode.jsas an example
- if you use a built-in monaco language you must also add it to the list of languages inside the
-
Add a
lib/compilers/language.jsfile using the template below, replacingLanguageandlanguageas appropriateimport { BaseCompiler } from '../base-compiler'; export class LanguageCompiler extends BaseCompiler { static get key() { return 'language'; } }- the value returned by
keyabove corresponds to thecompilerTypevalue inetc/config/language.defaults.properties - implement the
OptionsForFiltermethod - comment out the line saying
fs.remove(result.dirPath);in base-compiler.js, so the latest CE compile attempt remains on disk for you to review- remember to undo this change before opening a PR
- for reference, the basic behaviour of the BaseCompiler is:
- make a random temporary folder
- save example.extension to the new folder, the full path to this is the inputFilename
- the outputFilename is determined by the
getOutputFilename()method - execute the compiler.exe with the arguments from
OptionsForFilter()and adding inputFilename - be aware that the the language class is only instanced once, so storing state is not possible
- if the compiler has problems with the defaults, you will have to override the
runCompiler()method - when overriding
runCompiler(), here are some ideas:- set execOptions.customCwd parameter if the working directory needs to be somewhere else
- set execOptions.env parameter if the compiler requires special environment variables
- manipulate options, but make sure the user can still add their own arguments in CE
- test with node app.js --debug so you see all execution arguments
- the value returned by
-
Add your
LanguageCompilertolib/compilers/_all.js, in alphabetical order -
Add
static/modes/language-mode.jsand require it instatic/panes/editor.js -
You can check http://127.0.0.1:10240/api/compilers to be sure your language and compiler are there
-
Make an installer in the infra repository