aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2024-02-28 16:38:03 +0100
committerGitHub <noreply@github.com>2024-02-28 16:38:03 +0100
commit8e6c90d1370e051d18eeb7f705527d3d97a6cd1c (patch)
treea90e6cc8b90c8037bf0cc494647d90be80d2f812 /lib/compilers
parent02d2194004410879bf41fd32bf117b0df02a1d88 (diff)
downloadcompiler-explorer-8e6c90d1370e051d18eeb7f705527d3d97a6cd1c.tar.gz
compiler-explorer-8e6c90d1370e051d18eeb7f705527d3d97a6cd1c.zip
pythran: initial support (#6197)gh-10807
Pythran is a python to c++ transpiler. Our supports both the C++ and the full link to a share library (a python module). See https://pypi.org/project/pythran/ for more information. fixes #6079 Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'lib/compilers')
-rw-r--r--lib/compilers/_all.ts1
-rw-r--r--lib/compilers/pythran.ts46
2 files changed, 47 insertions, 0 deletions
diff --git a/lib/compilers/_all.ts b/lib/compilers/_all.ts
index 02d497572..0e1dbb2aa 100644
--- a/lib/compilers/_all.ts
+++ b/lib/compilers/_all.ts
@@ -103,6 +103,7 @@ export {PonyCompiler} from './pony.js';
export {PPCICompiler} from './ppci.js';
export {PtxAssembler} from './ptxas.js';
export {PythonCompiler} from './python.js';
+export {PythranCompiler} from './pythran.js';
export {RacketCompiler} from './racket.js';
export {RGACompiler} from './rga.js';
export {RubyCompiler} from './ruby.js';
diff --git a/lib/compilers/pythran.ts b/lib/compilers/pythran.ts
new file mode 100644
index 000000000..33fb7d981
--- /dev/null
+++ b/lib/compilers/pythran.ts
@@ -0,0 +1,46 @@
+import path from 'path';
+import {BaseCompiler} from '../base-compiler.js';
+import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
+import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+
+export class PythranCompiler extends BaseCompiler {
+ static get key() {
+ return 'pythran';
+ }
+
+ cpp_compiler_root: string;
+
+ constructor(info: PreliminaryCompilerInfo, env) {
+ super(info, env);
+ this.cpp_compiler_root = this.compilerProps<string>(`compiler.${this.compiler.id}.cpp_compiler_root`);
+ }
+
+ override getDefaultExecOptions() {
+ const execOptions = super.getDefaultExecOptions();
+ if (this.cpp_compiler_root) {
+ execOptions.env.PATH = path.join(this.cpp_compiler_root, 'bin');
+ const ld_library_path = [
+ path.join(this.cpp_compiler_root, 'lib'),
+ path.join(this.cpp_compiler_root, 'lib64'),
+ ];
+ execOptions.env.LD_LIBRARY_PATH = ld_library_path.join(':');
+ }
+
+ return execOptions;
+ }
+
+ override optionsForFilter(
+ filters: ParseFiltersAndOutputOptions,
+ outputFilename: string,
+ userOptions?: string[],
+ ): string[] {
+ let options = ['-o', this.filename(outputFilename)];
+ if (!filters.binary && !filters.binaryObject) options = options.concat('-E');
+ return options;
+ }
+
+ override getCompilerResultLanguageId(filters?: ParseFiltersAndOutputOptions): string | undefined {
+ if (typeof filters !== 'undefined' && filters.binary) return 'asm';
+ else return 'cppp';
+ }
+}