-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from themmj/main
Enable cpp kit development on windows
- Loading branch information
Showing
9 changed files
with
174 additions
and
41 deletions.
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,4 +1,4 @@ | ||
FROM ubuntu:20.04 | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt update | ||
RUN apt install build-essential cmake curl -y | ||
RUN apt install build-essential cmake curl dos2unix tar -y |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@echo off | ||
|
||
Rem check for dependencies and cwd | ||
if not exist %cd%/compile.bat call :abort "script is not running from within the kits directory" & goto :eof | ||
where curl >nul 2>&1 || ( call :abort "curl needs to be installed and available in the PATH" & goto :eof ) | ||
where cmake >nul 2>&1 || ( call :abort "cmake needs to be installed and available in the PATH" & goto :eof ) | ||
|
||
Rem parse input parameters | ||
set build_warnings="ON" | ||
set build_config="Release" | ||
set build_debug="OFF" | ||
set build_dir="build" | ||
|
||
:parameterloop | ||
if "%1"=="" goto parameterloopend | ||
if "%1"=="/h" call :help & goto :eof | ||
if "%1"=="/w" set build_warnings="OFF" | ||
if "%1"=="/d" ( | ||
set build_debug="ON" | ||
set build_config="Debug" | ||
) | ||
if "%1"=="/b" ( | ||
if "%2"=="" call :abort "no build directory provided" & goto :eof | ||
set build_dir="%2" | ||
shift | ||
) | ||
shift | ||
goto parameterloop | ||
:parameterloopend | ||
|
||
Rem download json library | ||
set json_header_path=".\src\lux\nlohmann_json.hpp" | ||
if not exist %json_header_path% curl -o %json_header_path% "https://raw.githubusercontent.com/nlohmann/json/develop/single_include/nlohmann/json.hpp" | ||
if not exist %json_header_path% call :abort "something went wrong when downloading the json library" & goto :eof | ||
|
||
Rem run cmake | ||
if not exist %build_dir% mkdir %build_dir% | ||
cmake -B %build_dir% -DBUILD_WARNINGS=%build_warnings% -DBUILD_DEBUG=%build_debug% || ( call :abort "error during cmake configuration" & goto :eof ) | ||
|
||
Rem build the program | ||
cmake --build %build_dir% --config %build_config% || ( call :abort "error during build of the agent" & goto :eof ) | ||
|
||
Rem done | ||
goto :eof | ||
|
||
Rem helper functions | ||
:help | ||
echo Compilation script for cpp agent. By default with all warnings and optimized. | ||
echo NOTE: Script must be run from the directory it is located in! | ||
echo USAGE: .\compile.bat [OPTIONS] | ||
echo OPTIONS can be: | ||
echo /w : disable compiler warnings (e.g. -pedantic) | ||
echo /d : build in debug mode (O0 and -g) | ||
echo /b other_dir : alternative build dir to use (default: build) | ||
echo /h : print this help page | ||
goto :eof | ||
|
||
:abort | ||
echo %* | ||
echo Aborting... | ||
pause | ||
goto :eof |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@echo off | ||
|
||
Rem check for dependencies and cwd | ||
if not exist %cd%/create_submission.bat call :abort "script is not running from within the kits directory" & goto :eof | ||
where docker >nul 2>&1 || ( call :abort "docker needs to be installed and available in the PATH" & goto :eof ) | ||
|
||
set container_name="luxai_cpp_compiler" | ||
|
||
rem build the image | ||
set images_output= | ||
for /f %%i in ('docker images -q %container_name%') do set "images_output=%%i" | ||
if "%images_output%"=="" ( | ||
docker build -t %container_name% . | ||
if %errorlevel% gtr 0 call :abort "error during image build" & goto :eof | ||
) | ||
|
||
rem start the container | ||
docker ps | findstr %container_name% 1>nul | ||
if %errorlevel% gtr 0 ( | ||
docker run -it -d --name %container_name% -v %cd%:/root --rm %container_name% bash | ||
) | ||
|
||
rem build inside the container | ||
docker exec -w /root %container_name% dos2unix ./compile.sh | ||
docker exec -w /root %container_name% bash ./compile.sh -b docker_build | ||
if %errorlevel% gtr 0 ( | ||
call :abort "error during build inside docker container" & goto :eof | ||
) | ||
|
||
rem create submission archive | ||
set submisson_archive="submission.tar.gz" | ||
if exist %submisson_archive% del %submisson_archive% | ||
docker exec -w /root %container_name% tar --exclude=./%submisson_archive% --warning=no-file-changed -czvf %submisson_archive% . | ||
if %errorlevel% gtr 1 ( | ||
call :abort "error during archive creation" & goto :eof | ||
) | ||
|
||
rem done | ||
echo "successfully built submission" | ||
goto :eof | ||
|
||
rem helper functions | ||
:abort | ||
echo %* | ||
echo Aborting... | ||
pause | ||
goto :eof |
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
".js": "node", | ||
".py": "python", | ||
".out": "./", | ||
".exe": "./", | ||
".java": "java", | ||
} |
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