Gruntfile.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. var path = require('path');
  2. module.exports = function (grunt) {
  3. grunt.loadNpmTasks('grunt-contrib-jshint');
  4. grunt.loadNpmTasks('grunt-contrib-clean');
  5. grunt.loadNpmTasks('grunt-contrib-requirejs');
  6. grunt.loadNpmTasks('grunt-exec');
  7. grunt.loadTasks('./internal/grunt-tasks');
  8. grunt.loadTasks('./external/sdk/tasks');
  9. var helpers = require('./external/sdk').helpers;
  10. grunt.registerTask('default', ['peg', 'build:all']);
  11. grunt.registerTask('build:all', ['amberc:amber', 'build:cli', 'amberc:dev']);
  12. grunt.registerTask('build:cli', ['amberc:cli', 'amdconfig', 'requirejs:cli']);
  13. grunt.registerTask('test', ['amdconfig', 'requirejs:test_runner', 'exec:test_runner', 'clean:test_runner']);
  14. grunt.registerTask('devel', ['amdconfig']);
  15. grunt.initConfig({
  16. pkg: grunt.file.readJSON('package.json'),
  17. meta: {
  18. banner: '/*!\n <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n License: <%= pkg.license.type %> \n*/\n'
  19. },
  20. peg: {
  21. parser: {
  22. options: {
  23. cache: true,
  24. export_var: '$globals.SmalltalkParser'
  25. },
  26. src: 'support/parser.pegjs',
  27. dest: 'support/parser.js'
  28. }
  29. },
  30. amdconfig: {amber: {dest: 'config.js'}},
  31. amberc: {
  32. options: {
  33. amber_dir: process.cwd(),
  34. closure_jar: ''
  35. },
  36. amber: {
  37. output_dir: 'src',
  38. src: ['src/Kernel-Helpers.st',
  39. 'src/Kernel-Objects.st', 'src/Kernel-Classes.st', 'src/Kernel-Methods.st', 'src/Kernel-Collections.st',
  40. 'src/Kernel-Infrastructure.st', 'src/Kernel-Promises.st', 'src/Kernel-Exceptions.st', 'src/Kernel-Announcements.st',
  41. 'src/Platform-Services.st', 'src/Platform-ImportExport.st', 'src/Platform-Browser.st', 'src/Platform-Node.st',
  42. 'src/Platform-DOM.st',
  43. 'src/Kernel-Dag.st', 'src/Compiler-Core.st', 'src/Compiler-AST.st',
  44. 'src/Compiler-IR.st', 'src/Compiler-Inlining.st', 'src/Compiler-Semantic.st', 'src/Compiler-Interpreter.st',
  45. 'src/SUnit.st',
  46. 'src/Kernel-Tests.st', 'src/Compiler-Tests.st', 'src/Platform-DOM-Tests.st', 'src/SUnit-Tests.st'
  47. ],
  48. jsGlobals: ['navigator']
  49. },
  50. cli: {
  51. output_dir: 'external/cli/src',
  52. src: ['external/cli/src/AmberCli.st'],
  53. amd_namespace: 'amber_cli'
  54. },
  55. dev: {
  56. output_dir: 'external/sdk/lib',
  57. src: ['external/sdk/lib/NodeTestRunner.st'],
  58. amd_namespace: 'amber_devkit'
  59. }
  60. },
  61. requirejs: {
  62. options: {
  63. useStrict: true
  64. },
  65. cli: {
  66. options: {
  67. mainConfigFile: "config.js",
  68. rawText: {
  69. "__app__": "(" + function () {
  70. define(["amber/devel", "amber_core/Platform-Node", "amber_cli/AmberCli"], function (amber) {
  71. amber.initialize().then(function () {
  72. amber.globals.AmberCli._main();
  73. });
  74. });
  75. } + "());",
  76. "app": "(" + function () {
  77. define(["require", "amber/es2015-polyfills"], function (require) {
  78. require(["__app__"]);
  79. });
  80. } + "());"
  81. },
  82. pragmas: {
  83. // none, for repl to have all info
  84. },
  85. include: ['app', 'amber/lazypack', '__app__'],
  86. insertRequire: ['app'],
  87. optimize: "none",
  88. wrap: helpers.nodeWrapperWithShebang,
  89. out: "external/cli/support/amber-cli.js"
  90. }
  91. },
  92. test_runner: {
  93. options: {
  94. mainConfigFile: "config.js",
  95. rawText: {
  96. "__app__": "(" + function () {
  97. define(["amber/devel", "amber_core/Platform-Node", "amber_devkit/NodeTestRunner"], function (amber) {
  98. amber.initialize().then(function () {
  99. amber.globals.NodeTestRunner._main();
  100. });
  101. });
  102. } + "());",
  103. "app": "(" + function () {
  104. define(["require", "amber/es2015-polyfills"], function (require) {
  105. require(["__app__"]);
  106. });
  107. } + "());"
  108. },
  109. paths: {"amber_devkit": helpers.libPath},
  110. pragmas: {
  111. // none, amber tests test contexts as well as eg. class copying which needs sources
  112. },
  113. include: ['app', 'amber/lazypack', '__app__'],
  114. insertRequire: ['app'],
  115. optimize: "none",
  116. wrap: helpers.nodeWrapperWithShebang,
  117. out: "test_runner.js"
  118. }
  119. }
  120. },
  121. exec: {
  122. test_runner: 'node test_runner.js'
  123. },
  124. clean: {
  125. test_runner: ['test_runner.js']
  126. },
  127. jshint: {
  128. amber: ['src/*.js', 'support/*.js'],
  129. cli: ['external/cli/src/*.js', 'external/cli/support/*.js'],
  130. dev: ['external/sdk/lib/*.js'],
  131. grunt: ['Gruntfile.js', 'internal/grunt-tasks/*.js', 'external/sdk/tasks/*.js']
  132. }
  133. });
  134. };