Skip to content

Commit 7925aea

Browse files
NightlyBuildsNightlyBuilds
authored andcommitted
Fixed commit issue with missing files
1 parent d70d661 commit 7925aea

File tree

11 files changed

+332
-6
lines changed

11 files changed

+332
-6
lines changed

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
*
2-
!BatchReferences/
3-
!Scripts/
4-
5-
!Build.py
6-
!.gitignore
1+
ProjectDirectory/
2+
__pycache__/
3+
config.ini

BatchReferences/Launch.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
python Update_From_P4.py

Scripts/BuildGame.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import subprocess
2+
from datetime import datetime
3+
4+
from . import FileUtils as file_utils
5+
from . import Environment as env
6+
7+
game_name = env.get_env_variable('Game', 'game_name')
8+
builds_dir = env.get_env_variable( "Game", "builds_dir" )
9+
10+
def build_game():
11+
12+
print( '----------------------------------------------------------------------------------------------------' )
13+
print( '{} - Step 3: Starting BuildCookRun'.format( game_name ) )
14+
print( '----------------------------------------------------------------------------------------------------' )
15+
16+
uproject_file = env.get_env_variable( "Game", "uproject_file" )
17+
build_maps = env.get_env_variable( "Game", "build_maps" )
18+
19+
ue4_batchfiles_dir = env.get_env_variable( 'Local', "ue4_batchfiles_dir" )
20+
ue4_binaries_dir = env.get_env_variable( 'Local', "ue4_binaries_dir" )
21+
22+
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" ] ))
23+
24+
return True
25+
26+
def zip_build():
27+
latest_build_dir = env.get_env_variable( "Game", "latest_build_dir" )
28+
29+
now = datetime.now()
30+
now_str = now.strftime( "%m_%d_%H_%M" )
31+
32+
file_utils.zip_file_directory( latest_build_dir, builds_dir + game_name + "_" + now_str + ".zip" )
33+
34+
35+
if __name__ == '__main__':
36+
build_game()
37+
zip_build()

Scripts/BuildInstaller.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import subprocess
2+
3+
import Environment as env
4+
5+
game_name = env.get_env_variable('Game', 'game_name')
6+
7+
def build_installer():
8+
exe_build_script = env.get_env_variable( 'Local', "exe_build_script" )
9+
inno_setup_exe = env.get_env_variable( 'Local', "inno_setup_exe" )
10+
11+
# Yay, the build was a success!
12+
# Step 3 Time to make an installer using the created archive
13+
# I don't believe this step can fail, as I never had it fail, but you could check this return code too
14+
print( '----------------------------------------------------------------------' )
15+
print( '{} - Step 3: Building installer executable'.format( game_name ) )
16+
print( '----------------------------------------------------------------------' )
17+
print(subprocess.run( [ inno_setup_exe, exe_build_script ] ))
18+
19+
20+
if __name__ == '__main__':
21+
build_installer()

Scripts/Environment.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from os import path
2+
3+
from configparser import ConfigParser
4+
from configparser import ExtendedInterpolation
5+
6+
7+
config = ConfigParser( interpolation=ExtendedInterpolation() )
8+
9+
def parse_env_variables():
10+
if path.exists('config.ini'):
11+
config.read('config.ini')
12+
return True
13+
else:
14+
return False
15+
16+
17+
def get_env_variable( section, var_name ):
18+
if len( config.sections() ) == 0:
19+
success = parse_env_variables()
20+
if not success:
21+
raise Exception("Failed to find file 'config.ini'")
22+
23+
return config.get(section, var_name)

Scripts/FileUtils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import zipfile
3+
4+
def zip_file_directory( directory_path, zip_file_path ):
5+
zip_file = zipfile.ZipFile( zip_file_path, 'w', zipfile.ZIP_STORED )
6+
7+
for root, dirs, files in os.walk( directory_path ):
8+
for file in files:
9+
relative_path = os.path.relpath( root, directory_path )
10+
11+
zip_file.write( os.path.join( root, file ), relative_path + '\\' + file )
12+
13+
zip_file.close()
14+

