Skip to content

Commit

Permalink
merging changes from edge-js
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Oct 25, 2024
1 parent 0b6c3aa commit 8d46b4d
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 43 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ jobs:
needs: build
strategy:
matrix:
# electron: [29.4.6, 30.5.1, 31.6.0]
# electron: [29.4.6]
os: [windows-2022]
# fail-fast: false

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ on:
- '.circleci'
- '.circleci/*'
- 'README.md'
- '*.sln'
- '*.vcxproj'
push:
branches-ignore:
- 'circleci'
Expand Down Expand Up @@ -57,6 +59,8 @@ on:
- '.circleci'
- '.circleci/*'
- 'README.md'
- '*.sln'
- '*.vcxproj'

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true # required to setup CSC
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ test/mochawesome-report
mochawesome-report
mochawesome.json

release
*.zip

5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ test/mochawesome-report
mochawesome-report
mochawesome.json
*.zip
*.sln
*.sln
xunit*.*
getVersion*.js
*.vcxproj
Binary file modified lib/native/win32/ia32/29.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/ia32/29.0.0/edge_nativeclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/29.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/29.0.0/edge_nativeclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/30.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/30.0.0/edge_nativeclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/31.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/31.0.0/edge_nativeclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/32.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/32.0.0/edge_nativeclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/33.0.0/edge_coreclr.node
Binary file not shown.
Binary file modified lib/native/win32/x64/33.0.0/edge_nativeclr.node
Binary file not shown.
24 changes: 13 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "http://tomasz.janczuk.org",
"twitter": "tjanczuk"
},
"version": "33.0.0",
"version": "33.0.1",
"description": "Edge.js: run .NET and Node.js in-process on Electron",
"tags": [
"owin",
Expand Down Expand Up @@ -42,11 +42,11 @@
"license": "MIT",
"dependencies": {
"edge-cs": "npm:@agracio/edge-cs@^1.3.7",
"follow-redirects": "^1.15.9",
"nan": "^2.22.0"
},
"devDependencies": {
"electron": "^32.0.0",
"electron": "^33.0.0",
"follow-redirects": "^1.15.9",
"mocha": "10.7.3",
"mochawesome": "^7.1.3",
"mochawesome-merge": "^4.3.0",
Expand Down
65 changes: 46 additions & 19 deletions src/CoreCLREmbedding/coreclrembedding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ InitializeFunction initialize;
"EdgeJs",\
"CoreCLREmbedding",\
functionName,\
(void**) functionPointer);\
(void**) (functionPointer));\
pal::clr_palstring(functionName, &functionNameString);\
\
if (FAILED(result))\
Expand Down Expand Up @@ -209,7 +209,7 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
pal::string_t edgeDebug;
pal::getenv(_X("EDGE_DEBUG"), &edgeDebug);

if (edgeDebug.length() > 0)
if (!edgeDebug.empty())
{
trace::enable();
}
Expand Down Expand Up @@ -265,9 +265,9 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
pal::string_t edgeBootstrapDir;
pal::getenv(_X("EDGE_BOOTSTRAP_DIR"), &edgeBootstrapDir);

