Skip to content

Commit b87d3f9

Browse files
committed
File logging and lighting build
1 parent 89cbc9b commit b87d3f9

File tree

4 files changed

+48
-53
lines changed

4 files changed

+48
-53
lines changed

Build.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import sys
23

34
from Scripts.UpdateVersionNumber import update_version_number
45
from Scripts.UpdateFromP4 import update_from_P4
@@ -32,6 +33,7 @@ def script_error( log_file, error_message ):
3233

3334
build_dir = env.get_env_variable('Game', 'builds_dir')
3435
log_file = open( build_dir + args.output, 'w')
36+
sys.stderr = log_file
3537

3638
log_file.write( '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n' )
3739
log_file.write( 'Initiating Build Sequence\n' )
@@ -53,34 +55,21 @@ def script_error( log_file, error_message ):
5355

5456
if success and not args.no_lighting and (args.all or args.lighting):
5557
success = build_lighting( log_file )
58+
if not success:
59+
script_error(log_file, 'Failed to build the lighting')
5660

61+
if success and (args.all or args.build):
62+
success = build_game( log_file )
63+
if not success:
64+
script_error( log_file, 'Failed to build and package the game')
5765

58-
# success = update_from_P4()
59-
# if success:
60-
# success = update_version_number( major, minor, hotfix)
61-
# pass
62-
# else:
63-
# print('[FAILED] Failed to update from perforce')
64-
65-
# if success:
66-
# success = build_lighting()
67-
# pass
68-
# else:
69-
# print('[FAILED]: Failed to update version number')
70-
71-
# if success:
72-
# success = build_game()
73-
# pass
74-
# else:
75-
# print('[FAILED]: Failed to build lighting')
76-
77-
# if success:
78-
# success = upload_to_steam()
79-
# pass
80-
# else:
81-
# print('[FAILEd]: Failed to build and package the game')
66+
if success and (args.all or args.steam):
67+
success = upload_to_steam( log_file )
68+
if not success:
69+
script_error( log_file, 'Failed to upload to steam')
8270

