Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/installer/corehost/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ add_subdirectory(hostmisc)
add_subdirectory(hostcommon)
add_subdirectory(apphost)
add_subdirectory(dotnet)
add_subdirectory(fxr)
add_subdirectory(hostpolicy)
add_subdirectory(nethost)
add_subdirectory(test_fx_ver)
add_subdirectory(fxr)
add_subdirectory(hostpolicy)

add_subdirectory(test)

Expand Down
48 changes: 2 additions & 46 deletions src/installer/corehost/cli/apphost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,5 @@
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.

project(apphost)
set(DOTNET_PROJECT_NAME "apphost")

# Add RPATH to the apphost binary that allows using local copies of shared libraries
# dotnet core depends on for special scenarios when system wide installation of such
# dependencies is not possible for some reason.
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way,
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive.
if (NOT CLR_CMAKE_TARGET_OSX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps")
endif()

set(SKIP_VERSIONING 1)

set(SOURCES
./bundle_marker.cpp
)

set(HEADERS
./bundle_marker.h
)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
apphost.windows.cpp)

list(APPEND HEADERS
apphost.windows.h)
endif()

include(../exe.cmake)

add_definitions(-DFEATURE_APPHOST=1)

# Disable manifest generation into the file .exe on Windows
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY
LINK_FLAGS "/MANIFEST:NO"
)
endif()

# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
target_link_libraries(apphost Advapi32.lib shell32.lib)
endif()
add_subdirectory(static)
Comment thread
lpereira marked this conversation as resolved.
add_subdirectory(shared)
54 changes: 54 additions & 0 deletions src/installer/corehost/cli/apphost/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.

project(apphost)
set(DOTNET_PROJECT_NAME "apphost")

# Add RPATH to the apphost binary that allows using local copies of shared libraries
# dotnet core depends on for special scenarios when system wide installation of such
# dependencies is not possible for some reason.
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way,
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive.
if (NOT CLR_CMAKE_TARGET_OSX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps")
endif()

set(SKIP_VERSIONING 1)

include_directories(..)

set(SOURCES
../bundle_marker.cpp
./hostfxr_iface.cpp
)

set(HEADERS
../bundle_marker.h
../../../hostfxr_iface.h
)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
../apphost.windows.cpp)

list(APPEND HEADERS
../apphost.windows.h)
endif()

include(../../exe.cmake)

add_definitions(-DFEATURE_APPHOST=1)

# Disable manifest generation into the file .exe on Windows
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY
LINK_FLAGS "/MANIFEST:NO"
)
endif()

# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
target_link_libraries(apphost Advapi32.lib shell32.lib)
endif()
61 changes: 61 additions & 0 deletions src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#include <assert.h>

#include "pal.h"
#include "fxr_resolver.h"
#include "trace.h"
#include "hostfxr_iface.h"

hostfxr_main_bundle_startupinfo_fn hostfxr::resolve_main_bundle_startupinfo()
{
assert(m_hostfxr_dll != nullptr);
return reinterpret_cast<hostfxr_main_bundle_startupinfo_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_bundle_startupinfo"));
}

hostfxr_set_error_writer_fn hostfxr::resolve_set_error_writer()
{
assert(m_hostfxr_dll != nullptr);
return reinterpret_cast<hostfxr_set_error_writer_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_set_error_writer"));
}

hostfxr_main_startupinfo_fn hostfxr::resolve_main_startupinfo()
{
assert(m_hostfxr_dll != nullptr);
return reinterpret_cast<hostfxr_main_startupinfo_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_startupinfo"));
}

hostfxr_main_fn hostfxr::resolve_main_v1()
{
assert(m_hostfxr_dll != nullptr);
return reinterpret_cast<hostfxr_main_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main"));
}

hostfxr::hostfxr(const pal::string_t& app_root)
{
if (!fxr_resolver::try_get_path(app_root, &m_dotnet_root, &m_fxr_path))
{
m_status_code = StatusCode::CoreHostLibMissingFailure;
}
else if (pal::load_library(&m_fxr_path, &m_hostfxr_dll))
{
m_status_code = StatusCode::Success;
}
else
{
trace::error(_X("The library %s was found, but loading it from %s failed"), LIBFXR_NAME, m_fxr_path.c_str());
trace::error(_X(" - Installing .NET prerequisites might help resolve this problem."));
trace::error(_X(" %s"), DOTNET_CORE_INSTALL_PREREQUISITES_URL);
m_status_code = StatusCode::CoreHostLibLoadFailure;
}
}

hostfxr::~hostfxr()
{
if (m_hostfxr_dll != nullptr)
{
pal::unload_library(m_hostfxr_dll);
}
}
61 changes: 61 additions & 0 deletions src/installer/corehost/cli/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.

project(static_apphost)
set(DOTNET_PROJECT_NAME "static_apphost")

# Add RPATH to the apphost binary that allows using local copies of shared libraries
# dotnet core depends on for special scenarios when system wide installation of such
# dependencies is not possible for some reason.
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way,
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive.
if (NOT CLR_CMAKE_TARGET_OSX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps")
endif()

set(SKIP_VERSIONING 1)

include_directories(..)

set(SOURCES
../bundle_marker.cpp
./hostfxr_iface.cpp
)

set(HEADERS
../bundle_marker.h
../../../hostfxr_iface.h
)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
../apphost.windows.cpp)