if (edgeAppDir.length() == 0)
if (edgeAppDir.empty())
{
if (edgeBootstrapDir.length() != 0)
if (!edgeBootstrapDir.empty())
{
trace::info(_X("CoreClrEmbedding::Initialize - No EDGE_APP_ROOT environment variable present, using the Edge bootstrapper directory at %s"), edgeBootstrapDir.c_str());
edgeAppDir = edgeBootstrapDir;
Expand Down Expand Up @@ -321,7 +321,7 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
size_t previousIndex = 0;
size_t currentIndex = pathEnvironmentVariable.find(PATH_SEPARATOR);

while (dotnetExecutablePath.length() == 0 && previousIndex != std::string::npos)
while (dotnetExecutablePath.empty() && previousIndex != std::string::npos)
{
if (currentIndex != std::string::npos)
{
Expand Down Expand Up @@ -371,16 +371,43 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
if (mode != host_mode_t::standalone)
{
trace::verbose(_X("CoreClrEmbedding::Initialize - host mode: muxer"));

std::vector<pal::string_t> appConfigFiles;
pal::readdir(edgeAppDir, _X("*.runtimeconfig.json"), &appConfigFiles);
pal::string_t runtimeconfigfile;

pal::string_t sdkDirectory;

fx_muxer_t::resolve_sdk_dotnet_path(dotnetDirectory, &sdkDirectory);

pal::string_t dotnetAssemblyPath(sdkDirectory);
append_path(&dotnetAssemblyPath, _X("dotnet.dll"));
if (!sdkDirectory.empty()) // Default case: SDK is installed and found - using dotnet.runtimeconfig.json from SDK folder
{
runtimeconfigfile = pal::string_t(sdkDirectory);
append_path(&runtimeconfigfile, _X("dotnet.dll"));
get_runtime_config_paths_from_app(runtimeconfigfile, &configFile, &devConfigFile);
}
else if (appConfigFiles.size() == 1) // Fallback: No SDK directory found (probably only .NET runtime installed), trying to use [appname].runtimeconfig.json instead
{
runtimeconfigfile = pal::string_t(edgeAppDir);
append_path(&runtimeconfigfile, appConfigFiles[0].c_str());

get_runtime_config_paths_from_app(dotnetAssemblyPath, &configFile, &devConfigFile);
}
trace::info(_X("CoreClrEmbedding::Initialize - No SDK directory found - Exactly one (%s) app runtimeconfig file found in the Edge app directory, using that"), runtimeconfigfile.c_str());
configFile = pal::string_t(runtimeconfigfile);
}
else if (appConfigFiles.size() > 1) // Throw error: No SDK found but more than one runtimeconfig.json found in app folder - Which one is correct?
{
std::vector<char> edgeAppDirCstr;
pal::pal_clrstring(edgeAppDir, &edgeAppDirCstr);

throwV8Exception("CoreClrEmbedding::Initialize - Multiple app runtimeconfig files (*.runtimeconfig.json) files exist in the Edge.js application directory (%s).", edgeAppDirCstr.data());
return E_FAIL;
}
else // No app runtimeconfigfile found and also no SDK found
{
throwV8Exception("CoreClrEmbedding::Initialize - Could not find any runtimeconfig file ([appname].runtimeconfig.json in app folder nor dotnet.runtimeconfig.json in sdk folder)");
return E_FAIL;
}
}
else
{
trace::verbose(_X("CoreClrEmbedding::Initialize - host mode: standalone"));
Expand All @@ -392,12 +419,12 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
pal::string_t packagesEnvironmentVariable;
pal::getenv(_X("NUGET_PACKAGES"), &packagesEnvironmentVariable);

if (packagesEnvironmentVariable.length() == 0)
if (packagesEnvironmentVariable.empty())
{
pal::string_t profileDirectory;
pal::getenv(_X("USERPROFILE"), &profileDirectory);

if (profileDirectory.length() == 0)
if (profileDirectory.empty())
{
pal::getenv(_X("HOME"), &profileDirectory);
}
Expand Down Expand Up @@ -638,14 +665,14 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)

SetCallV8FunctionDelegateFunction setCallV8Function;

CREATE_DELEGATE("GetFunc", &getFunc);
CREATE_DELEGATE("CallFunc", &callFunc);
CREATE_DELEGATE("ContinueTask", &continueTask);
CREATE_DELEGATE("FreeHandle", &freeHandle);
CREATE_DELEGATE("FreeMarshalData", &freeMarshalData);
CREATE_DELEGATE("SetCallV8FunctionDelegate", &setCallV8Function);
CREATE_DELEGATE("CompileFunc", &compileFunc);
CREATE_DELEGATE("Initialize", &initialize);
CREATE_DELEGATE("GetFunc", &getFunc)
CREATE_DELEGATE("CallFunc", &callFunc)
CREATE_DELEGATE("ContinueTask", &continueTask)
CREATE_DELEGATE("FreeHandle", &freeHandle)
CREATE_DELEGATE("FreeMarshalData", &freeMarshalData)
CREATE_DELEGATE("SetCallV8FunctionDelegate", &setCallV8Function)
CREATE_DELEGATE("CompileFunc", &compileFunc)
CREATE_DELEGATE("Initialize", &initialize)

trace::info(_X("CoreClrEmbedding::Initialize - Getting runtime info"));

Expand Down
41 changes: 34 additions & 7 deletions src/CoreCLREmbedding/host/runtime_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ runtime_config_t::runtime_config_t(const pal::string_t& path, const pal::string_
trace::verbose(_X("Runtime config [%s] is valid=[%d]"), path.c_str(), m_valid);
}

// Parse runtimeconfig, see documentation here https://github.com/dotnet/sdk/blob/main/documentation/specs/runtime-configuration-file.md
bool runtime_config_t::parse_opts(const json_value& opts)
{
// Note: both runtime_config and dev_runtime_config call into the function.
Expand All @@ -38,7 +39,7 @@ bool runtime_config_t::parse_opts(const json_value& opts)
{
m_properties[property.first] = property.second.is_string()
? property.second.as_string()
: property.second.to_string();
: property.second.serialize();
}
}

Expand Down Expand Up @@ -71,17 +72,43 @@ bool runtime_config_t::parse_opts(const json_value& opts)
m_prerelease_roll_fwd = prerelease_roll_fwd->second.as_bool();
}

auto framework = opts_obj.find(_X("framework"));
if (framework == opts_obj.end())
auto framework = opts_obj.find(_X("framework"));
const web::json::object* fx_obj = nullptr;

if (framework == opts_obj.end()) // Found no "framework" section in file, trying "frameworks" or "includedFrameworks"
{
return true;
auto frameworks = opts_obj.find(_X("frameworks"));
if (frameworks == opts_obj.end())
{
frameworks = opts_obj.find(_X("includedFrameworks"));

if (frameworks == opts_obj.end())
{
trace::verbose(_X("Found neither 'framework' nor 'frameworks' nor 'includedFrameworks' section in runtimeconfig.json file"));
return true;
}
}

const auto& frameworks_array = frameworks->second.as_array();
if (frameworks_array.size() == 0)
{
trace::verbose(_X("'Frameworks' in runtimeconfig.json file section found but is empty"));
return true;
}

fx_obj = &frameworks_array.at(0).as_object(); // Using first element of frameworks array
}
else
{
fx_obj = &framework->second.as_object();
}

m_portable = true;
m_fx_name = fx_obj->at(_X("name")).as_string();
m_fx_ver = fx_obj->at(_X("version")).as_string();

trace::verbose(_X("Found framework [%s] with version [%s] in runtimeconfig.json file"), m_fx_name.c_str(), m_fx_ver.c_str());

const auto& fx_obj = framework->second.as_object();
m_fx_name = fx_obj.at(_X("name")).as_string();
m_fx_ver = fx_obj.at(_X("version")).as_string();
return true;
}

Expand Down
1 change: 1 addition & 0 deletions tools/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if "%1" equ "" (
echo e.g. build.bat release "30.0.0"
exit /b -1
)
rmdir /S /Q ..\build\
FOR /F "tokens=* USEBACKQ" %%F IN (`node -p process.arch`) DO (SET ARCH=%%F)

SET FLAVOR=%1
Expand Down

0 comments on commit 8d46b4d

Please sign in to comment.