CmdBuildOptionsOutput.diff

The diff file to apply for uppsrc directory (Output mode) - Sender Ghost, 12/17/2014 05:22 AM

Download (10.9 KB)

View differences:

uppsrc/ide/ide.lay 2014-12-17 05:47:48 +0400
246 246
END_LAYOUT
247 247

  
248 248
LAYOUT(OutputModeLayout, 616, 480)
249
	ITEM(Label, dv___0, SetLabel(t_("&Build method:")).LeftPosZ(10, 70).TopPosZ(4, 19))
250
	ITEM(DropList, method, LeftPosZ(82, 184).TopPosZ(4, 19))
251
	ITEM(Switch, mode, SetLabel(t_("Debug         \nOptimal\nOptimize speed\nOptimize size")).LeftPosZ(244, 356).TopPosZ(32, 18))
252
	ITEM(LabelBox, dv___3, LeftPosZ(304, 4).TopPosZ(28, 360))
253
	UNTYPED(debug, LeftPosZ(8, 288).TopPosZ(56, 332))
254
	ITEM(LabelBox, dv___5, SetLabel(t_("Release")).LeftPosZ(320, 288).TopPosZ(16, 36))
255
	UNTYPED(release, LeftPosZ(320, 288).TopPosZ(56, 332))
256
	ITEM(LabelBox, dv___7, SetLabel(t_("Export project")).LeftPosZ(8, 600).TopPosZ(392, 48))
257
	ITEM(Label, dv___8, SetLabel(t_("To directory")).LeftPosZ(12, 68).TopPosZ(408, 21))
249
	ITEM(Label, dv___0, SetLabel(t_("Main configuration:")).LeftPosZ(4, 96).TopPosZ(4, 20))
250
	ITEM(DropList, config, LeftPosZ(100, 184).TopPosZ(4, 19))
251
	ITEM(Label, dv___2, SetLabel(t_("&Build method:")).LeftPosZ(288, 70).TopPosZ(4, 19))
252
	ITEM(DropList, method, LeftPosZ(360, 184).TopPosZ(4, 19))
253
	ITEM(Switch, mode, SetLabel(t_("Debug         \nOptimal\nOptimize speed\nOptimize size")).LeftPosZ(244, 356).TopPosZ(40, 18))
254
	ITEM(LabelBox, dv___5, LeftPosZ(304, 4).TopPosZ(28, 360))
255
	UNTYPED(debug, LeftPosZ(8, 288).TopPosZ(64, 324))
256
	ITEM(LabelBox, dv___7, SetLabel(t_("Release")).LeftPosZ(320, 288).TopPosZ(24, 36))
257
	UNTYPED(release, LeftPosZ(320, 288).TopPosZ(64, 324))
258
	ITEM(LabelBox, dv___9, SetLabel(t_("Export project")).LeftPosZ(8, 600).TopPosZ(392, 48))
259
	ITEM(Label, dv___10, SetLabel(t_("To directory")).LeftPosZ(12, 68).TopPosZ(408, 21))
258 260
	ITEM(EditString, export_dir, LeftPosZ(80, 316).TopPosZ(409, 19))
259 261
	ITEM(Button, export_used, SetLabel(t_("Used")).LeftPosZ(400, 64).TopPosZ(407, 24))
260 262
	ITEM(Button, export_all, SetLabel(t_("All")).LeftPosZ(468, 64).TopPosZ(407, 24))
261 263
	ITEM(Button, export_makefile, SetLabel(t_("Makefile")).LeftPosZ(536, 64).TopPosZ(407, 24))
262
	ITEM(Button, reset_blitz, SetLabel(t_("Reset BLITZ ")).LeftPosZ(8, 88).TopPosZ(448, 24))
264
	ITEM(Button, reset_blitz, SetLabel(t_("Reset BLITZ")).LeftPosZ(8, 88).TopPosZ(448, 24))
265
	ITEM(Button, cmd_options, SetLabel(t_("Command line &options..")).LeftPosZ(100, 124).TopPosZ(448, 24))
263 266
	ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(64, 200).TopPosZ(448, 24))
