ioef/code/unix/Conscript-sdk

123 lines
5 KiB
Text
Raw Normal View History

2005-08-26 17:39:27 +00:00
# sdk
Import qw( SDK_NAME Q3_VER CC CXX LINK );
# http://www.devdaily.com/perl/edu/articles/pl010005/pl010005.shtml
#----------------------------( promptUser )-----------------------------#
# #
# FUNCTION: promptUser #
# #
# PURPOSE: Prompt the user for some type of input, and return the #
# input back to the calling program. #
# #
# ARGS: $promptString - what you want to prompt the user with #
# $defaultValue - (optional) a default value for the prompt #
# #
#-------------------------------------------------------------------------#
sub promptUser {
#-------------------------------------------------------------------#
# two possible input arguments - $promptString, and $defaultValue #
# make the input arguments local variables. #
#-------------------------------------------------------------------#
local($promptString,$defaultValue) = @_;
#-------------------------------------------------------------------#
# if there is a default value, use the first print statement; if #
# no default is provided, print the second string. #
#-------------------------------------------------------------------#
if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
#------------------------------------------------------------------#
# remove the newline character from the end of the input the user #
# gave us. #
#------------------------------------------------------------------#
chomp;
#-----------------------------------------------------------------#
# if we had a $default value, and the user gave us input, then #
# return the input; if we had a default, and they gave us no #
# no input, return the $defaultValue. #
# #
# if we did not have a default value, then just return whatever #
# the user gave us. if they just hit the <enter> key, #
# the calling routine will have to deal with that. #
#-----------------------------------------------------------------#
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}
}
sub launch {
print("Building MOD SDK (version $Q3_VER)\n");
print("Before building the mod sdk, your CVS tree must be completely clean!\nIf there are some temporary files and binaries in the tree, they can get included in the distribution and cause problems.\n");
$ok = &promptUser("Ready to build mod sdk [y/n]? ");
if ($ok ne 'y')
{
print("aborting\n");
return 0;
}
# create the dirs:
$RAW_DATA = "mod-sdk-$Q3_VER";
system("rm -rf $RAW_DATA ; mkdir -p $RAW_DATA/code");
# actual code
system("cp -R cgame game q3_ui ui $RAW_DATA/code");
# UI stuff
system("cp -R ../ui $RAW_DATA");
# tools
system("cp -R ../lcc ../q3asm $RAW_DATA");
# build scripts
system("cp Construct $RAW_DATA/code");
system("mkdir $RAW_DATA/code/unix ; cp unix/cons unix/pcons-2.3.1 unix/Conscript-pk3 $RAW_DATA/code/unix");
system("cp unix/mod-sdk-data/Makefile $RAW_DATA/code/");
# cleanup some stuff
system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
# test that the build works just fine
$host=`hostname`; chomp($host);
if ($host ne 'antares')
{
system("rm -rf /tmp/$RAW_DATA ; cp -R $RAW_DATA /tmp");
system("cd /tmp/$RAW_DATA/code ; make");
if ($? ne 0)
{
printf("ERROR: test build failed\n");
return 0;
}
printf("build test successful\n");
}
# make a setup out of this
system("cp -R unix/setup/setup.sh unix/setup/setup.data $RAW_DATA");
# TODO: splash!
system("cp unix/mod-sdk-data/setup.xml unix/mod-sdk-data/config.sh unix/mod-sdk-data/postinstall.sh $RAW_DATA/setup.data");
# mod-sdk-data/Q3A_EULA.txt is a copy of stuff that is usually in $Q3SETUPMEDIA .. can't be arsed
system("cp unix/mod-sdk-data/Q3A_EULA.txt $RAW_DATA");
# I love those dirty hacks
system("cd $RAW_DATA/setup.data/bin ; ln -s Linux FreeBSD ; ln -s Linux OpenBSD ; ln -s Linux NetBSD");
# cleanup some stuff
system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
# weeee
system("unix/mod-sdk-data/makeself/makeself.sh $RAW_DATA $SDK_NAME \"Quake III Arena mod SDK\" ./setup.sh $Q3_VER");
return 1;
}
print("in Conscript-sdk\n");
$env = new cons();
Command $env "$SDK_NAME", "[perl] &launch()";