Skip to content

RDKEMW-3106 : Ensure modules path works in all environments #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

Sid2001-maker
Copy link
Contributor

Fetches modules directory path in generic way

Reason for change: Cleaned up the code
Test Procedure: build should be successful.
Risks: low
Priority: P2
@Sid2001-maker Sid2001-maker requested a review from a team as a code owner April 8, 2025 08:44
@Sid2001-maker Sid2001-maker requested review from madanagopalt and removed request for a team April 8, 2025 08:44
@CLAassistant
Copy link

CLAassistant commented Apr 8, 2025

CLA assistant check
All committers have signed the CLA.

Reason for change: Cleaned up the code
Test Procedure: build should be successful.
Risks: low
Priority: P2
@vjain008
Copy link
Contributor

Changes are good and validated with custom build.

@@ -55,6 +55,10 @@ class JavaScriptContextBase:public IJavaScriptContext, public JavaScriptKeyListe
std::string getUrl();
virtual void onKeyPress(struct JavaScriptKeyDetails& details);
virtual void onKeyRelease(struct JavaScriptKeyDetails& details);

//newly added
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the "newly added" comments - here and in the other places.

@@ -55,6 +55,10 @@ class JavaScriptContextBase:public IJavaScriptContext, public JavaScriptKeyListe
std::string getUrl();
virtual void onKeyPress(struct JavaScriptKeyDetails& details);
virtual void onKeyRelease(struct JavaScriptKeyDetails& details);

//newly added
static void setEnvVariable(const char* name, const char* value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want this method.


//newly added
static std::string sModulesPath;
std::string getModulesPath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be static method?

JavaScriptContextFeatures::JavaScriptContextFeatures(bool embedThunderJS, bool embedWebBridge, bool enableWebSockerServer, ModuleSettings& moduleSettings):mEmbedThunderJS(embedThunderJS), mEmbedWebBridge(embedWebBridge), mEnableWebSockerServer(enableWebSockerServer), mModuleSettings(moduleSettings)
{
}

JavaScriptContextBase::JavaScriptContextBase(JavaScriptContextFeatures& features, std::string url, IJavaScriptEngine* jsEngine): mApplicationUrl(url), mEngine(jsEngine), mEmbedThunderJS(features.mEmbedThunderJS), mEmbedWebBridge(features.mEmbedWebBridge), mEnableWebSockerServer(features.mEnableWebSockerServer), mModuleSettings(features.mModuleSettings)
{
//newly added
JavaScriptContextBase::setEnvVariable("JSRUNTIME_MODULES_PATH", "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don;t want this method. Only we need to read this env variable JSRUNTIME_MODULES_PATH and should take priority than other modules path

if (mEmbedThunderJS)
{
if (sThunderJSCode.empty())
{
sThunderJSCode = readFile("modules/thunderJS.js");
std::string ThunderJS= sModulesPath + "thunderJS.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep all append inside readFile method?

Copy link
Contributor

@madanagopalt madanagopalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kindly address comments. Also, keep PR heading with ticketnumber:<title>

@Sid2001-maker Sid2001-maker changed the title Topic/rdkemw 3106 RDKEMW-3106 : Ensure modules path works in all environments Apr 15, 2025
Reason for change: Removed unwanted comments newly added
Test Procedure: build should be successful.
Risks: low
Priority: P2
Copy link
Contributor

@madanagopalt madanagopalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some changes to address. I will explain in meeting

home = PWD;
}
sModulesPath = home;
if(setenv("JSRUNTIME_MODULES_PATH",home.c_str(),1)==0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1, Perfrom getenv and use it as sModulesPath if environment is set
2,Else, set module path to pwd+/modules as written
3, Don;t want multiple if else


JavaScriptContextFeatures::JavaScriptContextFeatures(bool embedThunderJS, bool embedWebBridge, bool enableWebSockerServer, ModuleSettings& moduleSettings):mEmbedThunderJS(embedThunderJS), mEmbedWebBridge(embedWebBridge), mEnableWebSockerServer(enableWebSockerServer), mModuleSettings(moduleSettings)
{
}

JavaScriptContextBase::JavaScriptContextBase(JavaScriptContextFeatures& features, std::string url, IJavaScriptEngine* jsEngine): mApplicationUrl(url), mEngine(jsEngine), mEmbedThunderJS(features.mEmbedThunderJS), mEmbedWebBridge(features.mEmbedWebBridge), mEnableWebSockerServer(features.mEnableWebSockerServer), mModuleSettings(features.mModuleSettings)
{
getModulesPath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename as populateModulesPath

@@ -77,6 +82,22 @@ std::string JavaScriptContextBase::readFile(const char *file)
std::ifstream src_file(file);
std::stringstream src_script;
src_script << src_file.rdbuf();
if(src_script.str().empty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1, Get one argument to readFile isModule (by default true). Pass it false, when we are calling this api for running local file/application
2, This will avoid read to fail everytime for all modules fist time.
3, Also, if isModule is set, read the file after appending modulespath, else ready directly

Copy link
Contributor

@madanagopalt madanagopalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kindly look at comments

Sid2001-maker and others added 4 commits June 16, 2025 16:18
Reason for change: Cleaned up the code
Test Procedure: build should be successful.
Risks: low
Priority: P2
Reason for change: Cleaned up the code
Test Procedure: build should be successful.
Risks: low
Priority: P2
Reason for change: Removed unwanted comments newly added
Test Procedure: build should be successful.
Risks: low
Priority: P2
Reason for change: Cleaned up the code
Test Procedure: build should be successful.
Risks: low
Priority: P2
@Sid2001-maker Sid2001-maker deleted the topic/RDKEMW-3106 branch June 16, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants