Conscript-sdk 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # sdk
  2. Import qw( SDK_NAME Q3_VER CC CXX LINK );
  3. # http://www.devdaily.com/perl/edu/articles/pl010005/pl010005.shtml
  4. #----------------------------( promptUser )-----------------------------#
  5. # #
  6. # FUNCTION: promptUser #
  7. # #
  8. # PURPOSE: Prompt the user for some type of input, and return the #
  9. # input back to the calling program. #
  10. # #
  11. # ARGS: $promptString - what you want to prompt the user with #
  12. # $defaultValue - (optional) a default value for the prompt #
  13. # #
  14. #-------------------------------------------------------------------------#
  15. sub promptUser {
  16. #-------------------------------------------------------------------#
  17. # two possible input arguments - $promptString, and $defaultValue #
  18. # make the input arguments local variables. #
  19. #-------------------------------------------------------------------#
  20. local($promptString,$defaultValue) = @_;
  21. #-------------------------------------------------------------------#
  22. # if there is a default value, use the first print statement; if #
  23. # no default is provided, print the second string. #
  24. #-------------------------------------------------------------------#
  25. if ($defaultValue) {
  26. print $promptString, "[", $defaultValue, "]: ";
  27. } else {
  28. print $promptString, ": ";
  29. }
  30. $| = 1; # force a flush after our print
  31. $_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
  32. #------------------------------------------------------------------#
  33. # remove the newline character from the end of the input the user #
  34. # gave us. #
  35. #------------------------------------------------------------------#
  36. chomp;
  37. #-----------------------------------------------------------------#
  38. # if we had a $default value, and the user gave us input, then #
  39. # return the input; if we had a default, and they gave us no #
  40. # no input, return the $defaultValue. #
  41. # #
  42. # if we did not have a default value, then just return whatever #
  43. # the user gave us. if they just hit the <enter> key, #
  44. # the calling routine will have to deal with that. #
  45. #-----------------------------------------------------------------#
  46. if ("$defaultValue") {
  47. return $_ ? $_ : $defaultValue; # return $_ if it has a value
  48. } else {
  49. return $_;
  50. }
  51. }
  52. sub launch {
  53. print("Building MOD SDK (version $Q3_VER)\n");
  54. 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");
  55. $ok = &promptUser("Ready to build mod sdk [y/n]? ");
  56. if ($ok ne 'y')
  57. {
  58. print("aborting\n");
  59. return 0;
  60. }
  61. # create the dirs:
  62. $RAW_DATA = "mod-sdk-$Q3_VER";
  63. system("rm -rf $RAW_DATA ; mkdir -p $RAW_DATA/code");
  64. # actual code
  65. system("cp -R cgame game q3_ui ui $RAW_DATA/code");
  66. # UI stuff
  67. system("cp -R ../ui $RAW_DATA");
  68. # tools
  69. system("cp -R ../lcc ../q3asm $RAW_DATA");
  70. # build scripts
  71. system("cp Construct $RAW_DATA/code");
  72. system("mkdir $RAW_DATA/code/unix ; cp unix/cons unix/pcons-2.3.1 unix/Conscript-pk3 $RAW_DATA/code/unix");
  73. system("cp unix/mod-sdk-data/Makefile $RAW_DATA/code/");
  74. # cleanup some stuff
  75. system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
  76. # test that the build works just fine
  77. $host=`hostname`; chomp($host);
  78. if ($host ne 'antares')
  79. {
  80. system("rm -rf /tmp/$RAW_DATA ; cp -R $RAW_DATA /tmp");
  81. system("cd /tmp/$RAW_DATA/code ; make");
  82. if ($? ne 0)
  83. {
  84. printf("ERROR: test build failed\n");
  85. return 0;
  86. }
  87. printf("build test successful\n");
  88. }
  89. # make a setup out of this
  90. system("cp -R unix/setup/setup.sh unix/setup/setup.data $RAW_DATA");
  91. # TODO: splash!
  92. system("cp unix/mod-sdk-data/setup.xml unix/mod-sdk-data/config.sh unix/mod-sdk-data/postinstall.sh $RAW_DATA/setup.data");
  93. # mod-sdk-data/Q3A_EULA.txt is a copy of stuff that is usually in $Q3SETUPMEDIA .. can't be arsed
  94. system("cp unix/mod-sdk-data/Q3A_EULA.txt $RAW_DATA");
  95. # I love those dirty hacks
  96. system("cd $RAW_DATA/setup.data/bin ; ln -s Linux FreeBSD ; ln -s Linux OpenBSD ; ln -s Linux NetBSD");
  97. # cleanup some stuff
  98. system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
  99. # weeee
  100. system("unix/mod-sdk-data/makeself/makeself.sh $RAW_DATA $SDK_NAME \"Quake III Arena mod SDK\" ./setup.sh $Q3_VER");
  101. return 1;
  102. }
  103. print("in Conscript-sdk\n");
  104. $env = new cons();
  105. Command $env "$SDK_NAME", "[perl] &launch()";