aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/ocaml.js
diff options
context:
space:
mode:
authorHaz <hyphens@pm.me>2021-09-03 05:51:15 +0200
committerGitHub <noreply@github.com>2021-09-03 05:51:15 +0200
commitb3628b2c31a1af4d303f1f44ff964a42119d2cd4 (patch)
tree7be9c7c699b936d15941cb5cead0a35afb992e39 /lib/compilers/ocaml.js
parent6a1dbe14f75eeebde0d658e455728d3910bb711a (diff)
downloadcompiler-explorer-b3628b2c31a1af4d303f1f44ff964a42119d2cd4.tar.gz
compiler-explorer-b3628b2c31a1af4d303f1f44ff964a42119d2cd4.zip
OCaml Improvements: objdump and a few refactorings (#2913)
* OCaml properties fixes - Improve defaults by adding local and system versions - Make no assumptions about whether local and system are the same - Enable OPAM workflows which rely on updating PATH - Fix version flag - Fix objdumper * OCaml output refactoring * Add an arg parser for OCaml Derived from Pascal (for now) * Rename default OCaml compiler ids * Add alias of old OCaml default compiler id Co-authored-by: Rubén Rincón Blanco <ruben@rinconblanco.es>
Diffstat (limited to 'lib/compilers/ocaml.js')
-rw-r--r--lib/compilers/ocaml.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/compilers/ocaml.js b/lib/compilers/ocaml.js
index 46b396773..1bbd9a6cf 100644
--- a/lib/compilers/ocaml.js
+++ b/lib/compilers/ocaml.js
@@ -22,35 +22,37 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-import path from 'path';
-
import { BaseCompiler } from '../base-compiler';
+import { PascalParser } from './argument-parsers';
+
export class OCamlCompiler extends BaseCompiler {
static get key() { return 'ocaml'; }
+ constructor(compilerInfo, env) {
+ super(compilerInfo, env);
+ // override output base because ocaml's -S -o has different semantics.
+ // namely, it outputs a full binary exe to the supposed asm dump.
+ // with this override and optionsForFilter override, that pecularity..
+ // ..is bypassed entirely.
+ this.outputFilebase = 'example';
+ }
+
getSharedLibraryPathsAsArguments() {
return [];
}
optionsForFilter(filters, outputFileName) {
- let options = ['-g', '-S'];
+ const options = ['-g'];
if (filters.binary) {
- options = options.concat('-o', this.filename(outputFileName));
+ options.unshift('-o', outputFileName);
} else {
- options = options.concat('-c');
+ options.unshift('-S', '-c');
}
return options;
}
- getOutputFilename(dirPath, outputFilebase, key) {
- const filename = key.backendOptions.customOutputFilename ||
- `${path.basename(this.compileFilename, this.lang.extensions[0])}.s`;
- return path.join(dirPath, filename);
- }
-
- getExecutableFilename(dirPath, outputFilebase, key) {
- const filename = key.backendOptions.customOutputFilename || outputFilebase;
- return path.join(dirPath, filename);
+ getArgumentParser() {
+ return PascalParser;
}
}