264 267
	ITEM(Button, cancel, SetLabel(t_("Cancel")).HCenterPosZ(64, 268).TopPosZ(448, 24))
265 268
END_LAYOUT
266 269

  
270
LAYOUT(CmdBuildOptionsLayout, 300, 368)
271
	ITEM(DocEdit, cmd, HSizePosZ(4, 4).BottomPosZ(28, 44))
272
	ITEM(Option, rebuild, SetLabel(t_("Rebuild all")).Tip(t_("a")).LeftPosZ(4, 72).TopPosZ(4, 16))
273
	ITEM(Option, blitz, SetLabel(t_("Use BLITZ")).Tip(t_("b")).HSizePosZ(4, 220).TopPosZ(24, 16))
274
	ITEM(Option, msgonfail, SetLabel(t_("If building fails, stop with message box")).Tip(t_("e (not umk compatible)")).LeftPosZ(4, 204).TopPosZ(44, 16))
275
	ITEM(Option, silent, SetLabel(t_("Silent mode")).Tip(t_("l")).LeftPosZ(4, 76).TopPosZ(64, 16))
276
	ITEM(Option, map, SetLabel(t_("Create a map file")).Tip(t_("m")).LeftPosZ(4, 104).TopPosZ(84, 16))
277
	ITEM(Option, shared, SetLabel(t_("Use shared libraries")).Tip(t_("s")).LeftPosZ(4, 112).TopPosZ(104, 16))
278
	ITEM(Option, sharedbuild, SetLabel(t_("Use shared libraries and build as shared libraries")).Tip(t_("S")).LeftPosZ(4, 248).TopPosZ(124, 16))
279
	ITEM(Option, verbose, SetLabel(t_("Be verbose")).Tip(t_("v")).LeftPosZ(4, 76).TopPosZ(144, 16))
280
	ITEM(Option, makefile, SetLabel(t_("Create makefile (to file out)")).Tip(t_("M")).LeftPosZ(4, 152).TopPosZ(164, 16))
281
	ITEM(Option, savetargetdir, SetLabel(t_("Do not delete target directory out when exporting")).Tip(t_("k")).LeftPosZ(4, 256).TopPosZ(184, 16))
282
	ITEM(LabelBox, dv___11, SetLabel(t_("Export project (to directory out): ")).HSizePosZ(4, 4).TopPosZ(204, 40))
283
	ITEM(Switch, exportproject, SetLabel(t_("do not\nexport only files used\nexport all files")).HSizePosZ(8, 8).TopPosZ(216, 24))
284
	ITEM(EditIntSpin, threads, Min(0).Tip(t_("Hn (umk compatible)")).HSizePosZ(252, 4).TopPosZ(248, 19))
285
	ITEM(Label, dv___14, SetLabel(t_("Number of threads used for building (0 - default):")).HSizePosZ(4, 52).TopPosZ(248, 16))
286
	ITEM(EditString, out, HSizePosZ(60, 4).TopPosZ(272, 19))
287
	ITEM(Option, outoption, SetLabel(t_("Output:")).LeftPosZ(4, 52).TopPosZ(272, 20))
288
	ITEM(Button, btnCopy, SetLabel(t_("Copy to clipboard")).RightPosZ(4, 100).BottomPosZ(4, 20))
289
	ITEM(Option, umk, SetLabel(t_("Umk compatible")).LeftPosZ(4, 100).TopPosZ(344, 16))
290
END_LAYOUT
291

  
267 292
LAYOUT(InstallLayout, 400, 88)
268 293
	ITEM(Label, dv___0, SetLabel(t_("MyApps directory")).LeftPosZ(8, 120).TopPosZ(8, 19))
269 294
	ITEM(WithDropChoice<EditString>, myapps, LeftPosZ(8, 316).TopPosZ(28, 19))
uppsrc/ide/OutputMode.cpp 2014-12-17 07:14:17 +0400
130 130
	void Save();
131 131
	void Preset();
132 132
	void SyncLock();
133
	
133

  
134 134
	void Export(int kind);
