Skip to content

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

Closed
Sid2001-maker wants to merge 7 commits into
developfrom
topic/RDKEMW-3106
Closed

RDKEMW-3106 : Ensure modules path works in all environments#17
Sid2001-maker wants to merge 7 commits into
developfrom
topic/RDKEMW-3106

Conversation

@Sid2001-maker

Copy link
Copy Markdown
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 review from a team and madanagopalt and removed request for a team April 8, 2025 08:44
@CLAassistant

CLAassistant commented Apr 8, 2025

Copy link
Copy Markdown

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
Copy Markdown
Contributor

Changes are good and validated with custom build.

Comment thread include/JavaScriptContextBase.h Outdated
virtual void onKeyPress(struct JavaScriptKeyDetails& details);
virtual void onKeyRelease(struct JavaScriptKeyDetails& details);

//newly added

Copy link
Copy Markdown
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.

Comment thread include/JavaScriptContextBase.h Outdated
virtual void onKeyRelease(struct JavaScriptKeyDetails& details);

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

Copy link
Copy Markdown
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.

Comment thread include/JavaScriptContextBase.h Outdated

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

Copy link
Copy Markdown
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?

Comment thread src/JavaScriptContextBase.cpp Outdated
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
Copy Markdown
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

Comment thread src/JavaScriptContextBase.cpp Outdated
if (sThunderJSCode.empty())
{
sThunderJSCode = readFile("modules/thunderJS.js");
std::string ThunderJS= sModulesPath + "thunderJS.js"

Copy link
Copy Markdown
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?

@madanagopalt madanagopalt left a comment

Copy link
Copy Markdown
Contributor

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

@madanagopalt madanagopalt left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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


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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename as populateModulesPath

std::ifstream src_file(file);
std::stringstream src_script;
src_script << src_file.rdbuf();
if(src_script.str().empty())

Copy link
Copy Markdown
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

@madanagopalt madanagopalt left a comment

Copy link
Copy Markdown
Contributor

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