diff --git a/README.md b/README.md index cd88759cc..1c02e9270 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,9 @@ important you can quickly and easily get running. Currently, **Compiler Explorer Running with `make EXTRA_ARGS='--language LANG'` will allow you to load `LANG` exclusively, where `LANG` is one for the language ids/aliases defined in `lib/languages.ts`. For example, to only run **Compiler Explorer** with C++ support, -you'd run `make EXTRA_ARGS='--language c++'`. The `Makefile` will automatically install all the third-party libraries -needed to run; using `npm` to install server-side and client-side components. +you'd run `make EXTRA_ARGS='--language c++'`. You can supply multiple `--language` arguments to restrict to more than +one language. The `Makefile` will automatically install all the third-party libraries needed to run; using `npm` to +install server-side and client-side components. For development, we suggest using `make dev` to enable some useful features, such as automatic reloading on file changes and shorter startup times. diff --git a/app.ts b/app.ts index 3e1543c94..b341934f5 100755 --- a/app.ts +++ b/app.ts @@ -100,7 +100,7 @@ export type CompilerExplorerOptions = Partial<{ noRemoteFetch: boolean; tmpDir: string; wsl: boolean; - language: string; + language: string[]; noCache: boolean; ensureNoIdClash: boolean; logHost: string; @@ -131,7 +131,7 @@ const opts = nopt({ tmpDir: [String], wsl: [Boolean], // If specified, only loads the specified languages, resulting in faster loadup/iteration times - language: [String], + language: [String, Array], // Do not use caching for compilation results (Requests might still be cached by the client's browser) noCache: [Boolean], // Don't cleanly run if two or more compilers have clashing ids @@ -218,13 +218,22 @@ export type AppDefaultArguments = { port: number; gitReleaseName: string; releaseBuildNumber: string; - wantedLanguages: string | null; + wantedLanguages: string[] | null; doCache: boolean; fetchCompilersFromRemote: boolean; ensureNoCompilerClash: boolean | undefined; suppressConsoleLog: boolean; }; +function patchUpLanguageArg(languages: string[] | undefined): string[] | null { + if (!languages) return null; + if (languages.length === 1) { + // Support old style comma-separated language args. + return languages[0].split(','); + } + return languages; +} + // Set default values for omitted arguments const defArgs: AppDefaultArguments = { rootDir: opts.rootDir || './etc', @@ -233,7 +242,7 @@ const defArgs: AppDefaultArguments = { port: opts.port || 10240, gitReleaseName: gitReleaseName, releaseBuildNumber: releaseBuildNumber, - wantedLanguages: opts.language || null, + wantedLanguages: patchUpLanguageArg(opts.language), doCache: !opts.noCache, fetchCompilersFromRemote: !opts.noRemoteFetch, ensureNoCompilerClash: opts.ensureNoIdClash, @@ -288,13 +297,15 @@ props.initialize(configDir, propHierarchy); // Instantiate a function to access records concerning "compiler-explorer" // in hidden object props.properties const ceProps = props.propsFor('compiler-explorer'); -defArgs.wantedLanguages = ceProps('restrictToLanguages', defArgs.wantedLanguages); +const restrictToLanguages = ceProps('restrictToLanguages'); +if (restrictToLanguages) { + defArgs.wantedLanguages = restrictToLanguages.split(','); +} const languages = (() => { if (defArgs.wantedLanguages) { const filteredLangs: Partial> = {}; - const passedLangs = defArgs.wantedLanguages.split(','); - for (const wantedLang of passedLangs) { + for (const wantedLang of defArgs.wantedLanguages) { for (const lang of Object.values(allLanguages)) { if (lang.id === wantedLang || lang.name === wantedLang || lang.alias.includes(wantedLang)) { filteredLangs[lang.id] = lang;