--- /dev/null
+/*\r
+ Copyright 2013 Daniel Wirtz <dcode@dcode.io>\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+ */\r
+\r
+var MetaScript = require("metascript"),\r
+ path = require("path"),\r
+ fs = require("fs");\r
+\r
+var rootDir = path.join(__dirname, ".."),\r
+ srcDir = path.join(rootDir, "src"),\r
+ distDir = path.join(rootDir, "dist"),\r
+ pkg = require(path.join(rootDir, "package.json")),\r
+ filename;\r
+\r
+var scope = {\r
+ VERSION: pkg.version, // Version\r
+ DOTPROTO: true // Whether to include the ProtoBuf.DotProto package for .proto syntax support\r
+};\r
+\r
+// Make full build\r
+console.log("Building protobuf.js with scope", JSON.stringify(scope, null, 2));\r
+fs.writeFileSync(\r
+ path.join(distDir, "protobuf.js"),\r
+ MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)\r
+);\r
+\r
+// Make light build\r
+scope.DOTPROTO = false;\r
+console.log("Building protobuf-light.js with scope", JSON.stringify(scope, null, 2));\r
+fs.writeFileSync(\r
+ path.join(distDir, "protobuf-light.js"),\r
+ MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)\r
+);\r
+\r
+// Update bower.json\r
+scope = { VERSION: pkg.version };\r
+console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));\r
+fs.writeFileSync(\r
+ path.join(rootDir, "bower.json"),\r
+ MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json.in")), filename, scope, srcDir)\r
+);\r