1
0

Gruntfile.js 5.8 KB

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