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

Improved windows resource handling. Fixes #68.

woollybah 6 жил өмнө
parent
commit
68a4fb5a1b
5 өөрчлөгдсөн 51 нэмэгдсэн , 14 устгасан
  1. 4 0
      CHANGELOG
  2. 4 2
      bmk.bmx
  3. 22 7
      bmk_config.bmx
  4. 14 3
      bmk_make.bmx
  5. 7 2
      make.bmk

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+## [3.35] - 2019-04-29
+### Fixed
+ - Improved Windows resource handling.
+
 ## [3.34] - 2019-03-15
 ### Added
  - New 'no-pie' option to disable PIE.

+ 4 - 2
bmk.bmx

@@ -248,6 +248,8 @@ Function MakeApplication( args$[],makelib:Int,compileOnly:Int = False )
 	End Select
 
 	If FileType(Main)<>FILETYPE_FILE Throw "Unable to open source file '"+Main+"'"
+	
+	opt_infile = Main
 
 	If Not opt_outfile Then
 		opt_outfile = StripExt( Main )
@@ -256,10 +258,10 @@ Function MakeApplication( args$[],makelib:Int,compileOnly:Int = False )
 	End If
 
 	' set some useful global variables
-	globals.SetVar("BUILDPATH", ExtractDir(opt_outfile))
+	globals.SetVar("BUILDPATH", ExtractDir(opt_infile))
 	globals.SetVar("EXEPATH", ExtractDir(opt_outfile))
 	globals.SetVar("OUTFILE", StripDir(StripExt(opt_outfile)))
-
+	globals.SetVar("INFILE", StripDir(StripExt(opt_infile)))
 
 	' some more useful globals
 	If processor.Platform() = "macos" And opt_apptype="gui" And Not compileOnly Then

+ 22 - 7
bmk_config.bmx

@@ -10,7 +10,7 @@ Import brl.map
 
 Import "stringbuffer_core.bmx"
 
-Const BMK_VERSION:String = "3.34"
+Const BMK_VERSION:String = "3.35"
 
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc;asm;S"
 
@@ -18,6 +18,7 @@ Global opt_arch$
 Global opt_arch_set=False
 Global opt_server$
 Global opt_outfile$
+Global opt_infile:String
 Global opt_framework$
 Global opt_apptype$="console"
 Global opt_debug=False
@@ -655,17 +656,31 @@ Function ValidatePlatform(platform:String)
 End Function
 
 Function ParseApplicationIniFile:TMap()
-	Local appId:String = StripDir(StripExt(opt_outfile))
-	Local buildDir:String = ExtractDir(opt_outfile)
+	Local ids:String[] = [StripDir(StripExt(opt_outfile)), StripDir(StripExt(opt_infile))]
 
-	Local path:String = buildDir + "/" + appId + ".settings"
+	Local appId:String = ids[0]
+	Local buildDir:String = ExtractDir(opt_infile)
 
+	Local path:String
+	Local found:Int
 	Local settings:TMap = New TMap
+	
+	For Local id:String = EachIn ids
+		path = buildDir + "/" + id + ".settings"
 
-	If Not FileType(path) Then
-		If opt_verbose Then
-			Print "Not Found : application settings file '" + appId + ".settings'. Using defaults..."
+		If Not FileType(path) Then
+			If opt_verbose Then
+				Print "Not Found : application settings file '" + id + ".settings'."
+			End If
+			Continue
 		End If
+		
+		found = True
+		Exit
+	Next
+	
+	If Not found Then
+		Print "Using defaults."
 		Return DefaultApplicationSettings()
 	End If
 

+ 14 - 3
bmk_make.bmx

@@ -618,9 +618,17 @@ Type TBuildManager Extends TCallback
 							
 							' include settings and icon times in calculation
 							If opt_manifest And processor.Platform() = "win32" And opt_apptype="gui" Then
-								Local settings:String = ExtractDir(opt_outfile) + "/" + StripDir(StripExt(opt_outfile)) + ".settings"
+								Local settings:String = ExtractDir(opt_infile) + "/" + StripDir(StripExt(opt_outfile)) + ".settings"
+								If Not FileType(settings) Then
+									settings = ExtractDir(opt_infile) + "/" + StripDir(StripExt(opt_infile)) + ".settings"
+								End If
 								max_lnk_time = Max(FileTime(settings), max_lnk_time)
-								max_lnk_time = Max(FileTime(StripDir(StripExt(opt_outfile)) + ".ico"), max_lnk_time)
+								
+								Local icon:String = ExtractDir(opt_infile) + "/" + StripDir(StripExt(opt_outfile)) + ".ico"
+								If Not FileType(icon) Then
+									icon = ExtractDir(opt_infile) + "/" + StripDir(StripExt(opt_infile)) + ".ico"
+								End If
+								max_lnk_time = Max(FileTime(icon), max_lnk_time)
 							End If
 						
 							If max_lnk_time > FileTime(opt_outfile) Or opt_all Then
@@ -628,7 +636,10 @@ Type TBuildManager Extends TCallback
 								' generate manifest for app
 								If opt_manifest And processor.Platform() = "win32" And opt_apptype="gui" Then
 									processor.RunCommand("make_win32_resource", Null)
-									Local res:String = ExtractDir(opt_outfile) + "/.bmx/" + StripDir(StripExt(opt_outfile)) + "." + processor.CPU() + ".res.o"
+									Local res:String = ExtractDir(opt_infile) + "/.bmx/" + StripDir(StripExt(opt_outfile)) + "." + processor.CPU() + ".res.o"
+									If Not FileType(res) Then
+										res = ExtractDir(opt_infile) + "/.bmx/" + StripDir(StripExt(opt_infile)) + "." + processor.CPU() + ".res.o"
+									End If
 									If FileType(res) = FILETYPE_FILE Then
 										Local s:TSourceFile = New TSourceFile
 										s.obj_path = res

+ 7 - 2
make.bmk

@@ -535,6 +535,7 @@
 	
 	local outfile = %outfile%
 	local undecorated_outfile = outfile
+	local infile = %infile%
 	
 	local decoration = ""
 	
@@ -569,9 +570,9 @@
 		arch = "x86"
 	end
 	
-	local tmp_path = %exepath% .. "/.bmx/"
+	local tmp_path = %buildpath% .. "/.bmx/"
 	
-	local user_manifest_path = %exepath% .. outfile .. ".exe.manifest"
+	local user_manifest_path = %buildpath% .. outfile .. ".exe.manifest"
 	local manifest_path = tmp_path .. outfile .. "." .. bmk.CPU() .. ".manifest"
 	local resource_path = tmp_path .. outfile .. "." .. bmk.CPU() .. ".rc"
 	local object_path = bmk.Quote(tmp_path .. outfile .. "." .. bmk.CPU() .. ".res.o")
@@ -579,6 +580,10 @@
 	if sys.FileType(icon_path) == 0 then
 		-- fall back to undecorated icon file
 		icon_path = undecorated_outfile .. ".ico"
+		
+		if sys.FileType(icon_path) == 0 then
+			icon_path = infile .. ".ico"
+		end
 	end
 
 	local manifest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" ..