2
0
Эх сурвалжийг харах

Added -ud/adddef options.

woollybah 6 жил өмнө
parent
commit
bf5ab09909
6 өөрчлөгдсөн 86 нэмэгдсэн , 1 устгасан
  1. 4 0
      CHANGELOG
  2. 11 1
      bmk_config.bmx
  3. 20 0
      bmk_make.bmx
  4. 31 0
      bmk_modutil.bmx
  5. 16 0
      bmk_ng.bmx
  6. 4 0
      make.bmk

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+## [3.38] - 2019-05-29
+### Added
+ - New '-ud' option to add user defined compiler options. (bcc 0.108+)
+
 ## [3.37] - 2019-05-26
 ### Fixed
  - Wrapped upx arg path in quotes.

+ 11 - 1
bmk_config.bmx

@@ -10,7 +10,7 @@ Import brl.map
 
 Import "stringbuffer_core.bmx"
 
-Const BMK_VERSION:String = "3.37"
+Const BMK_VERSION:String = "3.38"
 
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc;asm;S"
 
@@ -59,6 +59,7 @@ Global opt_override_error:Int
 Global opt_nopie:Int
 Global opt_nopie_set:Int
 Global opt_upx:Int
+Global opt_userdefs:String
 
 Global opt_dumpbuild
 
@@ -235,6 +236,10 @@ Function ParseConfigArgs$[]( args$[], legacyMax:Int = False )
 			opt_nopie_set = True
 		Case "upx"
 			opt_upx = True
+		Case "ud"
+			n:+1
+			If n=args.length CmdError "Missing arg for '-ud'"
+			opt_userdefs=args[n]
 		Default
 			CmdError "Invalid option '" + arg[1..] + "'"
 		End Select
@@ -413,6 +418,11 @@ Function Usage:String(fullUsage:Int = False)
 		s:+ "~t~tShould be either 'console' or 'gui' (without single quote!).~n"
 		s:+ "~t~tThe default is console."
 		s:+ "~n~n"
+		s:+ "~t-ud <definitions>~n"
+		s:+ "~t~tAdd user defined compiler options. (NG only)."
+		s:+ "~t~tA comma-separated list of compiler options that can be used in addition to the defaults.~n"
+		s:+ "~t~tAlternatively, the option 'adddef' can be used in build scripts to provide the same.~n"
+		s:+ "~n~n"
 		s:+ "~t-upx~n"
 		s:+ "~t~tPack binary using UPX. (makeapp only)."
 		s:+ "~n~n"

+ 20 - 0
bmk_make.bmx

@@ -398,6 +398,16 @@ Type TBuildManager Extends TCallback
 					sb.Append(" -overerr")
 				End If
 			End If
+			Local defs:String = opt_userdefs
+			If globals.Get("user_defs") Then
+				If defs Then
+					defs :+ ","
+				End If
+				defs :+ globals.Get("user_defs")
+			End If
+			If defs Then
+				sb.Append(" -ud ").Append(defs)
+			End If
 		End If
 
 		source.cc_opts :+ cc_opts
@@ -1257,6 +1267,16 @@ Type TBuildManager Extends TCallback
 						sb.Append(" -overerr")
 					End If
 				End If
+				Local defs:String = opt_userdefs
+				If globals.Get("user_defs") Then
+					If defs Then
+						defs :+ ","
+					End If
+					defs :+ globals.Get("user_defs")
+				End If
+				If defs Then
+					sb.Append(" -ud ").Append(defs)
+				End If
 			End If
 	
 			source.bcc_opts = sb.ToString()

+ 31 - 0
bmk_modutil.bmx

@@ -753,5 +753,36 @@ Function SetCompilerValues()
 	compilerOptions.Add("nx", processor.Platform() = "nx")
 	compilerOptions.Add("nxarm64", processor.Platform() = "nx" And processor.CPU()="arm64")
 
+	Local userdefs:String[] = GetUserDefs()
+	If userdefs Then
+		For Local def:String = EachIn userdefs
+			compilerOptions.Add(def, True)
+		Next
+	End If
 End Function
 
+Function GetUserDefs:String[]()
+	Local defs:String = opt_userdefs
+	If globals.Get("user_defs") Then
+		If defs Then
+			defs :+ ","
+		End If
+		defs :+ globals.Get("user_defs")
+	End If
+	
+	Local parts:String[] = defs.ToLower().Split(",")
+	Local userdefs:String[parts.length]
+	Local count:Int
+	For Local def:String = EachIn parts
+		def = def.Trim()
+		If Not def Then
+			Continue
+		End If
+		userdefs[count] = def
+		count :+ 1
+	Next
+	If count < parts.length Then
+		userdefs = userdefs[..count]
+	End If
+	Return userdefs
+End Function

+ 16 - 0
bmk_ng.bmx

@@ -991,6 +991,22 @@ Type TBMKGlobals
 		End If
 	End Method
 
+	' adds comma separated value to the end of variable
+	Method AddC(variable:String, value:String)
+		If Not AsConfigurable(variable.ToLower(), value) Then
+			variable = variable.ToUpper()
+	
+			Local v:Object = vars.ValueForKey(variable)
+			If Not TOptionVariable(v) Then
+				If v Then
+					SetVar(variable, String(v) + "," + value)
+				Else
+					SetVar(variable, value)
+				End If
+			End If
+		End If
+	End Method
+
 	Method AddOption(variable:String, key:String, value:String)
 		variable = variable.ToUpper()
 

+ 4 - 0
make.bmk

@@ -421,6 +421,10 @@
 	end
 @end
 
+@define adddef
+	globals.AddC("user_defs", arg1)
+@end
+
 # the default ccopts
 # used for compiling c-type files
 @define default_cc_opts