@@ -1029,7 +1029,18 @@ module.exports = function(grunt) {
10291029 return tasks ;
10301030 }
10311031
1032- grunt . registerTask ( 'base' , [
1032+ // Returns a task name that will run the input task only once if
1033+ // called multiple times.
1034+ function makeRunOnce ( taskName ) {
1035+ return 'run-once:' + taskName ;
1036+ }
1037+
1038+ // Register a task, making sure subtasks only run once.
1039+ function registerTask ( grunt , taskName , subTasks ) {
1040+ return grunt . registerTask ( taskName , subTasks . map ( makeRunOnce ) ) ;
1041+ }
1042+
1043+ registerTask ( grunt , 'base' , [
10331044 'copy:resources' ,
10341045 'copy:devGenericCore' ,
10351046 'ts' ,
@@ -1043,95 +1054,95 @@ module.exports = function(grunt) {
10431054 'browserify:cloudSocialProviderFreedomModule' ,
10441055 'browserify:digitalOceanFreedomModule'
10451056 ] ) ;
1046- grunt . registerTask ( 'echoServer' , [
1057+ registerTask ( grunt , 'echoServer' , [
10471058 'base' ,
10481059 'browserify:echoServerFreedomModule' ,
10491060 'copy:libsForEchoServerChromeApp' ,
10501061 'copy:libsForEchoServerFirefoxApp' ,
10511062 'copy:libsForEchoServerNode'
10521063 ] ) ;
1053- grunt . registerTask ( 'copypasteChat' , [
1064+ registerTask ( grunt , 'copypasteChat' , [
10541065 'base' ,
10551066 'browserify:copypasteChatFreedomModule' ,
10561067 'browserify:copypasteChatMain' ,
10571068 'copy:libsForCopypasteChatChromeApp' ,
10581069 'copy:libsForCopypasteChatFirefoxApp' ,
10591070 'copy:libsForCopypasteChatWebApp'
10601071 ] ) ;
1061- grunt . registerTask ( 'copypasteSocks' , [
1072+ registerTask ( grunt , 'copypasteSocks' , [
10621073 'base' ,
10631074 'browserify:copypasteSocksFreedomModule' ,
10641075 'browserify:copypasteSocksMain' ,
10651076 'vulcanize:copypasteSocks' ,
10661077 'copy:libsForCopyPasteSocksChromeApp' ,
10671078 'copy:libsForCopyPasteSocksFirefoxApp'
10681079 ] ) ;
1069- grunt . registerTask ( 'deployer' , [
1080+ registerTask ( grunt , 'deployer' , [
10701081 'base' ,
10711082 'browserify:deployerFreedomModule' ,
10721083 'copy:libsForDeployerChromeApp' ,
10731084 'copy:libsForDeployerFirefoxApp'
10741085 ] ) ;
1075- grunt . registerTask ( 'simpleChat' , [
1086+ registerTask ( grunt , 'simpleChat' , [
10761087 'base' ,
10771088 'browserify:simpleChatFreedomModule' ,
10781089 'browserify:simpleChatMain' ,
10791090 'copy:libsForSimpleChatChromeApp' ,
10801091 'copy:libsForSimpleChatFirefoxApp' ,
10811092 'copy:libsForSimpleChatWebApp'
10821093 ] ) ;
1083- grunt . registerTask ( 'simpleSocks' , [
1094+ registerTask ( grunt , 'simpleSocks' , [
10841095 'base' ,
10851096 'browserify:simpleSocksFreedomModule' ,
10861097 'copy:libsForSimpleSocksChromeApp' ,
10871098 'copy:libsForSimpleSocksFirefoxApp' ,
10881099 'copy:libsForSimpleSocksNode'
10891100 ] ) ;
1090- grunt . registerTask ( 'uprobe' , [
1101+ registerTask ( grunt , 'uprobe' , [
10911102 'base' ,
10921103 'browserify:uprobeFreedomModule' ,
10931104 'copy:libsForUprobeChromeApp' ,
10941105 'copy:libsForUprobeFirefoxApp'
10951106 ] ) ;
1096- grunt . registerTask ( 'zork' , [
1107+ registerTask ( grunt , 'zork' , [
10971108 'base' ,
10981109 'browserify:zorkFreedomModule' ,
10991110 'copy:libsForZorkChromeApp' ,
11001111 'copy:libsForZorkFirefoxApp' ,
11011112 'copy:libsForZorkNode' ,
11021113 'exec:installFreedomForNodeForZork'
11031114 ] ) ;
1104- grunt . registerTask ( 'version_file' , [
1115+ registerTask ( grunt , 'version_file' , [
11051116 'gitinfo' ,
11061117 'string-replace:version'
11071118 ] ) ;
1108- grunt . registerTask ( 'build_chrome_app' , [
1119+ registerTask ( grunt , 'build_chrome_app' , [
11091120 'base' ,
11101121 'copy:chrome_app'
11111122 ] . concat ( fullyVulcanize ( 'chrome/app/polymer' , 'ext-missing' , 'vulcanized' ) ) ) ;
1112- grunt . registerTask ( 'build_chrome_ext' , [
1123+ registerTask ( grunt , 'build_chrome_ext' , [
11131124 'base' ,
11141125 'copy:chrome_extension' ,
11151126 'copy:chrome_extension_additional' ,
11161127 'browserify:chromeExtMain' ,
11171128 'browserify:chromeContext'
11181129 ] . concat ( fullyVulcanize ( 'chrome/extension/generic_ui/polymer' , 'root' , 'vulcanized' , true ) ) ) ;
11191130
1120- grunt . registerTask ( 'build_chrome' , [
1131+ registerTask ( grunt , 'build_chrome' , [
11211132 'build_chrome_app' ,
11221133 'build_chrome_ext'
11231134 ] ) ;
11241135
11251136 // Firefox build tasks.
1126- grunt . registerTask ( 'build_firefox' , [
1137+ registerTask ( grunt , 'build_firefox' , [
11271138 'base' ,
11281139 'copy:firefox' ,
11291140 'copy:firefox_additional' ,
11301141 'browserify:firefoxContext'
11311142 ] . concat ( fullyVulcanize ( 'firefox/data/generic_ui/polymer' , 'root' , 'vulcanized' , true ) ) ) ;
11321143
11331144 // CCA build tasks
1134- grunt . registerTask ( 'build_cca' , [
1145+ registerTask ( grunt , 'build_cca' , [
11351146 'base' ,
11361147 'copy:cca' ,
11371148 'copy:cca_additional' ,
@@ -1140,7 +1151,7 @@ module.exports = function(grunt) {
11401151 ] . concat ( fullyVulcanize ( 'cca/app/generic_ui/polymer' , 'root' , 'vulcanized' , true ) ) ) ;
11411152
11421153 // Mobile OS build tasks
1143- grunt . registerTask ( 'build_android' , [
1154+ registerTask ( grunt , 'build_android' , [
11441155 'exec:cleanAndroid' ,
11451156 'build_cca' ,
11461157 'exec:ccaCreateDev' ,
@@ -1150,7 +1161,7 @@ module.exports = function(grunt) {
11501161 'exec:ccaBuildAndroid' ,
11511162 'exec:androidReplaceXwalkDev'
11521163 ] ) ;
1153- grunt . registerTask ( 'release_android' , [
1164+ registerTask ( grunt , 'release_android' , [
11541165 'build_cca' ,
11551166 'copy:dist' ,
11561167 'exec:ccaCreateDist' ,
@@ -1163,47 +1174,47 @@ module.exports = function(grunt) {
11631174 ] ) ;
11641175
11651176 // Emulate the mobile client for android
1166- grunt . registerTask ( 'emulate_android' , [
1177+ registerTask ( grunt , 'emulate_android' , [
11671178 'build_android' ,
11681179 'exec:ccaEmulateAndroid'
11691180 ] ) ;
11701181
1171- grunt . registerTask ( 'build_ios' , [
1182+ registerTask ( grunt , 'build_ios' , [
11721183 'exec:cleanIos' ,
11731184 'build_cca' ,
11741185 'exec:ccaCreateIosDev' ,
11751186 'exec:ccaAddPluginsIosBuild' ,
11761187 'exec:addIosrtcHook' ,
11771188 'exec:ccaPrepareIosDev'
11781189 ] ) ;
1179- grunt . registerTask ( 'test_chrome' , [
1190+ registerTask ( grunt , 'test_chrome' , [
11801191 'build_chrome' ,
11811192 'browserify:chromeExtensionCoreConnectorSpec' ,
11821193 'jasmine:chrome_core_connector'
11831194 ] ) ;
1184- grunt . registerTask ( 'tcpIntegrationTestModule' , [
1195+ registerTask ( grunt , 'tcpIntegrationTestModule' , [
11851196 'base' ,
11861197 'copy:libsForIntegrationTcp' ,
11871198 'browserify:integrationTcpFreedomModule' ,
11881199 'browserify:integrationTcpSpec'
11891200 ] ) ;
1190- grunt . registerTask ( 'tcpIntegrationTest' , [
1201+ registerTask ( grunt , 'tcpIntegrationTest' , [
11911202 'tcpIntegrationTestModule' ,
11921203 'jasmine_chromeapp:tcp'
11931204 ] ) ;
1194- grunt . registerTask ( 'socksEchoIntegrationTestModule' , [
1205+ registerTask ( grunt , 'socksEchoIntegrationTestModule' , [
11951206 'base' ,
11961207 'copy:libsForIntegrationSocksEcho' ,
11971208 'browserify:integrationSocksEchoFreedomModule' ,
11981209 'browserify:integrationSocksEchoChurnSpec' ,
11991210 'browserify:integrationSocksEchoNochurnSpec' ,
12001211 'browserify:integrationSocksEchoSlowSpec'
12011212 ] ) ;
1202- grunt . registerTask ( 'socksEchoIntegrationTest' , [
1213+ registerTask ( grunt , 'socksEchoIntegrationTest' , [
12031214 'socksEchoIntegrationTestModule' ,
12041215 'jasmine_chromeapp:socksEcho'
12051216 ] ) ;
1206- grunt . registerTask ( 'unit_test_nobuild' , _ . flatten ( [ ] . concat (
1217+ registerTask ( grunt , 'unit_test_nobuild' , _ . flatten ( [ ] . concat (
12071218 Rule . getTests ( 'src' , 'lib' , [ 'build-tools' , 'integration-tests' ] ) ,
12081219 Rule . getTests ( 'src' , 'generic_core' ) ,
12091220 Rule . getTests ( 'src' , 'generic_ui/scripts' )
@@ -1212,40 +1223,40 @@ module.exports = function(grunt) {
12121223 } )
12131224 ) ) ;
12141225
1215- grunt . registerTask ( 'unit_test' , [
1226+ registerTask ( grunt , 'unit_test' , [
12161227 'base' ,
12171228 'unit_test_nobuild'
12181229 ] ) ;
12191230 // TODO: add test_chrome once it passes reliably
1220- grunt . registerTask ( 'integration_test' , [
1231+ registerTask ( grunt , 'integration_test' , [
12211232 'tcpIntegrationTest' ,
12221233 'socksEchoIntegrationTest'
12231234 ] ) ;
1224- grunt . registerTask ( 'test' , [
1235+ registerTask ( grunt , 'test' , [
12251236 'unit_test' ,
12261237 'integration_test'
12271238 ] ) ;
12281239 // Builds all code, including the "dist" build, but skips
12291240 // iOS and Android as well as
12301241 // ts-linting and testing which can be annoying and slow.
12311242 // We added jshint here because catches hard syntax errors, etc.
1232- grunt . registerTask ( 'build' , [
1243+ registerTask ( grunt , 'build' , [
12331244 'build_chrome' ,
12341245 'build_firefox' ,
12351246 'build_cca' ,
12361247 'jshint' ,
12371248 'copy:dist' ,
12381249 'jpm:xpi'
12391250 ] ) ;
1240- grunt . registerTask ( 'lint' , [ 'tslint' ] ) ;
1251+ registerTask ( grunt , 'lint' , [ 'tslint' ] ) ;
12411252 // This is run prior to releasing uProxy and, in addition to
12421253 // building, tests and lints all code.
1243- grunt . registerTask ( 'dist' , [
1254+ registerTask ( grunt , 'dist' , [
12441255 'build' ,
12451256 'lint' ,
12461257 'test'
12471258 ] ) ;
1248- grunt . registerTask ( 'default' , [ 'build' ] ) ;
1259+ registerTask ( grunt , 'default' , [ 'build' ] ) ;
12491260
12501261 //-------------------------------------------------------------------------
12511262 grunt . loadNpmTasks ( 'grunt-browserify' ) ;
@@ -1259,6 +1270,7 @@ module.exports = function(grunt) {
12591270 grunt . loadNpmTasks ( 'grunt-gitinfo' ) ;
12601271 grunt . loadNpmTasks ( 'grunt-jasmine-chromeapp' ) ;
12611272 grunt . loadNpmTasks ( 'grunt-jpm' ) ;
1273+ grunt . loadNpmTasks ( 'grunt-run-once' ) ;
12621274 grunt . loadNpmTasks ( 'grunt-string-replace' ) ;
12631275 grunt . loadNpmTasks ( 'grunt-ts' ) ;
12641276 grunt . loadNpmTasks ( 'grunt-tslint' ) ;
0 commit comments