浏览代码

Improved custom options support for Universal builds. Fixed import ordering.

git-svn-id: http://bmkng.googlecode.com/svn/trunk@8 2a3afde7-ceff-d69e-269d-2b6c215c828a
[email protected] 14 年之前
父节点
当前提交
18bd9b218e
共有 5 个文件被更改,包括 129 次插入14 次删除
  1. 21 1
      bmk.bmx
  2. 1 1
      bmk_bank.bmx
  3. 57 1
      bmk_ng.bmx
  4. 5 2
      custom.bmk
  5. 45 9
      make.bmk

+ 21 - 1
bmk.bmx

@@ -1,5 +1,8 @@
 '
 ' Change History :
+' 2.03 28/06/2009 - Improved custom options support for Universal builds.
+'                   Fixed import ordering.
+' 2.02 08/06/2009 - Fixed multiple defines problem.
 ' 2.01 07/06/2009 - Fixed dependency compilation issue - or lack of it!
 '  BaH 26/05/2009 - Added multi-process (threading) support.
 '                   Improved custom variable overriding.
@@ -30,7 +33,7 @@ args=ParseConfigArgs( AppArgs[2..] )
 RunCommand("default_cc_opts", Null)
 
 ' load any global custom options (in BlitzMax/bin)
-LoadBMK(AppDir + "/custom.bmk")
+LoadOptions
 
 CreateDir BlitzMaxPath()+"/tmp"
 
@@ -49,8 +52,10 @@ Case "makemods"
 		If opt_universal
 			SetConfigMung
 			processor.ToggleCPU()
+			LoadOptions(True) ' reload options for PPC
 			MakeModules args
 			processor.ToggleCPU()
+			LoadOptions(True)
 		End If
 	
 	Else
@@ -61,8 +66,10 @@ Case "makemods"
 		If opt_universal
 			SetConfigMung
 			processor.ToggleCPU()
+			LoadOptions(True) ' reload options for PPC
 			MakeModules args
 			processor.ToggleCPU()
+			LoadOptions(True)
 		End If
 		opt_debug=False
 		opt_release=True
@@ -71,8 +78,10 @@ Case "makemods"
 		If opt_universal
 			SetConfigMung
 			processor.ToggleCPU()
+			LoadOptions(True) ' reload options for PPC
 			MakeModules args
 			processor.ToggleCPU()
+			LoadOptions(True)
 		End If
 	EndIf
 Case "cleanmods"
@@ -304,10 +313,12 @@ Function MakeApplication( args$[],makelib )
 
 		Local previousOutfile:String = opt_outfile
 		processor.ToggleCPU()
+		LoadOptions(True) ' reload options for PPC
 		opt_outfile :+ "." + processor.CPU()
 		BeginMake
 		MakeApp Main,makelib
 		processor.ToggleCPU()
+		LoadOptions(True)
 		
 		MergeApp opt_outfile, previousOutfile
 		
@@ -384,3 +395,12 @@ Function RanlibDir( args$[] )
 
 End Function
 
+Function LoadOptions(reload:Int = False)
+	If reload Then
+		' reset the options to default
+		RunCommand("default_cc_opts", Null)
+	End If
+	LoadBMK(AppDir + "/custom.bmk")
+End Function
+
+

+ 1 - 1
bmk_bank.bmx

@@ -5,7 +5,7 @@ Import BRL.MaxUtil
 
 Import Pub.MacOS
 
-Const BMK_VERSION:String = "2.02"
+Const BMK_VERSION:String = "2.03"
 
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s"
 

+ 57 - 1
bmk_ng.bmx

@@ -437,7 +437,23 @@ Type TBMKGlobals
 		If TOptionVariable(v) Then
 			TOptionVariable(v).AddVar(key, value)
 		Else
-			SetVar(variable, String(v) + " " + value)
+			Local opt:TOptionVariable = New TOptionVariable
+			opt.addVar(key, value)
+			setVar(variable, opt)
+		End If
+
+	End Method
+
+	Method SetOption(variable:String, key:String, value:String)
+		variable = variable.ToUpper()
+
+		Local v:Object = vars.ValueForKey(variable)
+		If TOptionVariable(v) Then
+			TOptionVariable(v).SetVar(key, value)
+		Else
+			Local opt:TOptionVariable = New TOptionVariable
+			opt.SetVar(key, value)
+			setVar(variable, opt)
 		End If
 
 	End Method
@@ -451,6 +467,19 @@ Type TBMKGlobals
 		End If
 	End Method
 	
+	Method Clear(variable:String)
+		variable = variable.ToUpper()
+
+		Local v:Object = vars.ValueForKey(variable)
+		If TOptionVariable(v) Then
+			vars.remove(variable)
+		End If
+	End Method
+	
+	Method Reset()
+		stack.Clear()
+	End Method
+	
 End Type
 
 Type TOpt
@@ -474,6 +503,8 @@ Type TOptionVariable
 			count:+1
 			name = "VAR" + count
 			opt.name = name
+		Else
+			opt.name = name
 		End If
 		opt.value = value
 		
@@ -481,6 +512,30 @@ Type TOptionVariable
 		orderedOptions.AddLast(opt)
 		
 	End Method
