diff options
author | Joe George <joe@zeroc.com> | 2015-04-23 14:33:12 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2015-04-23 14:35:45 -0400 |
commit | 8a1b65e8f91a442be280b5ba53cc76937b5f16b3 (patch) | |
tree | db2462a40b516641ae0dd70facf3e51fc44e2041 /cpp | |
parent | Make js use npm ice-gulp-builder package (diff) | |
download | ice-8a1b65e8f91a442be280b5ba53cc76937b5f16b3.tar.bz2 ice-8a1b65e8f91a442be280b5ba53cc76937b5f16b3.tar.xz ice-8a1b65e8f91a442be280b5ba53cc76937b5f16b3.zip |
ICE-6466 - Replace --icejs metadata js:ice-build
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 29 | ||||
-rw-r--r-- | cpp/src/slice2js/Gen.h | 5 | ||||
-rw-r--r-- | cpp/src/slice2js/Main.cpp | 26 |
3 files changed, 30 insertions, 30 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 9ad4b2d63a4..0f14a9be27e 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -617,9 +617,8 @@ Slice::JsVisitor::writeDocComment(const ContainedPtr& p, const string& deprecate _out << nl << " **/"; } -Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, bool icejs) : +Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir) : _includePaths(includePaths), - _icejs(icejs), _useStdout(false) { _fileBase = base; @@ -650,10 +649,9 @@ Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const st printGeneratedHeader(_out, _fileBase + ".ice"); } -Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, bool icejs, ostream& out) : +Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir, ostream& out) : _out(out), _includePaths(includePaths), - _icejs(icejs), _useStdout(true) { _fileBase = base; @@ -678,7 +676,16 @@ Slice::Gen::~Gen() void Slice::Gen::generate(const UnitPtr& p) { - if(_icejs) + // + // Check for global "js:ice-build" metadata. + // If this is set then we are building Ice. + // + DefinitionContextPtr dc = p->findDefinitionContext(p->topLevelFile()); + assert(dc); + StringList globalMetaData = dc->getMetaData(); + bool icejs = find(globalMetaData.begin(), globalMetaData.end(), "js:ice-build") != globalMetaData.end(); + + if(icejs) { _out.zeroIndent(); _out << nl << "/* slice2js browser-bundle-skip */"; @@ -686,26 +693,26 @@ Slice::Gen::generate(const UnitPtr& p) } _out << nl << "(function(module, require, exports)"; _out << sb; - if(_icejs) + if(icejs) { _out.zeroIndent(); _out << nl << "/* slice2js browser-bundle-skip-end */"; _out.restoreIndent(); } - RequireVisitor requireVisitor(_out, _includePaths, _icejs); + RequireVisitor requireVisitor(_out, _includePaths, icejs); p->visit(&requireVisitor, false); vector<string> seenModules = requireVisitor.writeRequires(p); - TypesVisitor typesVisitor(_out, seenModules, _icejs); + TypesVisitor typesVisitor(_out, seenModules, icejs); p->visit(&typesVisitor, false); // // Export the top-level modules. // - ExportVisitor exportVisitor(_out, _icejs); + ExportVisitor exportVisitor(_out, icejs); p->visit(&exportVisitor, false); - if(_icejs) + if(icejs) { _out.zeroIndent(); _out << nl << "/* slice2js browser-bundle-skip */"; @@ -717,7 +724,7 @@ Slice::Gen::generate(const UnitPtr& p) << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? require : window.Ice.__require," << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? exports : window));"; - if(_icejs) + if(icejs) { _out.zeroIndent(); _out << nl << "/* slice2js browser-bundle-skip-end */"; diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h index 8b788ae334b..3c9781471c7 100644 --- a/cpp/src/slice2js/Gen.h +++ b/cpp/src/slice2js/Gen.h @@ -53,13 +53,11 @@ public: Gen(const std::string&, const std::vector<std::string>&, - const std::string&, - bool); + const std::string&); Gen(const std::string&, const std::vector<std::string>&, const std::string&, - bool, std::ostream&); ~Gen(); @@ -73,7 +71,6 @@ private: std::vector<std::string> _includePaths; std::string _fileBase; - bool _icejs; bool _useStdout; void printHeader(); diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index 35aca5463d4..b751dd295bf 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -75,7 +75,6 @@ usage(const char* n) "-d, --debug Print debug messages.\n" "--ice Permit `Ice' prefix (for building Ice source code only).\n" "--underscore Permit underscores in Slice identifiers.\n" - "--icejs Build icejs module\n" ; } @@ -98,7 +97,6 @@ compile(int argc, char* argv[]) opts.addOpt("d", "debug"); opts.addOpt("", "ice"); opts.addOpt("", "underscore"); - opts.addOpt("", "icejs"); vector<string> args; try @@ -146,11 +144,11 @@ compile(int argc, char* argv[]) bool preprocess = opts.isSet("E"); bool useStdout = opts.isSet("stdout"); - + string output = opts.optArg("output-dir"); bool depend = opts.isSet("depend"); - + bool dependJSON = opts.isSet("depend-json"); bool dependxml = opts.isSet("depend-xml"); @@ -163,8 +161,6 @@ compile(int argc, char* argv[]) bool underscore = opts.isSet("underscore"); - bool icejs = opts.isSet("icejs"); - if(args.empty()) { getErrorStream() << argv[0] << ": error: no input file" << endl; @@ -207,7 +203,7 @@ compile(int argc, char* argv[]) { out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl; } - + // // Create a copy of args without the duplicates. // @@ -220,9 +216,9 @@ compile(int argc, char* argv[]) sources.push_back(*i); } } - + for(vector<string>::const_iterator i = sources.begin(); i != sources.end();) - { + { if(depend || dependJSON || dependxml) { PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); @@ -243,9 +239,9 @@ compile(int argc, char* argv[]) out.cleanup(); return EXIT_FAILURE; } - + bool last = (++i == sources.end()); - + if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::JavaScript : (dependJSON ? Preprocessor::JavaScriptJSON : Preprocessor::SliceXML), includePaths, @@ -260,7 +256,7 @@ compile(int argc, char* argv[]) out.cleanup(); return EXIT_FAILURE; } - + if(dependJSON) { if(!last) @@ -315,12 +311,12 @@ compile(int argc, char* argv[]) { if(useStdout) { - Gen gen(icecpp->getBaseName(), includePaths, output, icejs, cout); + Gen gen(icecpp->getBaseName(), includePaths, output, cout); gen.generate(p); } else { - Gen gen(icecpp->getBaseName(), includePaths, output, icejs); + Gen gen(icecpp->getBaseName(), includePaths, output); gen.generate(p); } } @@ -352,7 +348,7 @@ compile(int argc, char* argv[]) } } } - + if(dependJSON) { out.os() << "}" << endl; |