Scripts/UpdateFromP4.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import time
2+
import threading
3+
4+
from P4 import P4
5+
6+
from . import Environment as env
7+
8+
# Threaded P4V Sync function
9+
def p4_sync():
10+
global synced_files
11+
synced_files = p4.run( 'sync', '-f' )
12+
return synced_files
13+
14+
# Threaded P4v Sync callback
15+
def p4_sync_callback( synced_files_from_p4 ):
16+
global files_synced
17+
synced_files = synced_files_from_p4
18+
files_synced = True
19+
20+
#
21+
threaded_callback_lock = threading.Lock()
22+
class Threaded_Callback (threading.Thread):
23+
def __init__(self, thread_id, function, callback):
24+
threading.Thread.__init__(self)
25+
self.thread_id = thread_id
26+
self.function = function
27+
self.callback = callback
28+
29+
def run(self):
30+
returnValue = self.function()
31+
32+
threaded_callback_lock.acquire()
33+
self.callback( returnValue )
34+
threaded_callback_lock.release()
35+
36+
p4 = P4()
37+
synced_files = {}
38+
files_synced = False
39+
40+
game_name = env.get_env_variable('Game', 'game_name')
41+
42+
def update_from_P4():
43+
print( '----------------------------------------------------------------------------------------------------' )
44+
print( '{} - Step 1: Update the local workspace for P4'.format( game_name ) )
45+
print( '----------------------------------------------------------------------------------------------------' )
46+
47+
# Perforce Settings
48+
p4.user = env.get_env_variable('Perforce', 'user_name')
49+
p4.password = env.get_env_variable('Perforce', 'user_password')
50+
p4.client = env.get_env_variable('Perforce', 'client')
51+
52+
# Connect to the perforce server
53+
success = p4.connect()
54+
print( success )
55+
56+
p4_thread = Threaded_Callback(1, p4_sync, p4_sync_callback)
57+
p4_thread.start()
58+
59+
start_time = time.time()
60+
while( not files_synced ):
61+
print( "Time Elapsed: {:.2f}".format( time.time() - start_time ), end='\r')
62+
63+
print( 'Completed Perfoce Sync in {:.2f} seconds'.format( time.time() - start_time ) )
64+
65+
files_updated = 0
66+
files_deleted = 0
67+
for file in synced_files:
68+
if file['action'] == 'refreshed':
69+
continue
70+
71+
if file['action'] == 'deleted':
72+
files_deleted += 1
73+
continue
74+
75+
files_updated += 1
76+
update_message = str(files_updated) + ": "
77+
78+
relative_file_name = file['clientFile']
79+
name_loc = relative_file_name.find( game_name )
80+
relative_file_name = relative_file_name[ name_loc + len(game_name):]
81+
82+
update_message += relative_file_name + " ( "
83+
update_message += file['rev'] + " ) - "
84+
update_message += file['action']
85+
86+
print(update_message)
87+
88+
if files_deleted > 0:
89+
print( '{} files marked for deleted in total'.format( files_deleted ) )
90+
if files_updated == 0:
91+
print( 'All files are current' )
92+
93+
return True
94+
95+
if __name__ == '__main__':
96+
update_from_P4()
97+