135 135

  
136
	void ConfigChange();
137
	void CmdOptions();
138

  
136 139
	typedef OutMode CLASSNAME;
137 140

  
138 141
	OutMode(Ide& ide);
......
140 143

  
141 144
void OutMode::Load()
142 145
{
146
	config.Clear();
147
	const DropList& list = ide.mainconfiglist;
148
	for (int i = 0; i < list.GetCount(); ++i)
149
		config.Add(list.GetKey(i), list[i]);
150
	config <<= ide.mainconfigparam;
143 151
	method.Clear();
144 152
	FindFile ff(ConfigFile("*.bm"));
145 153
	while(ff) {
......
184 192
	Break(IDOK);
185 193
}
186 194

  
195
void OutMode::ConfigChange()
196
{
197
	if (config.GetIndex() < 0)
198
		return;
199
	ide.mainconfigparam = ~config;
200
}
201

  
202
class CmdBuildOptionsWindow : public WithCmdBuildOptionsLayout<TopWindow> {
203
private:
204
	String cmdAssembly, cmdBuildMode, cmdPackage, cmdMethod, cmdMainConfig;
205

  
206
	struct PathConvert : ConvertString {
207
		virtual int Filter(int chr) const
208
		{
209
			if (chr == '<' || chr == '>' || chr == '|' || chr == '*' || chr == '?' || chr == '\"') return Null;
210
			return ConvertString::Filter(chr);
211
		}
212
	};
213

  
214
public:
215
	typedef CmdBuildOptionsWindow CLASSNAME;
216

  
217
	CmdBuildOptionsWindow(const String& package, const String& method, const String& mainconfigparam, const String& output,
218
		int targetmode, int hydra1_threads, int linkmode, bool blitzbuild, bool createmap, bool verbosebuild) :
219
		cmdPackage(package), cmdMethod(method)
220
	{
221
		CtrlLayout(*this, t_("Command line options for building"));
222
		MinimizeBox().CloseBoxRejects();
223
		threads <<= hydra1_threads;
224
		threads.NotNull(false);
225
		cmdAssembly = GetVarsName();
226
		cmdBuildMode = (targetmode == 1 ? "r" : targetmode == 2 ? "1" : targetmode == 3 ? "2" : "d");
227
		if (mainconfigparam.GetCount()) {
228
			cmdMainConfig = mainconfigparam;
229
			cmdMainConfig.Replace(" ", ",");
230
			cmdMainConfig.Insert(0, " +");
231
		}
232
		if (blitzbuild) blitz <<= true;
233
		switch(linkmode) {
234
			case 1: shared <<= true;  break;
235
			case 2: sharedbuild <<= true; break;
236
		}
237
		exportproject <<= 0;
238
		map <<= createmap;
239
		verbose <<= verbosebuild;
240
		out <<= output;
241
		out.SetConvert(Single<PathConvert>());
242
		outoption <<= true;
243

  
244
		rebuild.WhenAction = blitz.WhenAction = msgonfail.WhenAction = silent.WhenAction =
245
			map.WhenAction = verbose.WhenAction = makefile.WhenAction =
246
			savetargetdir.WhenAction = exportproject.WhenAction = umk.WhenAction =
247
			threads.WhenAction = out.WhenAction = outoption.WhenAction = THISBACK(GenerateCmd);
248
		shared.WhenAction = THISBACK(OnShared);
249
		sharedbuild.WhenAction << THISBACK(OnSharedBuild);
250
		btnCopy.WhenPush = callback(&cmd, &TextCtrl::Copy);
251
	}
252

  
253
	void OnShared()      { if (shared && sharedbuild) sharedbuild <<= false; GenerateCmd(); }
254
	void OnSharedBuild() { if (sharedbuild && shared) shared <<= false; GenerateCmd(); }
255

  
256
	void GenerateCmd()
257
	{
258
		String cmdBuild("-");
259
		if (rebuild) cmdBuild << 'a';
260
		if (blitz) cmdBuild << 'b';
261
		if (!umk && msgonfail) cmdBuild << 'e';
262
		if (silent) cmdBuild << 'l';
263
		if (map) cmdBuild << 'm';
264
		cmdBuild << cmdBuildMode;
265
		if (shared) cmdBuild << 's';
266
		else if (sharedbuild) cmdBuild << 'S';
267
		if (verbose) cmdBuild << 'v';
268
		if (savetargetdir) cmdBuild << 'k';
269
		switch (exportproject) {
270
			case 1: cmdBuild << 'x'; break;
271
			case 2: cmdBuild << 'X'; break;
272
		}
273
		if (makefile) cmdBuild << 'M';
274
		int numThreads = ~threads;
275
		if (umk && !IsNull(numThreads) && numThreads > 0)
276
			cmdBuild << 'H' << numThreads;
277
		String output;
278
		if (outoption) {
279
			output = TrimBoth(~out);
280
			if (output.Find(" ") >= 0)
281
				output = String().Cat() << "\"" << output << "\"";
282
		}
283
		cmd <<= TrimRight(Format("%s %s %s %s%s %s",
284
			cmdAssembly, cmdPackage, cmdMethod, cmdBuild, cmdMainConfig, output));
285
	}
286

  
287
	virtual void Serialize(Stream& s)
288
	{
289
		s % rebuild % msgonfail % silent % verbose % makefile % savetargetdir % exportproject
290
			% threads % outoption % umk ;
291
	}
292

  
293
	virtual bool Key(dword key, int count)
294
	{
295
		if (key == K_ESCAPE) {
296
			Close();
297
			return true;
298
		}
299
		return false;
300
	}
301
};
302

  
303
void OutMode::CmdOptions()
304
{
305
	const Workspace& wspc = ide.IdeWorkspace();
306
	int pi = wspc.GetCount() > 0 ? 0 : -1;
307
	if (pi < 0) {
308
		PromptOK("No main package");
309
		return;
310
	}
311
	VectorMap<String, String> bm = ide.GetMethodVars(~method);
312
	if (bm.GetCount() == 0) {
313
		PromptOK("Invalid build method");
314
		return;
315
	}
316
	One<Host> host = ide.CreateHost(false);
317
	One<Builder> b = ide.CreateBuilder(~host);
318
	const String& p = wspc[pi];
319
	String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true));
