AmpGen 2.1
Loading...
Searching...
No Matches
CompilerWrapper.h
Go to the documentation of this file.
1#ifndef AMPGEN_COMPILERWRAPPER_H
2#define AMPGEN_COMPILERWRAPPER_H
3
4#include <stdlib.h>
5#include <fstream>
6#include <iostream>
7#include <string>
8#include <vector>
9#include <map>
10#include "AmpGen/Property.h"
11#include "AmpGen/Configurable.h"
12
13namespace AmpGen {
15 std::string get_cpp_version();
16
17 class CompilerWrapper : public Configurable<CompilerWrapper> {
18 public:
19 explicit CompilerWrapper();
20 virtual ~CompilerWrapper() = default;
21 void generateSource(const CompiledExpressionBase &expression, const std::string &fname);
22 bool compile(CompiledExpressionBase &expression, const std::string &fname = "");
23 bool compile(std::vector<CompiledExpressionBase *> &expression, const std::string &fname = "",
24 const std::map<std::string, std::string> &metadata_functions = {});
25 void compileSource(const std::string &fname, const std::string &oname);
26 void preamble(std::ostream &os) const;
27 void addHeader(const std::string &include) { m_includes.push_back(include); }
28 void addPythonBindings() { m_includePythonBindings = true; }
29
30 private:
31 using strings = std::vector<std::string>;
32 std::vector<std::string> m_includes = {"complex", "cmath", "vector"};
33 bool m_includePythonBindings{true};
34 std::string m_cxx;
35 std::string generateFilename();
36 bool isClang() const;
37 std::string m_extension{"so"};
38 Property<strings> m_compileFlags{this, "CompilerWrapper::Flags", {"-Ofast", "--std=" + get_cpp_version()}};
39 Property<bool> m_forceRebuild{this, "CompilerWrapper::ForceRebuild", false};
40 Property<bool> m_disable{this, "CompilerWrapper::Disable", false};
41 };
42} // namespace AmpGen
43#endif
Base class for compiled expressions, i.e.
bool compile(CompiledExpressionBase &expression, const std::string &fname="")
bool compile(std::vector< CompiledExpressionBase * > &expression, const std::string &fname="", const std::map< std::string, std::string > &metadata_functions={})
void compileSource(const std::string &fname, const std::string &oname)
void generateSource(const CompiledExpressionBase &expression, const std::string &fname)
void addHeader(const std::string &include)
void preamble(std::ostream &os) const
virtual ~CompilerWrapper()=default
std::string get_cpp_version()