1
0

Gruntfile.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. "helios/index": "",
  73. "__app__": "(" + function () {
  74. define(["amber/devel", "amber/core/Platform-Node", "amber_cli/AmberCli"], function (amber) {
  75. amber.initialize().then(function () {
  76. amber.globals.AmberCli._main();
  77. });
  78. });
  79. } + "());",
  80. "app": '(' + polyfillThenPromiseApp + '());'
  81. },
  82. pragmas: {
  83. // none, for repl to have all info
  84. },
  85. include: ['app'],
  86. findNestedDependencies: true,
  87. exclude: ['helios/index'],
  88. insertRequire: ['app'],
  89. optimize: "none",
  90. wrap: helpers.nodeWrapperWithShebang,
  91. out: "cli/dist/amber-cli.js"
  92. }
  93. },
  94. test_runner: {
  95. options: {
  96. mainConfigFile: "config.js",
  97. rawText: {
  98. "helios/index": "",
  99. "__app__": "(" + function () {
  100. define(["amber/devel", "amber/core/Platform-Node", "amber_devkit/NodeTestRunner"], function (amber) {
  101. amber.initialize().then(function () {
  102. amber.globals.NodeTestRunner._main();
  103. });
  104. });
  105. } + "());",
  106. "app": '(' + polyfillThenPromiseApp + '());'
  107. },
  108. paths: {"amber_devkit": helpers.libPath},
  109. pragmas: {
  110. // none, amber tests test contexts as well as eg. class copying which needs sources
  111. },
  112. include: ['app'],
  113. findNestedDependencies: true,
  114. exclude: ['helios/index'],
  115. insertRequire: ['app'],
  116. optimize: "none",
  117. wrap: helpers.nodeWrapperWithShebang,
  118. out: "test_runner.js"
  119. }
  120. }
  121. },
  122. exec: {
  123. build_parser: 'cd lang && npm run build:parser',
  124. test_runner: 'node test_runner.js'
  125. },
  126. clean: {
  127. test_runner: ['test_runner.js']
  128. },
  129. jshint: {
  130. amber: ['lang/src/*.js', 'lang/base/[^p]*.js'],
  131. cli: ['cli/src/*.js', 'cli/dist/*.js'],
  132. dev: ['sdk/lib/*.js'],
  133. grunt: ['Gruntfile.js', 'grunt-tasks/*.js', 'sdk/tasks/*.js']
  134. }
  135. });
  136. };