Files
gtav-src/tools_ng/lib/util/ragebuilder/build_rpf.rbs
T
2025-09-29 00:52:08 +02:00

156 lines
4.5 KiB
Plaintext
Executable File

----
-- File:: %RS_TOOLSLIB%/util/ragebuilder/build_rpf.rbs
-- Description:: Build RPF file from a directory.
--
-- Author:: David Muir <david.muir@rockstarnorth.com>
-- Date:: 24 June 2011
--
-- Example Usage:
-- (simple, just specify files on command line)
--
-- ragebuilder_0378 %RS_TOOLSLIB%\util\ragebuilder\build_rpf.rbs
-- -output x:\test.rpf
-- -platform xenon
-- infile1.txt infile2.bmp
--
-- OR
--
-- (using filelist input file, only way for directories to exist)
--
-- ragebuilder_0378 %RS_TOOLSLIB%\util\ragebuilder\build_rpf.rbs
-- -output x:\test.rpf
-- -platform xenon
-- -filelist filelist.txt
--
-----------------------------------------------------------------------------
-- Uses
-----------------------------------------------------------------------------
local shader = get_param( "shader" )
local shaderdb = get_param( "shaderdb" )
local platform = get_param( "platform" )
local output_filename = get_param( "output" )
local file_index = 5
local file_list = get_param( "filelist" )
local show_help = get_param( "info" )
local taskname = get_param( "taskname" )
local noshaders = get_param( "noshaders" )
-----------------------------------------------------------------------------
-- Functions
-----------------------------------------------------------------------------
function help( )
display( "" )
display( get_parambyindex(0) .. " build_rpf.rbs <options>" )
display( "" )
display( "\noptions:" )
display( "\t-output <filename>" )
display( "\t[-taskname <name>]" )
display( "\t Asset Pipeline 3, for log parsing" )
display( "\t[-platform target]" )
display( "\t Where target is win32|ps3|xenon." )
display( "\t[-filelist <textfile>]" )
display( "\t Where textfile is a textfile of tab separated source, destination pairs." )
display( "\t<filelist>" )
display( "\t Simple RPF build when -filelist is not specified." )
display( "\t[-noshaders]")
display( "\t Don't set a shader path" )
display( "" )
return 0
end
-----------------------------------------------------------------------------
-- Parameter Checking
-----------------------------------------------------------------------------
if ( nil == noshaders) then
set_shaderpath( shader )
set_shaderdbpath( shaderdb )
end
if ( nil ~= show_help ) then
return help()
end
if ( nil == file_list ) then
file_index = file_index + 1
end
if ( get_paramcount() < 5 ) then
error( "No filelist or files specified on command line. Aborting." )
return 1
end
if ( nil == output_filename ) then
error( "No output file specified on command line. Aborting." )
return 1
end
if ( nil == platform ) then
set_platform( "independent" )
warning( "No platform specified; autodetected at compression stage." )
else
set_platform( platform )
end
if ( taskname ~= nil ) then
display( "TASK: " .. taskname )
end
-----------------------------------------------------------------------------
-- Main
-----------------------------------------------------------------------------
if ( "xenon" == platform ) then
start_pack_xcompress( )
elseif ( ( "ps3" == platform ) or ( "win32" == platform ) ) then
start_pack_zlib( )
else
start_pack( )
end
-- Handle case where we have been specified a file list; only way to alter
-- paths used in an RPF.
if ( nil == file_list ) then
-- Loop through our command-line parameters; assuming they are files.
for i = file_index, get_paramcount()-1 do
filename = get_parambyindex( i )
add_to_pack( filename, get_filename_from_path( filename ) )
end
else
input_files = {}
output_files = {}
local index = 0
-- display( "Reading inputs from ".. file_list);
for line in io.lines( file_list ) do
local sep_index = string.find( line, "\t" )
if ( nil == sep_index ) then
-- if no tab, assume intput and output are the same
table.insert( input_files, line )
table.insert( output_files, line )
else
local len = string.len( line )
local src = string.sub( line, 1, sep_index - 1 )
local dst = string.sub( line, sep_index + 1 )
table.insert( input_files, src )
table.insert( output_files, dst )
end
index = index + 1
end
display( "Creating RPF with " .. table.getn( input_files ) .. " entries." )
-- Loop through our filelist pairs.
for n = 1, table.getn( input_files ) do
add_to_pack( input_files[n], output_files[n] )
end
end
save_pack( output_filename )
close_pack( )
-- %RS_TOOLSLIB%/util/ragebuilder/build_rpf.rbs