Scripts/UpdateVersionNumber.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import datetime
2+
import json
3+
4+
from P4 import P4, P4Exception
5+
6+
from . import Environment as env
7+
8+
game_name = env.get_env_variable('Game','game_name')
9+
10+
def update_version_number( major, minor, hotfix ):
11+
print( '----------------------------------------------------------------------------------------------------' )
12+
print( '{} - Step 2: Update the version number'.format( game_name ) )
13+
print( '----------------------------------------------------------------------------------------------------' )
14+
15+
uproject_file_name = env.get_env_variable('Game', 'uproject_file')
16+
# Load the uproject file
17+
with open( uproject_file_name, 'r') as file:
18+
uproject_json = json.load( file )
19+
20+
# Update the version number
21+
if 'Version' in uproject_json:
22+
new_version = get_version_number(major, minor, hotfix, uproject_json['Version'])
23+
uproject_json['Version'] = new_version
24+
else:
25+
uproject_json['Version'] = {'Major':'0', 'Minor':'0', 'Hotfix':'1'}
26+
27+
# Add a pretty version
28+
uproject_json['Version']['Pretty'] = str(uproject_json['Version']['Major']) + '.' + str(uproject_json['Version']['Minor']) + '.' + str(uproject_json['Version']['Hotfix'])
29+
30+
# Check the file out from P4
31+
p4 = P4()
32+
p4.user = env.get_env_variable('Perforce', 'user_name')
33+
p4.password = env.get_env_variable('Perforce', 'user_password')
34+
p4.client = env.get_env_variable('Perforce', 'client')
35+
36+
37+
try:
38+
p4.connect()
39+
40+
p4.run( 'edit', uproject_file_name )
41+
42+
with open( uproject_file_name, 'w') as file:
43+
json.dump( uproject_json, file, indent = 4 )
44+
45+
change = p4.fetch_change()
46+
change._description = '[Daily_Builds] Updated the version number to ' + uproject_json['Version']['Pretty']
47+
test = p4.run_submit( change )
48+
49+
return True
50+
except P4Exception:
51+
for e in p4.errors:
52+
print(e)
53+
54+
return False
55+
except Exception as e:
56+
print(e)
57+
return False
58+
59+
def get_version_number(major, minor, hotfix, version):
60+
if major:
61+
version['Major'] = int(version['Major']) + 1
62+
version['Minor'] = 0
63+
version['Hotfix'] = 0
64+
return version
65+
66+
if minor:
67+
version['Minor'] = int(version['Minor']) + 1
68+
version['Hotfix'] = 0
69+
return version
70+
71+
if hotfix:
72+
version['Hotfix'] = int(version['Hotfix']) + 1
73+
return version
74+
75+
76+
if __name__ == '__main__':
77+
update_version_number(False, False, True)

Scripts/UploadToDeletedNighly.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import subprocess
2+
3+
from . import Environment as env
4+
5+
game_name = env.get_env_variable('Game', 'game_name')
6+
7+
def upload_to_deleted_nightly():
8+
print( '----------------------------------------------------------------------------------------------------' )
9+
print( '{} - Step 4: Uploading the completed build to Deleted Nightly'.format( game_name ) )
10+
print( '----------------------------------------------------------------------------------------------------' )
11+
12+
# Get variables for network connection
13+
bound_drive_letter = env.get_env_variable('Local', 'drive_letter')
14+
deleted_nightly_dir = env.get_env_variable('SMU', 'deleted_nightly_dir')
15+
executable_dir = env.get_env_variable('SMU', 'remote_archive_dir')
16+
17+
print( executable_dir)
18+
19+
smu_username= env.get_env_variable('SMU', 'user_name')
20+
smu_password= env.get_env_variable('SMU', 'user_password')
21+
22+
# Maps the network drive to 'K:'
23+
print(subprocess.run( ['net', 'use', bound_drive_letter, deleted_nightly_dir, '/user:' + smu_username, smu_password, '/persistent:no' ] ))
24+
25+
26+
# Removes the network drive 'K:'
27+
print( subprocess.run(['net', 'use', bound_drive_letter, '/d']))
28+
29+
if __name__ == '__main__':
30+
upload_to_deleted_nightly()

Scripts/UploadToSteam.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import subprocess
2+
3+
from . import Environment as env
4+
5+
game_name = env.get_env_variable('Game', 'game_name')
6+
7+
def upload_to_steam():
8+
9+
print( '----------------------------------------------------------------------------------------------------' )
10+
print( '{} - Step 3: Starting Upload to Steam'.format( game_name ) )
11+
print( '----------------------------------------------------------------------------------------------------' )
12+
13+
user_name = env.get_env_variable( "Steam", "user_name" )
14+
user_password = env.get_env_variable( "Steam", "user_password" )
15+
steam_dir = env.get_env_variable( "Steam", "steam_dir" )
16+
steam_cmd = env.get_env_variable( "Steam", "steam_cmd" )
17+
app_build = env.get_env_variable( "Steam", "app_build" )
18+
19+
print(subprocess.run( [steam_dir + steam_cmd, "+login", user_name, user_password, "+run_app_build_http", steam_dir + app_build, "+quit"] ))
20+
21+
return True
22+
23+
if __name__ == '__main__':
24+
upload_to_steam()
25+
26+
27+

0 commit comments

Comments
 (0)