WebKit Bugzilla
Attachment 361799 Details for
Bug 194542
: [JSC] Add JSC shell support for systems that don't provide a working directory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add --working-directory and related code
194542.1.diff (text/plain), 4.82 KB, created by
Stephan Szabo
on 2019-02-12 08:54:30 PST
(
hide
)
Description:
Add --working-directory and related code
Filename:
MIME Type:
Creator:
Stephan Szabo
Created:
2019-02-12 08:54:30 PST
Size:
4.82 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 562101bcb5c..185e1f96231 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-12 Stephan Szabo <stephan.szabo@sony.com> >+ >+ [JSC] Add JSC shell support for systems that don't provide a working directory >+ https://bugs.webkit.org/show_bug.cgi?id=194542 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * jsc.cpp: >+ Add --working-directory option to set the working directory. >+ When a directory is provided with above, use absolute paths >+ for file access from fillBufferWithContentsOfFile. >+ > 2019-02-09 Yusuke Suzuki <ysuzuki@apple.com> > > Unreviewed, Lexer should use isLatin1 implementation in WTF >diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp >index be0180605e6..21510f01246 100644 >--- a/Source/JavaScriptCore/jsc.cpp >+++ b/Source/JavaScriptCore/jsc.cpp >@@ -156,6 +156,8 @@ struct MemoryFootprint { > #define PATH_MAX 4096 > #endif > >+Optional<String> s_workingDirectory; >+ > using namespace JSC; > > namespace { >@@ -425,6 +427,7 @@ public: > bool m_dumpMemoryFootprint { false }; > bool m_dumpSamplingProfilerData { false }; > bool m_enableRemoteDebugging { false }; >+ String m_workingDirectory; > > void parseArguments(int, char**); > }; >@@ -727,6 +730,16 @@ static Optional<DirectoryName> extractDirectoryName(const String& absolutePathTo > > static Optional<DirectoryName> currentWorkingDirectory() > { >+ if (s_workingDirectory) { >+ const String& directoryString = s_workingDirectory.value(); >+ if (directoryString[directoryString.length() - 1] == pathSeparator()) >+ return extractDirectoryName(directoryString); >+ return extractDirectoryName(makeString(directoryString, pathSeparator())); >+ } >+ >+#if PLATFORM(PLAYSTATION) >+ return WTF::nullopt; >+#else > #if OS(WINDOWS) > // https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934.aspx > // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#maxpath >@@ -762,6 +775,7 @@ static Optional<DirectoryName> currentWorkingDirectory() > return extractDirectoryName(directoryString); > // Append the seperator to represents the file name. extractDirectoryName only accepts the absolute file name. > return extractDirectoryName(makeString(directoryString, pathSeparator())); >+#endif > } > > static String resolvePath(const DirectoryName& directoryName, const ModuleName& moduleName) >@@ -798,6 +812,13 @@ static String absolutePath(const String& fileName) > return resolvePath(directoryName.value(), ModuleName(fileName.impl())); > } > >+static String filePath(const String& fileName) >+{ >+ if (s_workingDirectory) >+ return absolutePath(fileName); >+ return fileName; >+} >+ > JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSString* moduleNameValue, JSValue parameters, const SourceOrigin& sourceOrigin) > { > VM& vm = globalObject->vm(); >@@ -903,7 +924,7 @@ static RefPtr<Uint8Array> fillBufferWithContentsOfFile(FILE* file) > > static RefPtr<Uint8Array> fillBufferWithContentsOfFile(const String& fileName) > { >- FILE* f = fopen(fileName.utf8().data(), "rb"); >+ FILE* f = fopen(filePath(fileName).utf8().data(), "rb"); > if (!f) { > fprintf(stderr, "Could not open file: %s\n", fileName.utf8().data()); > return nullptr; >@@ -934,7 +955,8 @@ static bool fillBufferWithContentsOfFile(FILE* file, Vector& buffer) > > static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer) > { >- FILE* f = fopen(fileName.utf8().data(), "rb"); >+ FILE* f = fopen(filePath(fileName).utf8().data(), "rb"); >+ > if (!f) { > fprintf(stderr, "Could not open file: %s\n", fileName.utf8().data()); > return false; >@@ -2762,6 +2784,14 @@ void CommandLine::parseArguments(int argc, char** argv) > continue; > } > >+ // This option is provided for systems (such as PlayStation) which >+ // do not have a concept of working directory at the shell level. >+ static const unsigned workingDirectoryStrLength = strlen("--working-directory="); >+ if (!strncmp(arg, "--working-directory=", workingDirectoryStrLength)) { >+ m_workingDirectory = String(arg + workingDirectoryStrLength); >+ continue; >+ } >+ > // See if the -- option is a JSC VM option. > if (strstr(arg, "--") == arg) { > if (!JSC::Options::setOption(&arg[2])) { >@@ -2903,6 +2933,9 @@ int jscmain(int argc, char** argv) > > processConfigFile(Options::configFile(), "jsc"); > >+ if (!options.m_workingDirectory.isEmpty()) >+ s_workingDirectory = options.m_workingDirectory; >+ > // Initialize JSC before getting VM. > WTF::initializeMainThread(); > JSC::initializeThreading();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194542
:
361799
|
361803
|
361815
|
361817