Skip to content

Commit 8b248a3

Browse files
committed
Add non wasm build of xeus-cpp to ci
1 parent 5194327 commit 8b248a3

File tree

8 files changed

+514
-25
lines changed

8 files changed

+514
-25
lines changed

.github/workflows/ci.yml

+432-9
Large diffs are not rendered by default.

CMakeLists.txt

+9-4
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,15 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
303303
endif ()
304304

305305
# Fixes "C++ exception handler used, but unwind semantics are not enabled" warning Windows
306-
if (WIN32)
306+
if (MSVC)
307307
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
308308
endif ()
309309

310+
# Attempt to fix emulated tls missing symbols
311+
if (WIN32)
312+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -femulated-tls")
313+
endif ()
314+
310315
if (APPLE)
311316
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
312317
endif ()
@@ -393,7 +398,7 @@ else()
393398
option(CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." ON)
394399
endif()
395400

396-
if(MSVC)
401+
if(WIN32)
397402

398403
set(MSVC_EXPORTLIST
399404
??_7type_info@@6B@
@@ -421,8 +426,8 @@ if(MSVC)
421426
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z
422427
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z
423428
?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z
424-
)
425-
429+
)
430+
426431
if(MSVC_VERSION LESS 1914)
427432
set(MSVC_EXPORTLIST ${MSVC_EXPORTLIST} ??3@YAXPAX0@Z ??_V@YAXPAX0@Z)
428433
endif()