83-
# if not success:
84-
# print('[FAILED]: Failed to upload to steam')
71+
log_file.write('Sequence finished without error.\n')
72+
log_file.write('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
73+
log_file.close()
8574

86-
log_file.close()
75+
quit(0)

Scripts/BuildGame.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
game_name = env.get_env_variable('Game', 'game_name')
88
builds_dir = env.get_env_variable( "Game", "builds_dir" )
99

10-
def build_game():
10+
def build_game( log_file ):
1111

12-
print( '----------------------------------------------------------------------------------------------------' )
13-
print( '{} - Step 4: Starting BuildCookRun'.format( game_name ) )
14-
print( '----------------------------------------------------------------------------------------------------' )
12+
log_file.write( '----------------------------------------------------------------------------------------------------\n' )
13+
log_file.write( '{} - Step 4: Starting BuildCookRun\n'.format( game_name ) )
14+
log_file.write( '----------------------------------------------------------------------------------------------------\n' )
15+
log_file.flush()
1516

1617
uproject_file = env.get_env_variable( "Game", "uproject_file" )
1718

1819
ue4_batchfiles_dir = env.get_env_variable( 'Local', "ue4_batchfiles_dir" )
1920
ue4_binaries_dir = env.get_env_variable( 'Local', "ue4_binaries_dir" )
2021

21-
print(subprocess.run( [ ue4_batchfiles_dir + 'RunUAT.bat', "BuildCookRun", "-project=" + uproject_file, "-noP4", "-nocompile", "-nocompileeditor", "-installed", "-cook", "-stage", "-archive", "-archivedirectory=" + builds_dir, "-package", "-clientconfig=Development", "-ue4exe=" + ue4_binaries_dir + "UE4Editor-Cmd.exe", "-pak", "-prereqs", "-nodebuginfo", "-targetplatform=Win64", "-build", "-CrashReporter", "-utf8output" ] ))
22+
subprocess.run( [ ue4_batchfiles_dir + 'RunUAT.bat', "BuildCookRun", "-project=" + uproject_file, "-noP4", "-nocompile", "-nocompileeditor", "-installed", "-cook", "-stage", "-archive", "-archivedirectory=" + builds_dir, "-package", "-clientconfig=Development", "-ue4exe=" + ue4_binaries_dir + "UE4Editor-Cmd.exe", "-pak", "-prereqs", "-nodebuginfo", "-targetplatform=Win64", "-build", "-CrashReporter", "-utf8output" ], stdout=log_file )
2223

24+
log_file.flush()
2325
return True
2426

2527
def zip_build():
@@ -29,8 +31,3 @@ def zip_build():
2931
now_str = now.strftime( "%m_%d_%H_%M" )
3032

3133
file_utils.zip_file_directory( latest_build_dir, builds_dir + game_name + "_" + now_str + ".zip" )
32-
33-
34-
if __name__ == '__main__':
35-
build_game()
36-
zip_build()

Scripts/BuildLighting.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import subprocess
22
import os
3+
import glob
34

45
from P4 import P4, P4Exception
56

@@ -12,21 +13,26 @@ def build_lighting( log_file ):
1213
log_file.write( '{} - Step 3: Starting Lighting Build\n'.format( game_name ) )
1314
log_file.write( '----------------------------------------------------------------------------------------------------\n' )
1415

15-
maps = []
1616

1717
# Compile the list of maps
1818
map_dir = env.get_env_variable('Game', 'map_dir')
19-
map_names = env.get_env_variable('Game', 'maps').split(';')
19+
map_names = env.get_env_variable('Game', 'maps').split(' ')
20+
perforce_map_files = []
2021

2122
log_file.write('Building lighting for these maps: ')
2223
for map in map_names:
2324
log_file.write(map + " ")
24-
full_path_map = map_dir + map
25-
maps.append( full_path_map + '.umap')
2625

27-
maps.append( full_path_map + '_BuiltData.uasset')
26+
# Find all maps, and submaps that match <dir>\**\<map>*.umap
27+
found_maps = glob.glob(map_dir + '\**\\' + map + '*.umap', recursive=True)
28+
29+
# For all the found maps create a mapping to the build data
30+
for found_map in found_maps:
31+
perforce_map_files.append( found_map)
32+
perforce_map_files.append( found_map[0:found_map.index('.')] + '_BuildData.uasset' )
2833

29-
log_file.write('\n')
34+
log_file.write( '\n' )
35+
log_file.write('Found a total of {} maps to build lighting on\n'.format( (int)(len(perforce_map_files) / 2)))
3036
log_file.flush()
3137

3238
# Check the file out from P4
@@ -39,26 +45,27 @@ def build_lighting( log_file ):
3945
p4.connect()
4046

4147
# Checkout requested maps
42-
for map in maps:
48+
for map in perforce_map_files:
4349
try:
4450
p4.run('edit', map)
4551
except:
46-
pass
52+
log_file.write('Failed to open map {}\n'.format(map))
53+
log_file.flush()
4754

4855
# Build the lighting
4956
uproject_file = env.get_env_variable( "Game", "uproject_file" )
5057
ue4_binaries_dir = env.get_env_variable( 'Local', "ue4_binaries_dir" )
51-
subprocess.run( [ ue4_binaries_dir + 'UE4Editor-Cmd.exe', uproject_file, '-verbose', "-p4", "-submit", "-run=resavepackages" , "-buildlighting", "-quality=production", "-allowcommandletrendering", "-map" + ' '.join(maps)], stdout=log_file )
58+
subprocess.run( [ ue4_binaries_dir + 'UE4Editor-Cmd.exe', uproject_file, "-p4", "-submit", "-run=resavepackages" , "-buildlighting", "-quality=Production", "-AllowCommandletRendering", "-map" + ' '.join(map_names)], stdout=log_file )
5259
log_file.flush()
5360

5461
# Add maps back for addition to p4
55-
for map in maps:
62+
for map in perforce_map_files:
5663
log_file.write("adding " + map + '\n')
5764
p4.run('add', map)
5865
log_file.flush()
5966

6067
change = p4.fetch_change()
61-
change._description = '[Daily_Builds] Built lighting for the follow maps:\n' + '\n\t'.join(maps)
68+
change._description = '[Daily_Builds] Built lighting for the follow maps:\n' + '\n\t'.join(perforce_map_files)
6269
# p4.run_submit( change )
6370

6471
log_file.write('Lighting successfully built and submitted\n')

Scripts/UploadToSteam.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44

55
game_name = env.get_env_variable('Game', 'game_name')
66

7-
def upload_to_steam():
7+
def upload_to_steam( log_file ):
88

9-
print( '----------------------------------------------------------------------------------------------------' )
10-
print( '{} - Step 5: Starting Upload to Steam'.format( game_name ) )
11-
print( '----------------------------------------------------------------------------------------------------' )
9+
log_file.write( '----------------------------------------------------------------------------------------------------\n' )
10+
log_file.write( '{} - Step 5: Starting Upload to Steam\n'.format( game_name ) )
11+
log_file.write( '----------------------------------------------------------------------------------------------------\n' )
12+
log_file.flush()
1213

1314
user_name = env.get_env_variable( "Steam", "user_name" )
1415
user_password = env.get_env_variable( "Steam", "user_password" )
1516
steam_dir = env.get_env_variable( "Steam", "steam_dir" )
1617
steam_cmd = env.get_env_variable( "Steam", "steam_cmd" )
1718
app_build = env.get_env_variable( "Steam", "app_build" )
1819

19-
print(subprocess.run( [steam_dir + steam_cmd, "+login", user_name, user_password, "+run_app_build_http", steam_dir + app_build, "+quit"] ))
20+
subprocess.run( [steam_dir + steam_cmd, "+login", user_name, user_password, "+run_app_build_http", steam_dir + app_build, "+quit"], stdout=log_file )
2021

22+
log_file.flush()
2123
return True
2224

2325
if __name__ == '__main__':

0 commit comments

Comments
 (0)