You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. ## Syntax:
  3. ## php build.php { <platform> | all }
  4. ## ('all' builds for all available platforms)
  5. ##
  6. ## This script will create build/ and build/<platform> if needed, then will
  7. ## copy files from src/ and src/platform/<platform> into build/<platform>/.
  8. ## The extension can then be loaded from build/<platform>.
  9. ## No platform specified.
  10. if ($argc < 2) {
  11. echo "Syntax is:\n";
  12. echo "\tphp build.php { <platform> | all }\n";
  13. }
  14. ## Determine path to repository root.
  15. $root = dirname(__FILE__);
  16. ## Determine what platforms are available.
  17. $platforms = array_filter(scandir("{$root}/src/platform/"), function ($str) {
  18. return strncmp($str, ".", 1);
  19. });
  20. ## No platform specified, or specified platform does not exist.
  21. ## NOTE: specifying 'all' will build for all platforms.
  22. if ($argc < 2 || !(in_array($argv[1], $platforms) || $argv[1] == "all")) {
  23. echo "Available platforms are:\n";
  24. foreach ($platforms as $platform)
  25. echo "\t{$platform}\n";
  26. die;
  27. }
  28. ## Build for specified platform (or for all platforms, if 'all' is given).
  29. if ($argv[1] == "all") {
  30. foreach ($platforms as $platform) {
  31. build_for_platform($platform);
  32. }
  33. } else {
  34. build_for_platform($argv[1]);
  35. }
  36. function build_for_platform($platform) {
  37. global $root;
  38. echo "Building for: {$platform}\n";
  39. $command = "cd {$root}; ";
  40. $command .= "mkdir -p build/{$platform}; ";
  41. $command .= "rm -rf build/{$platform}/*; ";
  42. $command .= "cp -R src/{*.js,*.html,*.css,fonts,images} build/{$platform}/; ";
  43. $command .= "cp -R src/platform/{$platform}/* build/{$platform}/";
  44. `bash -c "{$command}"`;
  45. }
  46. ?>