cmake/CppInterOp/CppInterOpConfig.cmake.in

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ get_filename_component(CPPINTEROP_INSTALL_PREFIX "${CPPINTEROP_INSTALL_PREFIX}"
99
# Determine CMAKE_SHARED_LIBRARY_SUFFIX based on operating system
1010
include(CMakeSystemSpecificInformation)
1111

12-
if(MSVC)
13-
set(shared_lib_dir bin)
14-
else()
15-
set(shared_lib_dir lib)
16-
endif()
12+
set(shared_lib_dir lib)
1713

1814
### build/install workaround
1915
if (@BUILD_SHARED_LIBS@)
@@ -56,7 +52,7 @@ set_target_properties(clangCppInterOp PROPERTIES
5652
INTERFACE_INCLUDE_DIRECTORIES ${_include}
5753
IMPORTED_LOCATION ${_lib}
5854
)
59-
if (MSVC)
55+
if (WIN32)
6056
if (IS_DIRECTORY "${CPPINTEROP_INSTALL_PREFIX}/include")
6157
set(_static_lib "${CPPINTEROP_INSTALL_PREFIX}/lib/${_lib_prefix}clangCppInterOp.lib")
6258
else()
@@ -66,7 +62,7 @@ if (MSVC)
6662
set_target_properties(clangCppInterOp PROPERTIES
6763
IMPORTED_IMPLIB ${_static_lib}
6864
)
69-
endif(MSVC)
65+
endif(WIN32)
7066

7167
unset(_lib_prefix)
7268
unset(_lib_suffix)

cmake/modules/GoogleTest.cmake

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(_gtest_byproduct_binary_dir
2-
${CMAKE_BINARY_DIR}/downloads/googletest-prefix/src/googletest-build)
2+
${CMAKE_CURRENT_BINARY_DIR}/googletest-prefix/src/googletest-stamp)
3+
34
set(_gtest_byproducts
45
${_gtest_byproduct_binary_dir}/lib/libgtest.a
56
${_gtest_byproduct_binary_dir}/lib/libgtest_main.a
@@ -20,6 +21,10 @@ elseif(APPLE)
2021
endif()
2122

2223
include(ExternalProject)
24+
IF(WIN32)
25+
string(REPLACE "-Wsuggest-override" "" CMAKE_CXX_FLAGS_GTEST ${CMAKE_CXX_FLAGS})
26+
set(CMAKE_CXX_FLAGS_GTEST "${CMAKE_CXX_FLAGS_GTEST} -Wno-language-extension-token")
27+
endif()
2328
ExternalProject_Add(
2429
googletest
2530
GIT_REPOSITORY https://github.com/google/googletest.git
@@ -36,7 +41,7 @@ ExternalProject_Add(
3641
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
3742
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
3843
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
39-
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
44+
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS_GTEST}
4045
-DCMAKE_AR=${CMAKE_AR}
4146
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
4247
${EXTRA_GTEST_OPTS}

environment-dev.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: xeus-cpp
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
# Build dependencies
6+
- make
7+
- cmake
8+
# Host dependencies
9+
- xeus>=5.0.0
10+
- xeus-zmq>=3.0,<4.0
11+
- nlohmann_json=3.11.3
12+
- pugixml
13+
- cpp-argparse <3.1
14+
- zlib
15+
# Test dependencies
16+
- pytest
17+
- jupyter_kernel_test>=0.5,<0.6
18+
- papermill
19+
- nbformat
20+
- nbval
21+
- pytest-rerunfailures
22+
- doctest

lib/Interpreter/CppInterOp.cpp

+28-2
Original file line numberDiff line numberDiff line change
@@ -3206,22 +3206,41 @@ namespace Cpp {
32063206
int m_DupFD = -1;
32073207

32083208
public:
3209+
#if defined(_WIN32)
32093210
StreamCaptureInfo(int FD) : m_TempFile(tmpfile(), std::fclose), m_FD(FD) {
32103211
if (!m_TempFile) {
32113212
perror("StreamCaptureInfo: Unable to create temp file");
32123213
return;
32133214
}
32143215

3215-
m_DupFD = dup(FD);
3216+
m_DupFD = _dup(FD);
32163217

32173218
// Flush now or can drop the buffer when dup2 is called with Fd later.
32183219
// This seems only neccessary when piping stdout or stderr, but do it
32193220
// for ttys to avoid over complicated code for minimal benefit.
32203221
::fflush(FD == STDOUT_FILENO ? stdout : stderr);
3222+
if (_dup2(_fileno(m_TempFile.get()), FD) < 0)
3223+
perror("StreamCaptureInfo:");
3224+
}
3225+
#else
3226+
StreamCaptureInfo(int FD) : m_TempFile(tmpfile(), std::fclose), m_FD(FD) {
3227+
3228+
if (!m_TempFile) {
3229+
perror("StreamCaptureInfo: Unable to create temp file");
3230+
return;
3231+
}
3232+
3233+
m_DupFD = dup(FD);
32213234

3235+
// Flush now or can drop the buffer when dup2 is called with Fd later.
3236+
// This seems only neccessary when piping stdout or stderr, but do it
3237+
// for ttys to avoid over complicated code for minimal benefit.
3238+
::fflush(FD == STDOUT_FILENO ? stdout : stderr);
32223239
if (dup2(fileno(m_TempFile.get()), FD) < 0)
32233240
perror("StreamCaptureInfo:");
32243241
}
3242+
#endif
3243+
32253244
StreamCaptureInfo(const StreamCaptureInfo&) = delete;
32263245
StreamCaptureInfo& operator=(const StreamCaptureInfo&) = delete;
32273246
StreamCaptureInfo(StreamCaptureInfo&&) = delete;
@@ -3235,8 +3254,11 @@ namespace Cpp {
32353254
assert(m_DupFD != -1 && "Multiple calls to GetCapturedString");
32363255

32373256
fflush(nullptr);
3238-
3257+
#if defined(_WIN32)
3258+
if (_dup2(m_DupFD, m_FD) < 0)
3259+
#else
32393260
if (dup2(m_DupFD, m_FD) < 0)
3261+
#endif
32403262
perror("StreamCaptureInfo:");
32413263
// Go to the end of the file.
32423264
if (fseek(m_TempFile.get(), 0L, SEEK_END) != 0)
@@ -3263,7 +3285,11 @@ namespace Cpp {
32633285
content[newLen++] = '\0'; // Just to be safe.
32643286

32653287
std::string result = content.get();
3288+
#if defined(_WIN32)
3289+
_close(m_DupFD);
3290+
#else
32663291
close(m_DupFD);
3292+
#endif
32673293
m_DupFD = -1;
32683294
return result;
32693295
}

lib/Interpreter/DynamicLibraryManager.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ namespace Cpp {
5252
// Behaviour is to not add paths that don't exist...In an interpreted env
5353
// does this make sense? Path could pop into existance at any time.
5454
for (const char* Var : kSysLibraryEnv) {
55+
#if defined(_WIN32)
56+
char* Env = nullptr;
57+
size_t sz = 0;
58+
if (_dupenv_s(&Env, &sz, Var)) {
59+
#else
5560
if (const char* Env = ::getenv(Var)) {
61+
#endif
5662
SmallVector<StringRef, 10> CurPaths;
5763
SplitPaths(Env, CurPaths, utils::kPruneNonExistant, Cpp::utils::platform::kEnvDelim);
5864
for (const auto& Path : CurPaths)

lib/Interpreter/Paths.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ bool ExpandEnvVars(std::string& Str, bool Path) {
168168

169169
std::string EnvVar = Str.substr(DPos + 1, Length -1); //"HOME"
170170
std::string FullPath;
171-
if (const char* Tok = ::getenv(EnvVar.c_str()))
171+
#if defined(_WIN32)
172+
char* Tok = nullptr;
173+
size_t sz = 0;
174+
if (_dupenv_s(&Tok, &sz, EnvVar.c_str()))
175+
#else
176+
if (const char* Tok = getenv(EnvVar.c_str()))
177+
#endif
172178
FullPath = Tok;
173179

174180
Str.replace(DPos, Length, FullPath);

0 commit comments

Comments
 (0)