summaryrefslogtreecommitdiff
path: root/project2/ice/iceCompile.h
blob: 5e6873ab679005911f3a7acc1755923517662635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef ICECOMPILE_H
#define ICECOMPILE_H

#include "options.h"
#include <string>
#include <boost/filesystem/path.hpp>
#include <boost/optional.hpp>

class IceCompile {
	public:
		INITOPTIONS;

		typedef boost::shared_ptr<IceCompile> Ptr;
		typedef boost::shared_ptr<const IceCompile> CPtr;
		typedef std::vector<CPtr> Deps;

		static std::string slice2cpp;
		static std::string slicer;
		static std::string cxx;
		static std::string linker;
		static std::string cxxopts;
		static std::string linkeropts;
		static boost::filesystem::path tmpdir;
		static boost::filesystem::path headerdir;
		static boost::filesystem::path slicerheaderdir;
		
		IceCompile(const boost::filesystem::path & slice);
		IceCompile(const boost::filesystem::path & slice, const Deps & deps);
		virtual ~IceCompile();

		enum Steps {
			UpdateBuild = 0x1,
			UpdateCompile = 0x2,
			UpdateLink = 0x4,
		};
		/// Conditionally execute Build, Compile, Link as required
		void Update(int steps = UpdateBuild | UpdateCompile | UpdateLink) const;
		/// Source file path (e.g. /some/path/slice.ice)
		virtual boost::filesystem::path InputPath() const = 0;
		/// File name (no extension) in temporary directory (e.g. clientSlice)
		virtual boost::filesystem::path OutputName(const std::string & type) const = 0;

		typedef boost::shared_ptr<void> LibHandle;
		LibHandle Open() const;

	protected:
		virtual void Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const = 0;
		void Compile(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
		void Link(const boost::filesystem::path & in, const boost::filesystem::path & out) const;

		typedef void (IceCompile::*UpdateFunc)(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
		void update(const boost::filesystem::path & in, const boost::filesystem::path & out, UpdateFunc func) const;

		const boost::filesystem::path slice;

	private:
		const Deps deps;
};

#endif