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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/**
* \file session.h
* \brief Context for a program execution session.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*
* \defgroup session Session
*
* Premake is essentially a long chain of sequential actions; the Session object
* tracks the application state through this chain, and provides the context
* necessary for actions to do their work. It's a glorified global, essentially.
*
* @{
*/
#if !defined(PREMAKE_SESSION_H)
#define PREMAKE_SESSION_H
#include "base/stream.h"
#include "project/solution.h"
#include "project/project.h"
#include "project/block.h"
DECLARE_CLASS(Session)
/**
* Callback signature for Premake action handlers, which will get triggered
* if user specifies that action on the command line for processing.
* \param sess The current execution session context.
* \returns OKAY If successful.
*/
typedef int (*SessionActionCallback)(Session sess);
/**
* Per-solution object callback signature for session_enumerate_objects(). The
* solution callback will be called once for each solution in the session.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream(). May be NULL.
* \returns OKAY if successful.
*/
typedef int (*SessionSolutionCallback)(Session sess, Solution sln, Stream strm);
/**
* Per-project object callback signature for session_enumerate_objects(). The
* project callback will be called once for each solution in the session.
* \param sess The execution session context.
* \param prj The current project.
* \param strm The currently active stream; set with session_set_active_stream(). May be NULL.
* \returns OKAY if successful.
*/
typedef int (*SessionProjectCallback)(Session sess, Project prj, Stream strm);
/**
* Describe a Premake action, including the handler function and the metadata
* required to list it in the user help.
*/
typedef struct struct_SessionAction
{
const char* name;
const char* description;
SessionActionCallback callback;
} SessionAction;
/**
* Describe the features (languages, project kinds, etc.) supported by an action. Used by
* session_validate() to ensure that action handler functions only get called with data
* that they can handle.
*/
typedef struct struct_SessionFeatures
{
const char* languages[64];
} SessionFeatures;
Session session_create(void);
void session_destroy(Session sess);
void session_add_solution(Session sess, Solution sln);
int session_enumerate_configurations(Session sess, Project prj, Stream strm);
int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs, SessionProjectCallback* cfg_funcs);
const char* session_get_action(Session sess);
Stream session_get_active_stream(Session sess);
Solution session_get_solution(Session sess, int index);
int session_num_solutions(Session sess);
const char* session_run_file(Session sess, const char* filename);
const char* session_run_string(Session sess, const char* code);
void session_set_action(Session sess, const char* action);
void session_set_active_stream(Session sess, Stream strm);
int session_tests(void);
int session_unload(Session sess);
int session_validate(Session sess, SessionFeatures* features);
#endif
/** @} */
|