320
	if (output.Right(1) == ".")
321
		output = output.Left(output.GetCount() - 1);
322
	const ModePane& pane = ~mode == 0 ? debug : release;
323
	int blitzpackage = pane.package.Get(0, 2);
324
	bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz
325
		&& (IsNull(blitzpackage) ? true : blitzpackage);
326
	CmdBuildOptionsWindow window(p, ~method, ~config, output,
327
		~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild);
328
	LoadFromGlobal(window, "CmdBuildOptionsWindow");
329
	window.GenerateCmd();
330
	window.Run();
331
	StoreToGlobal(window, "CmdBuildOptionsWindow");
332
}
333

  
187 334
bool MapFlag(const VectorMap<String, String>& map, const char *key)
188 335
{
189 336
	return map.Get(key, "0") == "1";
......
242 389
:	ide(ide)
243 390
{
244 391
	CtrlLayoutOKCancel(*this, "Output mode");
392
	config <<= THISBACK(ConfigChange);
245 393
	method <<= THISBACK(Preset);
394
	cmd_options <<= THISBACK(CmdOptions);
246 395
	SyncLock();
247 396
	DirSel(export_dir, dsb);
248 397
	export_all <<= THISBACK1(Export, 1);
......
253 402

  
254 403
void Ide::SetupOutputMode()
255 404
{
405
	String prevmainconfig = mainconfigparam;
256 406
	SetupDefaultMethod();
257 407
	OutMode m(*this);
258 408
	m.Load();
259
	if(m.Execute() != IDOK)
409
	if(m.Execute() != IDOK) {
410
		mainconfigparam = prevmainconfig;
260 411
		return;
412
	}
261 413
	m.Save();
414
	if(prevmainconfig != mainconfigparam)
415
		SetMainConfigList();
262 416
	SyncBuildMode();
263 417
	SetBar();
264 418
}