Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflows #54

Closed
wants to merge 9 commits into from
Closed
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "lzaoral"
vmihalko marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "RelWithDebInfo"
# --------------------------------------------------
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -pedantic -fno-rtti")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14 /W4 /GR-")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -pedantic -fno-rtti")
endif()

# --------------------------------------------------
# LLVM
Expand All @@ -46,15 +50,24 @@ include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})

option(LLVM_LINK_DYLIB "Link with LLVM dynamically" ON)
if(MSVC)
message(WARNING "It is not possible to link with LLVM dynamically on Windows")
set(LLVM_LINK_DYLIB OFF)
endif()

if(LLVM_LINK_DYLIB)
message(STATUS "LLVM linking: dynamic")
set(llvm_libs LLVM)
else()
message(STATUS "LLVM linking: static")
# Find the libraries that correspond to the LLVM components
# that we wish to use
llvm_map_components_to_libnames(llvm_libs bitwriter core irreader linker
support)
llvm_map_components_to_libnames(llvm_libs irreader)

if(MSVC)
add_compile_options($<$<CONFIG:Debug>:/MTd>
$<$<NOT:$<CONFIG:Debug>>:/MT>)
endif()
endif()

# --------------------------------------------------
Expand All @@ -64,25 +77,17 @@ set(llvm2c_sources
main.cpp

core/Block.cpp
core/Block.h
core/Func.cpp
core/Func.h
core/Program.cpp
core/Program.h

expr/BinaryExpr.cpp
expr/BinaryExpr.h
expr/Expr.cpp
expr/Expr.h
expr/UnaryExpr.cpp
expr/UnaryExpr.h

parser/ProgramParser.cpp
parser/ProgramParser.h
parser/SimplifyingExprVisitor.cpp
parser/addSignCasts.cpp
parser/arrowify.cpp
parser/cfunc.h
parser/computeGlobalVarsOrder.cpp
parser/constval.cpp
parser/createAllocas.cpp
Expand All @@ -108,16 +113,12 @@ set(llvm2c_sources
parser/parseMetadataTypes.cpp
parser/parseStructDeclarations.cpp
parser/parseStructItems.cpp
parser/passes.h
parser/prepareBitcastUnion.cpp
parser/refDeref.cpp
parser/toinst.cpp
parser/toinst.h

type/Type.cpp
type/Type.h
type/TypeHandler.cpp
type/TypeHandler.h

writer/CWriter.cpp
writer/ExprWriter.cpp
Expand Down
4 changes: 0 additions & 4 deletions parser/createExpressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ Expr* parseLLVMInstruction(const llvm::Instruction& ins, Program& program);
static void parseInlineASM(const llvm::Instruction& ins, Func* func, Block* block);

// FIXME: Remove this when LLVM 8 is the minimal version for LLVM2C!
static inline llvm::iterator_range<llvm::User::op_iterator> args_wrapper(llvm::CallInst *CI) {
return make_range(CI->arg_begin(), CI->arg_end());
}

static inline llvm::iterator_range<llvm::User::const_op_iterator> args_wrapper(const llvm::CallInst *CI) {
return make_range(CI->arg_begin(), CI->arg_end());
}
Expand Down
8 changes: 3 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(N EQUAL 0)
set(N 1)
endif()

set(CTEST_OPTS -j${N} --output-on-failure --progress ${CTEST_OPTS})
set(CTEST_OPTS -j${N} --output-on-failure --progress ${CTEST_OPTS} -C $<CONFIG>)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_OPTS}
USES_TERMINAL)
add_dependencies(check llvm2c)
Expand All @@ -34,10 +34,7 @@ endforeach()
# --------------------------------------------------
# Tests
# --------------------------------------------------
set(LLVM2C $<TARGET_FILE:llvm2c>)
configure_file(run.in run.imd @ONLY)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run
INPUT ${CMAKE_CURRENT_BINARY_DIR}/run.imd)
configure_file(run.in run @ONLY)

set(tests
asm
Expand All @@ -56,4 +53,5 @@ set(tests

foreach(test ${tests})
add_test(NAME ${test} COMMAND ./run ${test})
set_tests_properties(${test} PROPERTIES ENVIRONMENT LLVM2C=$<TARGET_FILE:llvm2c>)
endforeach()
4 changes: 2 additions & 2 deletions test/run.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
LABEL="$1"
FOLDER=$LABEL

if ! [[ -e @LLVM2C@ ]]; then
if ! [[ -e "$LLVM2C" ]]; then
echo "llvm2c not found!"
exit 1
fi
Expand Down Expand Up @@ -37,7 +37,7 @@ for f in @CMAKE_CURRENT_SOURCE_DIR@/inputs/$FOLDER/*.c; do
@OPT@ -mem2reg $TEMPDIR/temp.ll -o $TEMPDIR/temp.ll
fi

@LLVM2C@ $TEMPDIR/temp.ll --o $TEMPDIR/temp.c # >> /dev/null
"$LLVM2C" $TEMPDIR/temp.ll --o $TEMPDIR/temp.c # >> /dev/null

if [[ $? != 0 ]]; then
echo -e "\n\t[NOK] llvm2c failed to translate $f!"
Expand Down