forked from EScript/EScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EScript.ekki
132 lines (109 loc) · 4.85 KB
/
EScript.ekki
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* ----------------------------------------------------------------
This file is part of the EkkiEkkiKateng build tool.
Copyright (C) 2013-2014 Claudius Jähn ([email protected])
Licensed under the MIT License. See LICENSE file for details.
https://github.com/ClaudiusJ/EkkiEkkiKateng
---------------------------------------------------------------- */
Runtime.setLoggingLevel(Runtime.LOG_PEDANTIC_WARNING);
outln("-"*79);
outln("This script creates a CodeBlocks project file for EScript using EkkiEkkiKateng.");
outln("EScript version: ",EScript.VERSION_STRING);
outln("CodeBlocks: http://www.codeblocks.org");
outln("EkkiEkkiKateng: https://github.com/ClaudiusJ/EkkiEkkiKateng");
outln("-"*79);
// ------
outln("Loading EScript Std library...");
assert(EScript.VERSION >= 701, "wrong EScript version (requires >=701)");
static module = load( IO.dirname(args[0])+ "/Std/module.escript"); // load Std lib module loader (relative to EScript executable)
module.addSearchPath( IO.dirname(args[0]) ); // search path for Std lib
module.addSearchPath( IO.condensePath(IO.dirname(args[0])+"\\..") ); // search path for EkkiEkkiKateng
// ------
outln("Loading EkkiEkkiKateng...");
outln("EkkiEkkiKateng Version: ",module('EkkiEkkiKateng/Version') );
assert(module('EkkiEkkiKateng/Version') >= 0.2,"wrong EkkiEkkiKateng version (requires>0.2)");
var Node = module('EkkiEkkiKateng/Node');
var FileUtils = module('EkkiEkkiKateng/FileUtils');
var CompilerOptions = module('EkkiEkkiKateng/CompilerOptions');
var LinkerOptions = module('EkkiEkkiKateng/LinkerOptions');
var Projects = module('EkkiEkkiKateng/Projects');
var Files = module('EkkiEkkiKateng/Files');
var Targets = module('EkkiEkkiKateng/Targets');
var VirtualTargets = module('EkkiEkkiKateng/VirtualTargets');
// ------
var configFileName = __FILE__.substr(0,__FILE__.rFind("."))+".ekki.txt";
outln("Creating/loading config file '",configFileName,"'...");
var config = new (module('Std/JSONDataStore'))(true);
config.init( configFileName, false);
static folder_base = config.get('Project.Folders.base', IO.condensePath( (__DIR__).replaceAll('\\','/') ));
// ------
outln("Creating project graph...");
var project = Projects.createNode( config.get('Project.name',"EScript") );
CompilerOptions.setCompilerId( project, config.get('Project.compilerId',"gcc") );
CompilerOptions.addOptions( project, config.get('Project.compilerOptions',[
"-std=c++11",
"-pedantic","-Wall","-Wextra","-Wshadow","-Wcast-qual","-Wcast-align","-Wlogical-op",
"-Wredundant-decls","-Wdisabled-optimization","-Wstack-protector","-Winit-self","-Wmissing-include-dirs",
"-Wswitch-default","-Wswitch-enum","-Wctor-dtor-privacy","-Wstrict-null-sentinel","-Wno-non-template-friend",
"-Wold-style-cast","-Woverloaded-virtual","-Wno-pmf-conversions","-Wsign-promo","-Wmissing-declarations"
]));
var allFiles = new Node;
foreach(FileUtils.scanFiles( folder_base,
config.get('Project.includeFiles',[".cpp",".h",".escript",".txt",".rc",".ekki"] ) ) as var filename){
if(!filename.contains('- Kopie'))
allFiles += Files.createNode(filename);
}
foreach( config.get('Project.targets',{
'Application' : {
'type' : 'CONSOLE_APP',
'output' : "EScript",
'objectFolder' : ".obj/app",
'compilerOptions' : [ "-g","-O3","-DES_BUILD_APPLICATION" ],
'linkerOptions' : ["-s"]
},
'Tests' : {
'type' : 'CONSOLE_APP',
'output' : "EScriptTest",
'objectFolder' : ".obj/test",
'compilerOptions' : [ "-g","-O3","-DES_BUILD_TEST_APPLICATION" ],
'linkerOptions' : []
},
'StaticLib' : {
'type' : 'STATIC_LIB',
'output' : "EScriptTest",
'objectFolder' : ".obj/test",
'compilerOptions' : [ "-g","-O3" ],
'linkerOptions' : []
}
}) as var targetName, var targetDescription){
var targetNode = Targets.createNode( targetName );
switch( targetDescription['type'] ){
case 'CONSOLE_APP':
Targets.setType_ConsoleApp( targetNode );
break;
case 'STATIC_LIB':
Targets.setType_StaticLib( targetNode );
break;
default:
Runtime.exception("Invalid target type: "+targetDescription['type']);
}
Targets.setOutput( targetNode, targetDescription['output'] );
Targets.setObjectFolder( targetNode, targetDescription['objectFolder']);
CompilerOptions.addOptions(targetNode, targetDescription['compilerOptions']);
LinkerOptions.addOptions(targetNode, targetDescription['linkerOptions']);
targetNode += allFiles;
project += targetNode;
}
{
var vTarget = VirtualTargets.createNode("All");
foreach( Targets.collect( project ) as var target)
vTarget += target;
project += vTarget;
// outln( vTarget.toDbgString() );
}
// ------
var projectFileName = config.get('Project.projectFile',"EScript.cbp");
outln("Exporting CodeBlocks project '",projectFileName,"'...");
var generator = module('EkkiEkkiKateng/CodeBlocksGenerator');
IO.saveTextFile(projectFileName, generator.createProject( project ));
//print_r(project.toDbgString());
return true;