forked from trailofbits/cb-multios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17,697 changed files
with
1,533,700 additions
and
894,909 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,88 @@ | ||
project (cb_porting) | ||
include_directories ("include") #nessecary libraries shared by all challenge binaries | ||
# Using this min version for now | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
project(cb_porting) | ||
include_directories(include) # necessary libraries shared by all challenge binaries | ||
|
||
if(UNIX AND NOT APPLE) | ||
set(LINUX TRUE) | ||
set(CMAKE_C_COMPILER clang-3.6) | ||
set(LINUX TRUE) | ||
set(CMAKE_C_COMPILER clang) | ||
endif() | ||
if(APPLE) | ||
set(APPLE TRUE) ##accurate on my mac | ||
set(APPLE TRUE) # accurate on my mac | ||
endif() | ||
if(WIN32) | ||
set(WIN TRUE) | ||
set(WIN TRUE) | ||
endif() | ||
|
||
set( main_dir cqe-challenges ) #directory which contains all cb subdirs | ||
set(main_dir cqe-challenges) # directory which contains all cb subdirs | ||
|
||
file(GLOB challenge_binaries ${main_dir}/*) #list of all files(+paths) in maindir - all dirs should be cbs | ||
file(GLOB challenge_binaries ${main_dir}/*) # list of all files(+paths) in maindir - all dirs should be cbs | ||
add_subdirectory(include) | ||
|
||
function(buildCB flags) | ||
MESSAGE("building ${cb_id}") | ||
aux_source_directory(${cb_path}/src cb_src) #get all source files | ||
aux_source_directory(${cb_path}/lib cb_lib) | ||
aux_source_directory(${cb_path}/include cb_inc) | ||
set(cb_all_src ${cb_lib} ${cb_src} ${cb_inc} ) | ||
|
||
include_directories(${cb_path}/lib) | ||
include_directories(${cb_path}/src) | ||
include_directories(${cb_path}/include) | ||
|
||
set(CFLAGS "${flags} -g3 ${CFLAGS}") | ||
set(CFLAGS "-Derrno=__cgc_errno ${CFLAGS}") | ||
set(CFLAGS "-isystem include ${CFLAGS}") | ||
|
||
if(LINUX) | ||
set(LINUX TRUE) | ||
set(CFLAGS "-m32 ${CFLAGS}") | ||
endif() | ||
|
||
add_executable(${cb_id} ${cb_all_src} ) | ||
add_executable(${cb_id}_patched ${cb_all_src} ) | ||
|
||
set_target_properties(${cb_id} PROPERTIES COMPILE_FLAGS "${CFLAGS}") | ||
set_target_properties(${cb_id}_patched PROPERTIES COMPILE_FLAGS "${CFLAGS} -DPATCHED") | ||
|
||
target_link_libraries (${cb_id} LINK_PUBLIC libcgc) | ||
target_link_libraries (${cb_id}_patched LINK_PUBLIC libcgc) | ||
|
||
endfunction(buildCB) | ||
function(build path target) | ||
message("Building ${target}") | ||
|
||
function(buildCB_LD flags ldflags) | ||
MESSAGE("building ${cb_id}") | ||
aux_source_directory(${cb_path}/src cb_src) #get all source files | ||
aux_source_directory(${cb_path}/lib cb_lib) | ||
aux_source_directory(${cb_path}/include cb_inc) | ||
set(cb_all_src ${cb_lib} ${cb_src} ${cb_inc} ) | ||
# Gather all sources | ||
aux_source_directory(${path}/src cb_src) | ||
aux_source_directory(${path}/lib cb_lib) | ||
aux_source_directory(${path}/include cb_inc) | ||
set(cb_all_src ${cb_lib} ${cb_src} ${cb_inc}) | ||
|
||
include_directories(${cb_path}/lib) | ||
include_directories(${cb_path}/src) | ||
include_directories(${cb_path}/include) | ||
include_directories(${path}/lib) | ||
include_directories(${path}/src) | ||
include_directories(${path}/include) | ||
|
||
set(CFLAGS "${flags} -g3 ${CFLAGS}") | ||
if(LINUX) | ||
set(LINUX TRUE) | ||
set(CFLAGS "-m32 ${CFLAGS}") | ||
endif() | ||
add_executable(${target} ${cb_all_src}) | ||
add_executable(${target}_patched ${cb_all_src}) | ||
|
||
add_executable(${cb_id} ${cb_all_src} ) | ||
add_executable(${cb_id}_patched ${cb_all_src} ) | ||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${CFLAGS} " LINK_FLAGS "-m32") | ||
set_target_properties(${target}_patched PROPERTIES COMPILE_FLAGS "${CFLAGS} -DPATCHED -DPATCHED_1 -DPATCHED_2" LINK_FLAGS "-m32") | ||
|
||
set_target_properties(${cb_id} PROPERTIES COMPILE_FLAGS "${CFLAGS}") | ||
set_target_properties(${cb_id} PROPERTIES LINK_FLAGS "${ldflags}") | ||
set_target_properties(${cb_id}_patched PROPERTIES COMPILE_FLAGS "${CFLAGS} -DPATCHED") | ||
set_target_properties(${cb_id}_patched PROPERTIES LINK_FLAGS "${ldflags} -DPATCHED") | ||
target_link_libraries(${target} LINK_PUBLIC libcgc) | ||
target_link_libraries(${target}_patched LINK_PUBLIC libcgc) | ||
endfunction() | ||
|
||
target_link_libraries (${cb_id} LINK_PUBLIC libcgc) | ||
target_link_libraries (${cb_id}_patched LINK_PUBLIC libcgc) | ||
function(buildCB flags) | ||
set(CFLAGS "${flags} -g3 -m32 ${CFLAGS}") | ||
set(CFLAGS "-Derrno=__cgc_errno ${CFLAGS}") | ||
|
||
# Set OS defines | ||
if(LINUX) | ||
set(CFLAGS "-DLINUX ${CFLAGS}") | ||
endif() | ||
if(APPLE) | ||
set(CFLAGS "-DAPPLE ${CFLAGS}") | ||
endif() | ||
if(WIN) | ||
set(CFLAGS "-DWIN ${CFLAGS}") | ||
endif() | ||
|
||
# Some challenges have multiple binaries that need to be built | ||
# Check if these directories exist | ||
file(GLOB cb_parts "${cb_path}/cb_*") | ||
if(cb_parts) | ||
# Iterate through the directories and build each | ||
set(i 1) | ||
foreach(cb ${cb_parts}) | ||
build(${cb} ${cb_id}_${i}) | ||
MATH(EXPR i "${i} + 1") | ||
endforeach() | ||
else() | ||
# Build normally if there are no extra directories | ||
build(${cb_path} ${cb_id}) | ||
endif() | ||
endfunction(buildCB) | ||
|
||
endfunction(buildCB_LD) | ||
|
||
foreach(cb_path ${challenge_binaries}) #iterate through cbs | ||
# if (LINUX) - test os | ||
if(IS_DIRECTORY ${cb_path} AND EXISTS ${cb_path}/CMakeLists.txt) | ||
MESSAGE("${cb_path}") | ||
get_filename_component(cb_id ${cb_path} NAME) #get filename | ||
|
||
FOREACH(cb_path ${challenge_binaries}) #iterate through cbs | ||
# if (LINUX) - test os | ||
if (IS_DIRECTORY ${cb_path}) | ||
MESSAGE("${cb_path}") | ||
get_filename_component(cb_id ${cb_path} NAME ) #get filename | ||
|
||
add_subdirectory(${cb_path} ${cb_path}/bin) | ||
add_subdirectory(${cb_path} ${cb_path}/bin) | ||
|
||
endif() | ||
# endif() | ||
ENDFOREACH() | ||
endif() | ||
# endif() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Root cb-multios directory | ||
DIR=$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd) | ||
TOOLS="$DIR/tools" | ||
|
||
# Install necessary python packages | ||
python -c "import yaml; import xlsxwriter" | ||
if [[ $? -ne 0 ]]; then | ||
echo "Please install pyyaml and xlsxwriter" | ||
echo " $ sudo pip install pyyaml xlsxwriter" | ||
exit 1 | ||
fi | ||
|
||
echo "Running patcher" | ||
${TOOLS}/cb_patcher.py $@ | ||
|
||
echo "Generating CMakelists" | ||
${TOOLS}/makefiles.py | ||
|
||
echo "Creating build directory" | ||
mkdir ${DIR}/build | ||
cd ${DIR}/build | ||
|
||
echo "Creating Makefiles" | ||
cmake .. | ||
|
||
make |
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.