list(APPEND HEADERS
../apphost.windows.h)
endif()

include(../../exe.cmake)

add_definitions(-DFEATURE_APPHOST=1)
add_definitions(-DFEATURE_STATIC_HOST=1)

# Disable manifest generation into the file .exe on Windows
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY
LINK_FLAGS "/MANIFEST:NO"
)
endif()

# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
target_link_libraries(static_apphost Advapi32.lib shell32.lib)
endif()

target_link_libraries(static_apphost
libhostfxr_static
libhostpolicy_static
libhostcommon
)
63 changes: 63 additions & 0 deletions src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#include <assert.h>
#include "trace.h"
#include "hostfxr.h"
#include "hostfxr_iface.h"

extern "C"
{
int HOSTFXR_CALLTYPE hostfxr_main_bundle_startupinfo(const int argc, const pal::char_t* argv[], const pal::char_t* host_path, const pal::char_t* dotnet_root, const pal::char_t* app_path, int64_t bundle_header_offset);
int HOSTFXR_CALLTYPE hostfxr_main_startupinfo(const int argc, const pal::char_t* argv[], const pal::char_t* host_path, const pal::char_t* dotnet_root, const pal::char_t* app_path);
int HOSTFXR_CALLTYPE hostfxr_main(const int argc, const pal::char_t* argv[]);
hostfxr_error_writer_fn HOSTFXR_CALLTYPE hostfxr_set_error_writer(hostfxr_error_writer_fn error_writer);
}

hostfxr_main_bundle_startupinfo_fn hostfxr::resolve_main_bundle_startupinfo()
{
assert(m_hostfxr_dll == nullptr);
return hostfxr_main_bundle_startupinfo;
}

hostfxr_set_error_writer_fn hostfxr::resolve_set_error_writer()
{
assert(m_hostfxr_dll == nullptr);
return hostfxr_set_error_writer;
}

hostfxr_main_startupinfo_fn hostfxr::resolve_main_startupinfo()
{
assert(m_hostfxr_dll == nullptr);
return hostfxr_main_startupinfo;
}

hostfxr_main_fn hostfxr::resolve_main_v1()
{
assert(m_hostfxr_dll == nullptr);
assert(!"This function should not be called in a static host");
return nullptr;
}

hostfxr::hostfxr(const pal::string_t& app_root)
{
if (app_root.length() == 0)
{
trace::info(_X("Application root path is empty. This shouldn't happen"));
m_status_code = StatusCode::CoreHostLibMissingFailure;
}
else
{
trace::info(_X("Using internal fxr"));

m_dotnet_root.assign(app_root);
m_fxr_path.assign(app_root);

m_status_code = StatusCode::Success;
}
}

hostfxr::~hostfxr()
{
}
1 change: 1 addition & 0 deletions src/installer/corehost/cli/comhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "comhost")

# Include directories
include_directories(../fxr)
include_directories(../fxr/static)
include_directories(../json)

# CMake does not recommend using globbing since it messes with the freshness checks
Expand Down
4 changes: 4 additions & 0 deletions src/installer/corehost/cli/dotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ if(CLR_CMAKE_TARGET_WIN32)
dotnet.manifest)
endif()

list(APPEND SOURCES
../apphost/shared/hostfxr_iface.cpp
)

include(../exe.cmake)
4 changes: 4 additions & 0 deletions src/installer/corehost/cli/exe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)

# Include directories
include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr)
include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr/static)

# CMake does not recommend using globbing since it messes with the freshness checks
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/fxr_resolver.cpp
${CMAKE_CURRENT_LIST_DIR}/../corehost.cpp
)
list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../hostfxr_iface.h
)

add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES})
target_link_libraries(${DOTNET_PROJECT_NAME} libhostmisc)
Expand Down
45 changes: 2 additions & 43 deletions src/installer/corehost/cli/fxr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,5 @@
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.

project(hostfxr)

set(DOTNET_PROJECT_NAME "hostfxr")

# Include directories
include_directories(../json)

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
./command_line.cpp
./corehost_init.cpp
./hostfxr.cpp
./fx_muxer.cpp
./fx_resolver.cpp
./fx_resolver.messages.cpp
./framework_info.cpp
./host_context.cpp
./hostpolicy_resolver.cpp
./sdk_info.cpp
./sdk_resolver.cpp
)

set(HEADERS
../corehost_context_contract.h
../hostpolicy.h
../fx_definition.h
../fx_reference.h
../roll_fwd_on_no_candidate_fx_option.h
./command_line.h
./corehost_init.h
./fx_muxer.h
./fx_resolver.h
./framework_info.h
./host_context.h
./hostpolicy_resolver.h
./sdk_info.h
./sdk_resolver.h
)

include(../lib.cmake)

install_with_stripped_symbols(hostfxr TARGETS corehost)
target_link_libraries(hostfxr libhostcommon)
add_subdirectory(static)
add_subdirectory(shared)
Loading