Skip to content

Commit

Permalink
Merge branch 'addlibc++warning' into 'master'
Browse files Browse the repository at this point in the history
Do not process standard input with libc++

See merge request hepmc/HepMC3!372
  • Loading branch information
Andrii Verbytskyi committed Dec 27, 2024
2 parents bbe42cc + 9ca00e9 commit c5a7d29
Show file tree
Hide file tree
Showing 6 changed files with 611 additions and 22 deletions.
79 changes: 58 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,66 @@ jobs:
matrix:
python-version: ["3.9"]
config:
- {
name: "MacOSX-12",
os: macos-12,
cc: "clang",
cxx: "clang++"
}
- {
name: "MacOSX-11",
os: macos-11,
cc: "clang",
cxx: "clang++"
}
- {
name: "MacOSX-13",
os: macos-13,
cc: "clang",
cxx: "clang++"
}
- {
name: "MacOSX-14",
os: macos-14,
cc: "clang",
cxx: "clang++"
}

#- {
#name: "MacOSX-13",
#os: macos-13-xlarge,
#cxx: "clang++"
#}
#- {
#name: "MacOSX-14",
#os: macos-14,
#cxx: "clang++"
#}
#- {
#name: "MacOSX-14",
#os: macos-14-xlarge,
#cxx: "clang++"
#}
#- {
#name: "MacOSX-15",
#os: macos-15,
#cxx: "clang++"
#}
#- {
#name: "MacOSX-15",
#os: macos-15-xlarge,
#cxx: "clang++"
#}
#- {
#name: "MacOSX-13",
#os: macos-13,
#cxx: "g++-14"
#}
#- {
#name: "MacOSX-13",
#os: macos-13-xlarge,
#cxx: "g++-14"
#}
#- {
#name: "MacOSX-14",
#os: macos-14,
#cxx: "g++-14"
#}
#- {
#name: "MacOSX-14",
#os: macos-14-xlarge,
#cxx: "g++-14"
#}
#- {
#name: "MacOSX-15",
#os: macos-15,
#cxx: "g++-14"
#}
#- {
#name: "MacOSX-15",
#os: macos-15-xlarge,
#cxx: "g++-14"
#}
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -47,7 +82,9 @@ jobs:
run: |
brew install protobuf
brew install doxygen
cmake -S. -B BUILD -DCMAKE_INSTALL_PREFIX=./INSTALL -DHEPMC3_BUILD_DOCS:BOOL=OFF -DHEPMC3_BUILD_EXAMPLES:BOOL=ON -DHEPMC3_ENABLE_ROOTIO:BOOL=OFF -DHEPMC3_ENABLE_PROTOBUFIO:BOOL=ON -DHEPMC3_ENABLE_TEST:BOOL=ON -DHEPMC3_PYTHON_VERSIONS=3
set -x
uname -m
cmake -S. -B BUILD -DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} -DCMAKE_C_COMPILER=${{matrix.config.cc}} -DCMAKE_INSTALL_PREFIX=./INSTALL -DHEPMC3_ENABLE_PYTHON=OFF -DHEPMC3_BUILD_DOCS:BOOL=OFF -DHEPMC3_BUILD_EXAMPLES:BOOL=ON -DHEPMC3_ENABLE_ROOTIO:BOOL=OFF -DHEPMC3_ENABLE_PROTOBUFIO:BOOL=OFF -DHEPMC3_ENABLE_TEST:BOOL=ON -DHEPMC3_PYTHON_VERSIONS=3
cmake --build BUILD
cmake --install BUILD
cd BUILD
Expand Down
7 changes: 7 additions & 0 deletions examples/ConvertExample/convert_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ int main(int argc, char** argv)
std::shared_ptr<Reader> input_file;
bool input_is_stdin = (std::string(ai.inputs[0]) == std::string("-"));
if (input_is_stdin) std::ios_base::sync_with_stdio(false);
#ifdef _LIBCPP_VERSION
if (input_is_stdin) {
printf("The program cannot process inputs from standard input as std::ios_base::sync_with_stdio(bool) is not implemented in libc++, please use another C++ standard library.\n");
exit(4);
}
#endif

