Skip to content

Commit

Permalink
Merge pull request cocos2d#15130 from chengstory/AddUseLocalScriptCom…
Browse files Browse the repository at this point in the history
…mand

Add "-use-local-script" command param.

It's OK for me, merged.
  • Loading branch information
xiaofeng11 committed Feb 29, 2016
2 parents 9af2f4e + c449f61 commit 8bf3d33
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
41 changes: 39 additions & 2 deletions tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ProjectConfig::ProjectConfig()
, _consolePort(kProjectConfigConsolePort)
, _fileUploadPort(kProjectConfigUploadPort)
, _bindAddress("")
, _useLocalScript(false)
{
normalize();
}
Expand Down Expand Up @@ -272,6 +273,17 @@ void ProjectConfig::setDebuggerType(int debuggerType)
_debuggerType = debuggerType;
}


bool ProjectConfig::isUseLocalScript() const
{
return _useLocalScript;
}

void ProjectConfig::setUseLocalScript(bool useLocalScript)
{
_useLocalScript = useLocalScript;
}

void ProjectConfig::parseCommandLine(const vector<string> &args)
{
auto it = args.begin();
Expand Down Expand Up @@ -409,7 +421,19 @@ void ProjectConfig::parseCommandLine(const vector<string> &args)
vector<string> pathes = split((*it), ';');
setSearchPath(pathes);
}

else if (arg.compare("-use-local-script") == 0)
{
++it;
if (it == args.end()) break;
if ((*it).compare("enable") == 0)
{
setUseLocalScript(true);
}
else
{
setUseLocalScript(false);
}
}
++it;
}
}
Expand Down Expand Up @@ -571,7 +595,20 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(pathArgs);
}
}


if (mask & kProjectConfigUseLocalScript)
{
if (isUseLocalScript())
{
ret.push_back("-use-local-script");
ret.push_back("enable");
}
else
{
ret.push_back("-use-local-script");
ret.push_back("disable");
}
}
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using namespace std;
#define kProjectConfigDebugger 1024 // -debugger-ldt, -debugger-codeide, -disable-debugger
#define kProjectConfigListen 2048 //
#define kProjectConfigSearchPath 4096 //
#define kProjectConfigUseLocalScript 8192 // -use-local-script

#define kProjectConfigOpenRecent (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile)

Expand Down Expand Up @@ -104,7 +105,10 @@ class CC_LIBSIM_DLL ProjectConfig
const std::string &getBindAddress() const;
void setSearchPath(const vector<string> &args);
const vector<string> &getSearchPath() const;


bool isUseLocalScript() const;
void setUseLocalScript(bool useLocalScript);

bool isAppMenu() const;
bool isResizeWindow() const;
bool isRetinaDisplay() const;
Expand Down Expand Up @@ -133,6 +137,7 @@ class CC_LIBSIM_DLL ProjectConfig
int _fileUploadPort;
string _bindAddress;
vector<string> _searchPath;
bool _useLocalScript;

void normalize();
string replaceProjectDirToMacro(const string &path) const;
Expand Down
8 changes: 6 additions & 2 deletions tools/simulator/libsimulator/lib/runtime/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ void RuntimeEngine::setProjectPath(const std::string &workPath)
g_projectPath = workPath;
}

// add project's root directory to search path
searchPathArray.insert(searchPathArray.begin(), g_projectPath);
if (!_project.isUseLocalScript())
{
// add project's root directory to search path
searchPathArray.insert(searchPathArray.begin(), g_projectPath);
}


// add writable path to search path
searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath());
Expand Down

0 comments on commit 8bf3d33

Please sign in to comment.