279 lines
16 KiB
Ruby
Executable File
279 lines
16 KiB
Ruby
Executable File
#
|
|
# File:: makeheaders.rb
|
|
# Automatically generates header files for configurations.
|
|
#
|
|
# Pipeline::
|
|
#
|
|
# Author:: Kevin Weinberg <kevin.weinberg@rockstarnorth.com>
|
|
# Date:: 14 May 2010
|
|
#
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# Uses
|
|
#-----------------------------------------------------------------------------
|
|
|
|
require 'pipeline/config/projects'
|
|
require 'pipeline/os/getopt'
|
|
require 'pipeline/os/path'
|
|
require 'pipeline/os/file'
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# Helper Functions
|
|
#-----------------------------------------------------------------------------
|
|
def get_makeheaders_config_root()
|
|
|
|
config_directory = ENV['RAGE_DIR']
|
|
config_directory = OS::Path::combine(config_directory, "base\\src\\forceinclude\\templates")
|
|
return config_directory
|
|
end
|
|
|
|
def concatenate_to_file(in_file_path, out_file)
|
|
if not in_file_path.nil?
|
|
lines = File.readlines(in_file_path)
|
|
write_array_to_file(out_file, lines)
|
|
end
|
|
end
|
|
|
|
def write_array_to_file(file, array)
|
|
|
|
array.each do |line|
|
|
|
|
file.write(line)
|
|
end
|
|
|
|
end
|
|
|
|
def create_file(top_header_lines, platform_common_file, platform_types_file, config_file, post_types_file, output_type_file, bottom_header_lines, output_path)
|
|
|
|
rage_dir = ENV["RAGE_DIR"]
|
|
if rage_dir.nil?
|
|
print "Unable to find the RAGE force include paths. The RAGE_DIR environment variable must be set via the framework configuration.\n"
|
|
end
|
|
|
|
forceinclude_directory = OS::Path::combine(rage_dir, "base\\src\\forceinclude")
|
|
output_path = OS::Path::combine(forceinclude_directory, output_path)
|
|
|
|
config_root = get_makeheaders_config_root()
|
|
platform_common_file = platform_common_file == nil ? nil : OS::Path::combine(config_root, platform_common_file)
|
|
platform_types_file = OS::Path::combine(config_root, platform_types_file)
|
|
config_file = OS::Path::combine(config_root, config_file)
|
|
post_types_file = OS::Path::combine(config_root, post_types_file)
|
|
output_type_file = OS::Path::combine(config_root, output_type_file)
|
|
|
|
#Disabled for now, until P4 command can determine which Perforce server to use.
|
|
#@@p4.run_edit_or_add(output_path)
|
|
|
|
file = File.new(output_path, "w")
|
|
|
|
write_array_to_file(file, top_header_lines)
|
|
|
|
concatenate_to_file(platform_common_file, file)
|
|
concatenate_to_file(platform_types_file, file)
|
|
concatenate_to_file(config_file, file)
|
|
concatenate_to_file(post_types_file, file)
|
|
concatenate_to_file(output_type_file, file)
|
|
|
|
write_array_to_file(file, bottom_header_lines)
|
|
|
|
file.close
|
|
|
|
|
|
|
|
end
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# Implementation
|
|
#-----------------------------------------------------------------------------
|
|
|
|
COMMAND_OPTIONS = [ ["--help", "-h", Getopt::BOOLEAN, "Display help text." ],
|
|
]
|
|
|
|
TRAILING_DESC = { }
|
|
|
|
opts, trailing = Pipeline::OS::Getopt.getopts( COMMAND_OPTIONS )
|
|
|
|
if ( opts["help"] ) then
|
|
puts OS::Getopt.usage( COMMAND_OPTIONS, TRAILING_DESC )
|
|
exit( 1 )
|
|
end
|
|
|
|
rage_directory = ENV['RAGE_DIR']
|
|
|
|
if rage_directory == nil
|
|
puts "Environment variable RAGE_DIR does not exist. Unable to continue.\n"
|
|
exit( 1 )
|
|
end
|
|
|
|
config_directory = get_makeheaders_config_root()
|
|
config = Pipeline::Config.instance
|
|
|
|
#Create a global instance of Perforce to check out header files.
|
|
@@p4 = SCM::Perforce.new()
|
|
@@p4.port = config.sc_server
|
|
@@p4.client = config.sc_workspace
|
|
@@p4.user = config.sc_username
|
|
@@p4.connect()
|
|
|
|
#First, create the top part of the header to be used every file.
|
|
top_header_lines = []
|
|
top_header_lines << "// This file is automatically generated by makeheaders.rb. DO NOT MODIFY DIRECTLY!\n"
|
|
top_header_lines << "// To rebuild the forceinclude files, modify the templates in " << config_directory << "/\n"
|
|
top_header_lines << "// and then run " << config_directory << "/makeheaders.bat\n"
|
|
top_header_lines << "#ifdef __cplusplus\n"
|
|
top_header_lines << "#define BEGIN_NS_RAGE namespace rage {\n"
|
|
top_header_lines << "#define END_NS_RAGE }\n"
|
|
top_header_lines << "#else\n"
|
|
top_header_lines << "#define BEGIN_NS_RAGE\n"
|
|
top_header_lines << "#define END_NS_RAGE\n"
|
|
top_header_lines << "#endif\n"
|
|
|
|
hacks_file = OS::Path::combine(rage_directory, "base\\src\\forceinclude\\hacks.h")
|
|
print "Hacks File: #{hacks_file}\n"
|
|
hacks_lines = File.readlines(hacks_file)
|
|
|
|
#Write the bottom part of the each header into a separate file.
|
|
bottom_header_lines = []
|
|
bottom_header_lines << hacks_lines
|
|
bottom_header_lines << "#ifdef USING_RAGE\n"
|
|
bottom_header_lines << "using namespace rage;\n"
|
|
bottom_header_lines << "#endif // USING_RAGE\n"
|
|
|
|
#Add both version.h and hacks.h to the top header file.
|
|
version_file = OS::Path::combine(config_directory, "version.h")
|
|
version_lines = File.readlines(version_file)
|
|
|
|
any_types_file = OS::Path::combine(config_directory, "any_types.h")
|
|
any_types_lines = File.readlines(any_types_file)
|
|
|
|
top_header_lines << version_lines
|
|
top_header_lines << any_types_lines
|
|
|
|
#Platform Common Headers
|
|
windows_common = "windows_common.h"
|
|
|
|
#Platform Types
|
|
win32_page_types = "win32pg_types.h"
|
|
win64_page_types = "win64pg_types.h"
|
|
win32_rsc_types = "win32rsc_types.h"
|
|
win64_rsc_types = "win64rsc_types.h"
|
|
win32_common_types = "win32_types.h"
|
|
win64_common_types = "win64_types.h"
|
|
win64_gametool_types = "win64gametool_types.h"
|
|
win32_dx11_types = "win32dx11_types.h"
|
|
xenon_common_types = "xenon_types.h"
|
|
psn_common_types = "psn_types.h"
|
|
spu_common_types = "spu_types.h"
|
|
durango_common_types = "durango_types.h"
|
|
orbis_common_types = "orbis_types.h"
|
|
|
|
#Configuration Headers
|
|
debug_header = "any_debug.h"
|
|
beta_header = "any_beta.h"
|
|
profile_header = "any_profile.h"
|
|
release_header = "any_release.h"
|
|
bankrelease_header = "any_bankrelease.h"
|
|
final_header = "any_final.h"
|
|
master_header = "any_master.h"
|
|
|
|
tooldebug_header = "any_tooldebug.h"
|
|
toolbeta_header = "any_toolbeta.h"
|
|
toolrelease_header = "any_toolrelease.h"
|
|
|
|
spu_debug_header = "spu_debug.h"
|
|
|
|
#Post Types Headers
|
|
post_types_header = "post_types.h"
|
|
spu_post_types_header = "spu_post_types.h"
|
|
|
|
#Output Headers
|
|
common_output_header = "any_output.h"
|
|
spu_output_header = "spu_output.h"
|
|
|
|
#Windows 32 bit (DX9) Game Configurations
|
|
create_file(top_header_lines, windows_common, win32_page_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win32_debug.h")
|
|
create_file(top_header_lines, windows_common, win32_page_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win32_beta.h")
|
|
create_file(top_header_lines, windows_common, win32_page_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win32_release.h")
|
|
create_file(top_header_lines, windows_common, win32_page_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "win32_bankrelease.h")
|
|
create_file(top_header_lines, windows_common, win32_page_types, final_header, post_types_header, common_output_header, bottom_header_lines, "win32_final.h")
|
|
|
|
#Windows Resource Compiler Configurations (32 and 64 bit)
|
|
create_file(top_header_lines, windows_common, win32_rsc_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win32_rscdebug.h")
|
|
create_file(top_header_lines, windows_common, win32_rsc_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win32_rscbeta.h")
|
|
create_file(top_header_lines, windows_common, win32_rsc_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win32_rscrelease.h")
|
|
create_file(top_header_lines, windows_common, win64_rsc_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win64_rscdebug.h")
|
|
create_file(top_header_lines, windows_common, win64_rsc_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win64_rscbeta.h")
|
|
create_file(top_header_lines, windows_common, win64_rsc_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win64_rscrelease.h")
|
|
|
|
#Windows 64 bit Configurations
|
|
create_file(top_header_lines, windows_common, win64_page_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win64_debug.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win64_beta.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, final_header, post_types_header, common_output_header, bottom_header_lines, "win64_final.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, master_header, post_types_header, common_output_header, bottom_header_lines, "win64_master.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, profile_header, post_types_header, common_output_header, bottom_header_lines, "win64_profile.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win64_release.h")
|
|
create_file(top_header_lines, windows_common, win64_page_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "win64_bankrelease.h")
|
|
create_file(top_header_lines, windows_common, win64_gametool_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win64_gametooldebug.h")
|
|
create_file(top_header_lines, windows_common, win64_gametool_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win64_gametoolbeta.h")
|
|
create_file(top_header_lines, windows_common, win64_gametool_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win64_gametoolrelease.h")
|
|
|
|
#Durango (64 bit) Configurations
|
|
create_file(top_header_lines, nil, durango_common_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "durango_debug.h")
|
|
create_file(top_header_lines, nil, durango_common_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "durango_beta.h")
|
|
create_file(top_header_lines, nil, durango_common_types, final_header, post_types_header, common_output_header, bottom_header_lines, "durango_final.h")
|
|
create_file(top_header_lines, nil, durango_common_types, master_header, post_types_header, common_output_header, bottom_header_lines, "durango_master.h")
|
|
create_file(top_header_lines, nil, durango_common_types, profile_header, post_types_header, common_output_header, bottom_header_lines, "durango_profile.h")
|
|
create_file(top_header_lines, nil, durango_common_types, release_header, post_types_header, common_output_header, bottom_header_lines, "durango_release.h")
|
|
create_file(top_header_lines, nil, durango_common_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "durango_bankrelease.h")
|
|
|
|
#Orbis (64 bit) Configurations
|
|
create_file(top_header_lines, nil, orbis_common_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "orbis_debug.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "orbis_beta.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, final_header, post_types_header, common_output_header, bottom_header_lines, "orbis_final.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, master_header, post_types_header, common_output_header, bottom_header_lines, "orbis_master.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, profile_header, post_types_header, common_output_header, bottom_header_lines, "orbis_profile.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, release_header, post_types_header, common_output_header, bottom_header_lines, "orbis_release.h")
|
|
create_file(top_header_lines, nil, orbis_common_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "orbis_bankrelease.h")
|
|
|
|
#Windows 32 bit DX11 Configurations
|
|
create_file(top_header_lines, windows_common, win32_dx11_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "win32_dx11_debug.h")
|
|
create_file(top_header_lines, windows_common, win32_dx11_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "win32_dx11_beta.h")
|
|
create_file(top_header_lines, windows_common, win32_dx11_types, release_header, post_types_header, common_output_header, bottom_header_lines, "win32_dx11_release.h")
|
|
create_file(top_header_lines, windows_common, win32_dx11_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "win32_dx11_bankrelease.h")
|
|
create_file(top_header_lines, windows_common, win32_dx11_types, final_header, post_types_header, common_output_header, bottom_header_lines, "win32_dx11_final.h")
|
|
|
|
#Windows Tools Configurations
|
|
create_file(top_header_lines, windows_common, win32_common_types, tooldebug_header, post_types_header, common_output_header, bottom_header_lines, "win32_tooldebug.h")
|
|
create_file(top_header_lines, windows_common, win64_common_types, tooldebug_header, post_types_header, common_output_header, bottom_header_lines, "win64_tooldebug.h")
|
|
create_file(top_header_lines, windows_common, win32_common_types, toolbeta_header, post_types_header, common_output_header, bottom_header_lines, "win32_toolbeta.h")
|
|
create_file(top_header_lines, windows_common, win64_common_types, toolbeta_header, post_types_header, common_output_header, bottom_header_lines, "win64_toolbeta.h")
|
|
create_file(top_header_lines, windows_common, win32_common_types, toolrelease_header, post_types_header, common_output_header, bottom_header_lines, "win32_toolrelease.h")
|
|
create_file(top_header_lines, windows_common, win64_common_types, toolrelease_header, post_types_header, common_output_header, bottom_header_lines, "win64_toolrelease.h")
|
|
|
|
#Xenon Configurations
|
|
create_file(top_header_lines, nil, xenon_common_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "xenon_debug.h")
|
|
create_file(top_header_lines, nil, xenon_common_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "xenon_beta.h")
|
|
create_file(top_header_lines, nil, xenon_common_types, profile_header, post_types_header, common_output_header, bottom_header_lines, "xenon_profile.h")
|
|
create_file(top_header_lines, nil, xenon_common_types, release_header, post_types_header, common_output_header, bottom_header_lines, "xenon_release.h")
|
|
create_file(top_header_lines, nil, xenon_common_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "xenon_bankrelease.h")
|
|
create_file(top_header_lines, nil, xenon_common_types, final_header, post_types_header, common_output_header, bottom_header_lines, "xenon_final.h")
|
|
|
|
#PSN Configurations
|
|
create_file(top_header_lines, nil, psn_common_types, debug_header, post_types_header, common_output_header, bottom_header_lines, "psn_debug.h")
|
|
create_file(top_header_lines, nil, psn_common_types, beta_header, post_types_header, common_output_header, bottom_header_lines, "psn_beta.h")
|
|
create_file(top_header_lines, nil, psn_common_types, profile_header, post_types_header, common_output_header, bottom_header_lines, "psn_profile.h")
|
|
create_file(top_header_lines, nil, psn_common_types, release_header, post_types_header, common_output_header, bottom_header_lines, "psn_release.h")
|
|
create_file(top_header_lines, nil, psn_common_types, bankrelease_header, post_types_header, common_output_header, bottom_header_lines, "psn_bankrelease.h")
|
|
create_file(top_header_lines, nil, psn_common_types, final_header, post_types_header, common_output_header, bottom_header_lines, "psn_final.h")
|
|
|
|
#SPU Configurations
|
|
create_file(top_header_lines, nil, spu_common_types, spu_debug_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_debug.h")
|
|
create_file(top_header_lines, nil, spu_common_types, beta_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_beta.h")
|
|
create_file(top_header_lines, nil, spu_common_types, profile_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_profile.h")
|
|
create_file(top_header_lines, nil, spu_common_types, release_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_release.h")
|
|
create_file(top_header_lines, nil, spu_common_types, bankrelease_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_bankrelease.h")
|
|
create_file(top_header_lines, nil, spu_common_types, final_header, spu_post_types_header, spu_output_header, bottom_header_lines, "spu_psn_final.h")
|
|
|
|
print "Header File Generation has succeeded!"
|
|
|