bool ignore_writer = false;
switch (format_map.at(std::string(ai.input_format_arg)))
{
Expand Down
40 changes: 39 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,43 @@ macro( hepmc_test testname )
set(srcdir ${CMAKE_CURRENT_SOURCE_DIR} )
set(builddir ${CMAKE_CURRENT_BINARY_DIR} )
add_test( ${testname} ${CMAKE_CURRENT_BINARY_DIR}/${testname} )
SET_TESTS_PROPERTIES( ${testname} PROPERTIES ENVIRONMENT "PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{PATH}")
SET_TESTS_PROPERTIES( ${testname} PROPERTIES ENVIRONMENT "PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{PATH}"
ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{LD_LIBRARY_PATH}"
ENVIRONMENT "DYLD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{DYLD_LIBRARY_PATH}"
)
file(GLOB INPUT${testname} "${CMAKE_CURRENT_SOURCE_DIR}/input${testname}*" )
file(COPY ${INPUT${testname}} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
string(REPLACE "test" "" ${testname} name)
file(GLOB INPUT${name} "${CMAKE_CURRENT_SOURCE_DIR}/input${name}*" )
file(COPY ${INPUT${name}} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endmacro( hepmc_test )

macro( hepmc_unix_test testname )
message( STATUS "HepMC3 test: building UNIX test ${testname} " )
find_file( ${testname}_source ${testname}.cc ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
ADD_EXECUTABLE(${testname} ${${testname}_source} ${ARGN} )
target_include_directories(${testname} BEFORE
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src )
target_link_libraries(${testname} PRIVATE HepMC3::HepMC3 )
set(srcdir ${CMAKE_CURRENT_SOURCE_DIR} )
set(builddir ${CMAKE_CURRENT_BINARY_DIR} )

string(REPLACE "test" "" ${testname} name)
file(GLOB INPUT${testname} "${CMAKE_CURRENT_SOURCE_DIR}/input${testname}*" )
file(COPY ${INPUT${testname}} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB INPUT${name} "${CMAKE_CURRENT_SOURCE_DIR}/input${name}*" )
file(COPY ${INPUT${name}} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB RUN${testname} "${CMAKE_CURRENT_SOURCE_DIR}/run${testname}*" )
file(COPY ${RUN${testname}} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_test( NAME ${testname} COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/run${testname}.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
SET_TESTS_PROPERTIES( ${testname} PROPERTIES ENVIRONMENT "PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/;$ENV{PATH}"
ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{LD_LIBRARY_PATH}"
ENVIRONMENT "DYLD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_LIBDIR}/;$ENV{DYLD_LIBRARY_PATH}"
)
endmacro( hepmc_unix_test )


macro( hepmc_root_test testname )
message( STATUS "HepMC3 test: building ROOT test ${testname} " )
find_file( ${testname}_source ${testname}.cc ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
Expand Down Expand Up @@ -137,6 +166,10 @@ set( HepMC_tests
testOrder
testVertexAttributes
)

set( HepMC_unix_tests
testReaderFactory5
)
set( HepMC_root_tests
testIO2
testIO4
Expand Down Expand Up @@ -313,6 +346,11 @@ if(HEPMC3_ENABLE_ROOTIO AND (NOT WIN32) )
target_link_libraries(testIO4 PRIVATE ROOT::Hist)
endif()

if(NOT WIN32)
foreach ( test ${HepMC_unix_tests} )
hepmc_unix_test( ${test} )
endforeach ( test ${HepMC_unix_tests} )
endif()

set( convert_tests )

Expand Down
Loading

0 comments on commit c5a7d29

Please sign in to comment.