+
+	Method SetVar(name:String, value:String)', insertBefore:Int = False)
+		Local opt:TOpt = New TOpt
+	
+		If Not name Then
+			Global count:Int
+			count:+1
+			name = "VAR" + count
+			opt.name = name
+		Else
+			opt.name = name
+		End If
+		opt.value = value
+
+		' option already exists?
+		Local o:TOpt = TOpt(options.ValueForKey(name))
+		If o Then
+			orderedOptions.Remove(o)
+		End If
+		
+		options.Insert(name, opt)
+		orderedOptions.AddLast(opt)
+		
+	End Method
 	
 	' finds and removes a matching value
 	Method RemoveVar(name:String)
@@ -495,6 +550,7 @@ Type TOptionVariable
 		For Local opt:TOpt = EachIn orderedOptions
 			s:+ opt.value + " "
 		Next
+
 		Return s
 	End Method
 	

+ 5 - 2
custom.bmk

@@ -1,4 +1,7 @@
 
-addccopt optimization -O3
+setccopt optimization -O3
 
-addwin32ccopt arch -march=pentium3
+setwin32ccopt arch -march=pentium3
+
+setmacx86ccopt arch -march=nocona
+setmacx86ccopt math -msse3

+ 45 - 9
make.bmk

@@ -138,36 +138,70 @@
 	globals.AddOption("cc_opts", arg1, arg2)
 @end
 
+@define setccopt
+	globals.SetOption("cc_opts", arg1, arg2)
+@end
+
 @define addwin32ccopt
 	if bmk.Platform() == "win32" then
 		globals.AddOption("cc_opts", arg1, arg2)
 	end
 @end
 
+@define setwin32ccopt
+	if bmk.Platform() == "win32" then
+		globals.SetOption("cc_opts", arg1, arg2)
+	end
+@end
+
 @define addmacccopt
 	if bmk.Platform() == "macos" then
 		globals.AddOption("cc_opts", arg1, arg2)
 	end
 @end
 
+@define setmacccopt
+	if bmk.Platform() == "macos" then
+		globals.SetOption("cc_opts", arg1, arg2)
+	end
+@end
+
 @define addmacppcccopt
 	if bmk.Platform() == "macos" and bmk.CPU() == "ppc" then
 		globals.AddOption("cc_opts", arg1, arg2)
 	end
 @end
 
+@define setmacppcccopt
+	if bmk.Platform() == "macos" and bmk.CPU() == "ppc" then
+		globals.SetOption("cc_opts", arg1, arg2)
+	end
+@end
+
 @define addmacx86ccopt
 	if bmk.Platform() == "macos" and bmk.CPU() == "x86" then
 		globals.AddOption("cc_opts", arg1, arg2)
 	end
 @end
 
+@define setmacx86ccopt
+	if bmk.Platform() == "macos" and bmk.CPU() == "x86" then
+		globals.SetOption("cc_opts", arg1, arg2)
+	end
+@end
+
 @define addlinuxccopt
 	if bmk.Platform() == "linux" then
 		globals.AddOption("cc_opts", arg1, arg2)
 	end
 @end
 
+@define setlinuxccopt
+	if bmk.Platform() == "linux" then
+		globals.SetOption("cc_opts", arg1, arg2)
+	end
+@end
+
 ## removes a cc_opt option
 @define rmccopt
 	globals.Remove("cc_opts", arg1)
@@ -186,28 +220,30 @@
 # used for compiling c-type files
 @define default_cc_opts
 
+	globals.Clear("cc_opts")
+
 	if bmk.Platform() == "macos" then
 		
 		# compile for 10.3 ?
 		# macos version >= 0x1050 ?
 		if tonumber(%macos_version%) >= 4176 then
-			globals.Addoption("cc_opts", "osversion", "-mmacosx-version-min=10.3")
+			globals.SetOption("cc_opts", "osversion", "-mmacosx-version-min=10.3")
 		end
 	elseif bmk.Platform() == "win32" then
 
-		globals.AddOption("cc_opts", "arch", "-march=pentium")
-		globals.AddOption("cc_opts", "fastmath", "-ffast-math")
+		globals.SetOption("cc_opts", "arch", "-march=pentium")
+		globals.SetOption("cc_opts", "fastmath", "-ffast-math")
 		
 	elseif bmk.Platform() == "linux" then
-		globals.AddOption("cc_opts", "aliasing", "-fno-strict-aliasing")
-		globals.AddOption("cc_opts", "arch", "-m32")
-		globals.AddOption("cc_opts", "fancymath", "-mfancy-math-387")
+		globals.SetOption("cc_opts", "aliasing", "-fno-strict-aliasing")
+		globals.SetOption("cc_opts", "arch", "-m32")
+		globals.SetOption("cc_opts", "fancymath", "-mfancy-math-387")
 	
 	end
 
-	globals.AddOption("cc_opts", "exceptions", "-fno-exceptions")
-	globals.AddOption("cc_opts", "linker", "-c")
-	globals.AddOption("cc_opts", "optimization", "-Os")
+	globals.SetOption("cc_opts", "exceptions", "-fno-exceptions")
+	globals.SetOption("cc_opts", "linker", "-c")
+	globals.SetOption("cc_opts", "optimization", "-Os")
 
 @end