Skip to content

Commit

Permalink
Merge branch 'c_nostdinc'
Browse files Browse the repository at this point in the history
  • Loading branch information
withzombies committed Aug 1, 2016
2 parents d4429ad + 7fa6d33 commit 6ca3583
Show file tree
Hide file tree
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.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ $RECYCLE.BIN/
CMakeCache.txt
CMakeFiles
CMakeScripts
Makefile

cmake_install.cmake
install_manifest.txt

Expand Down Expand Up @@ -204,7 +204,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down Expand Up @@ -249,3 +248,7 @@ target/
.DS_Store

cqe-challenges/*/bin/*
.idea/
_backup/
cqe-challenges/
test.cpp
138 changes: 67 additions & 71 deletions CMakeLists.txt
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()
28 changes: 28 additions & 0 deletions build.sh
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 removed cqe-challenges/.DS_Store
Binary file not shown.
Binary file removed cqe-challenges/CADET_00001/.DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions cqe-challenges/CADET_00001/CMakeLists.txt

This file was deleted.

2 changes: 0 additions & 2 deletions cqe-challenges/CADET_00001/Makefile

This file was deleted.

Binary file removed cqe-challenges/CADET_00001/lib/.DS_Store
Binary file not shown.
Binary file removed cqe-challenges/CADET_00003/.DS_Store
Binary file not shown.
4 changes: 0 additions & 4 deletions cqe-challenges/CADET_00003/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions cqe-challenges/CADET_00003/Makefile

This file was deleted.

42 changes: 0 additions & 42 deletions cqe-challenges/CADET_00003/poller/for-release/machine.py

This file was deleted.

13 changes: 0 additions & 13 deletions cqe-challenges/CROMU_00001/CMakeLists.txt

This file was deleted.

34 changes: 0 additions & 34 deletions cqe-challenges/CROMU_00001/README.md

This file was deleted.

59 changes: 0 additions & 59 deletions cqe-challenges/CROMU_00001/lib/mymath.c

This file was deleted.

Loading

0 comments on commit 6ca3583

Please sign in to comment.