<commit_before>
libyojimbo_version = "0.2.0"

if os.is "windows" then
    debug_libs = { "sodium-debug", "mbedtls-debug", "mbedx509-debug", "mbedcrypto-debug" }
    release_libs = { "sodium-release", "mbedtls-release", "mbedx509-release", "mbedcrypto-release" }
else
    debug_libs = { "sodium", "mbedtls", "mbedx509", "mbedcrypto" }
    release_libs = debug_libs
end

solution "Yojimbo"
    platforms { "x64" }
    if os.is "windows" then
        includedirs { ".", "./windows" }
        libdirs { "./windows" }
    else
        includedirs { ".", "/usr/local/include" }       -- for clang scan-build only. for some reason it needs it to work
    end
    if not os.is "windows" then
        targetdir "bin/"  
    end
    configurations { "Debug", "Release" }
    flags { "ExtraWarnings", "FatalWarnings", "StaticRuntime", "FloatFast" }
    rtti "Off"
    configuration "Debug"
        flags { "Symbols" }
        defines { "DEBUG" }
    configuration "Release"
        optimize "Speed"
        defines { "NDEBUG" }

project "test"
    language "C++"
    kind "ConsoleApp"
    files { "test.cpp" }
    links { "yojimbo" }
    configuration "Debug"
		links { debug_libs }
	configuration "Release"
        links { release_libs }

project "connect"
    language "C++"
    kind "ConsoleApp"
    files { "connect.cpp" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "info"
    language "C++"
    kind "ConsoleApp"
    files { "info.cpp" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "yojimbo"
    language "C++"
    kind "StaticLib"
    files { "yojimbo.h", "yojimbo.cpp", "yojimbo_*.h", "yojimbo_*.cpp" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "client"
    language "C++"
    kind "ConsoleApp"
    files { "client.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "server"
    language "C++"
    kind "ConsoleApp"
    files { "server.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "secure_server"
    language "C++"
    kind "ConsoleApp"
    files { "server.cpp", "shared.h" }
    links { "yojimbo" }
    defines { "SECURE_SERVER=1" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "client_server"
    language "C++"
    kind "ConsoleApp"
    files { "client_server.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

if not os.is "windows" then

    newaction
    {
        trigger     = "test",
        description = "Build and run all unit tests",
        execute = function ()
            if os.execute "make -j32 test" == 0 then
                os.execute "./bin/test"
            end
        end
    }

    newaction
    {
        trigger     = "info",
        description = "Build and run network info utility",
        execute = function ()
            if os.execute "make -j32 info" == 0 then
                os.execute "./bin/info"
            end
        end
    }

    newaction
    {
        trigger     = "cs",
        description = "Build and run client/server testbed",     
        execute = function ()
            if os.execute "make -j32 client_server" == 0 then
                os.execute "./bin/client_server"
            end
        end
    }

    newoption 
    {
        trigger     = "serverAddress",
        value       = "IP[:port]",
        description = "Specify the server address that the client should connect to",
    }

    newaction
    {
        trigger     = "client",
        description = "Build and run client",
        valid_kinds = premake.action.get("gmake").valid_kinds,
        valid_languages = premake.action.get("gmake").valid_languages,
        valid_tools = premake.action.get("gmake").valid_tools,
     
        execute = function ()
            if os.execute "make -j32 client" == 0 then
                if _OPTIONS["serverAddress"] then
                    os.execute( "./bin/client " .. _OPTIONS["serverAddress"] )
                else
                    os.execute "./bin/client"
                end
            end
        end
    }

    newaction
    {
        trigger     = "server",
        description = "Build and run server",     
        execute = function ()
            if os.execute "make -j32 server" == 0 then
                os.execute "./bin/server"
            end
        end
    }

    newaction
    {
        trigger     = "secure_server",
        description = "Build and run secure server",     
        execute = function ()
            if os.execute "make -j32 secure_server" == 0 then
                os.execute "./bin/secure_server"
            end
        end
    }

	newaction
	{
		trigger     = "docker",
		description = "Build and run a yojimbo server inside a docker container",
		execute = function ()
			os.execute "rm -rf docker/libyojimbo && mkdir -p docker/libyojimbo && cp *.h docker/libyojimbo && cp *.cpp docker/libyojimbo && cp premake5.lua docker/libyojimbo && cp -R rapidjson docker/libyojimbo && cd docker && docker build -t \"networkprotocol:yojimbo-server\" . && rm -rf libyojimbo && docker run -ti -p 50000:50000/udp networkprotocol:yojimbo-server"
		end
	}

    newaction
    {
        trigger     = "matcher",
        description = "Build and run the matchmaker web service inside a docker container",
        execute = function ()
            os.execute "cd docker/matcher && docker build -t networkprotocol:yojimbo-matcher . && docker run -ti -p 8080:8080 networkprotocol:yojimbo-matcher"
        end
    }

    newaction
    {
        trigger     = "connect",
        description = "Build and run connect test program",
        execute = function ()
            if os.execute "make -j32 connect" == 0 then
                os.execute "./bin/connect"
            end
        end
    }

    newaction
    {
        trigger     = "stress",
        description = "Launch 64 connect instances to stress the matcher and server",
        execute = function ()
            if os.execute "make -j32 connect" == 0 then
                for i = 0, 63 do
                    os.execute "./bin/connect &"
                end
            end
        end
    }

    newaction
    {
        trigger     = "cppcheck",
        description = "Run cppcheck over the source code and write to cppcheck.txt",
        execute = function ()
            os.execute "cppcheck *.h *.cpp --force --std=c++03 --language=c++ --quiet -U min -U max 2>&1 --config-exclude=rapidjson --suppress=cstyleCast --suppress=unusedFunction --suppress=unusedStructMember --suppress=variableScope --suppress=memsetClassFloat --enable=warning --enable=performance --enable=style --platform=native -j 32 | tee -a cppcheck.txt"
        end
    }

    newaction
    {
        trigger     = "release",
        description = "Create a release of this project",
        execute = function ()
            _ACTION = "clean"
            premake.action.call( "clean" )
            files_to_zip = "README.md BUILDING.md CHANGES.md ROADMAP.md *.cpp *.h premake5.lua docker rapidjson windows"
            os.execute( "rm -rf *.zip *.tar.gz *.7z" );
            os.execute( "rm -rf docker/libyojimbo" );
            os.execute( "zip -9r libyojimbo-" .. libyojimbo_version .. ".zip " .. files_to_zip )
            os.execute( "7z a -y -mx=9 -p\"information wants to be free\" libyojimbo-" .. libyojimbo_version .. ".7z " .. files_to_zip )
            os.execute( "unzip libyojimbo-" .. libyojimbo_version .. ".zip -d libyojimbo-" .. libyojimbo_version );
            os.execute( "tar -zcvf libyojimbo-" .. libyojimbo_version .. ".tar.gz libyojimbo-" .. libyojimbo_version );
            os.execute( "rm -rf libyojimbo-" .. libyojimbo_version );
            os.execute( "mkdir -p release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".7z release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".zip release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".tar.gz release" );
            os.execute( "echo" );
            os.execute( "echo \"*** SUCCESSFULLY CREATED RELEASE - libyojimbo-" .. libyojimbo_version .. " *** \"" );
            os.execute( "echo" );
        end
    }

else

	newaction
	{
		trigger     = "docker",
		description = "Build and run a yojimbo server inside a docker container",
		execute = function ()
			os.execute "cd docker && copyFiles.bat && buildServer.bat && runServer.bat"
		end
	}<commit_msg>added premake5 solution convenience action. one step build and launch vs2015 sln<commit_after>
libyojimbo_version = "0.2.0"

if os.is "windows" then
    debug_libs = { "sodium-debug", "mbedtls-debug", "mbedx509-debug", "mbedcrypto-debug" }
    release_libs = { "sodium-release", "mbedtls-release", "mbedx509-release", "mbedcrypto-release" }
else
    debug_libs = { "sodium", "mbedtls", "mbedx509", "mbedcrypto" }
    release_libs = debug_libs
end

solution "Yojimbo"
    platforms { "x64" }
    if os.is "windows" then
        includedirs { ".", "./windows" }
        libdirs { "./windows" }
    else
        includedirs { ".", "/usr/local/include" }       -- for clang scan-build only. for some reason it needs it to work
    end
    if not os.is "windows" then
        targetdir "bin/"  
    end
    configurations { "Debug", "Release" }
    flags { "ExtraWarnings", "FatalWarnings", "StaticRuntime", "FloatFast" }
    rtti "Off"
    configuration "Debug"
        flags { "Symbols" }
        defines { "DEBUG" }
    configuration "Release"
        optimize "Speed"
        defines { "NDEBUG" }

project "test"
    language "C++"
    kind "ConsoleApp"
    files { "test.cpp" }
    links { "yojimbo" }
    configuration "Debug"
		links { debug_libs }
	configuration "Release"
        links { release_libs }

project "connect"
    language "C++"
    kind "ConsoleApp"
    files { "connect.cpp" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "info"
    language "C++"
    kind "ConsoleApp"
    files { "info.cpp" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "yojimbo"
    language "C++"
    kind "StaticLib"
    files { "yojimbo.h", "yojimbo.cpp", "yojimbo_*.h", "yojimbo_*.cpp" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "client"
    language "C++"
    kind "ConsoleApp"
    files { "client.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "server"
    language "C++"
    kind "ConsoleApp"
    files { "server.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "secure_server"
    language "C++"
    kind "ConsoleApp"
    files { "server.cpp", "shared.h" }
    links { "yojimbo" }
    defines { "SECURE_SERVER=1" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

project "client_server"
    language "C++"
    kind "ConsoleApp"
    files { "client_server.cpp", "shared.h" }
    links { "yojimbo" }
    configuration "Debug"
        links { debug_libs }
    configuration "Release"
        links { release_libs }

if not os.is "windows" then

    -- MacOSX and Linux.
    
    newaction
    {
        trigger     = "test",
        description = "Build and run all unit tests",
        execute = function ()
            if os.execute "make -j32 test" == 0 then
                os.execute "./bin/test"
            end
        end
    }

    newaction
    {
        trigger     = "info",
        description = "Build and run network info utility",
        execute = function ()
            if os.execute "make -j32 info" == 0 then
                os.execute "./bin/info"
            end
        end
    }

    newaction
    {
        trigger     = "cs",
        description = "Build and run client/server testbed",     
        execute = function ()
            if os.execute "make -j32 client_server" == 0 then
                os.execute "./bin/client_server"
            end
        end
    }

    newoption 
    {
        trigger     = "serverAddress",
        value       = "IP[:port]",
        description = "Specify the server address that the client should connect to",
    }

    newaction
    {
        trigger     = "client",
        description = "Build and run client",
        valid_kinds = premake.action.get("gmake").valid_kinds,
        valid_languages = premake.action.get("gmake").valid_languages,
        valid_tools = premake.action.get("gmake").valid_tools,
     
        execute = function ()
            if os.execute "make -j32 client" == 0 then
                if _OPTIONS["serverAddress"] then
                    os.execute( "./bin/client " .. _OPTIONS["serverAddress"] )
                else
                    os.execute "./bin/client"
                end
            end
        end
    }

    newaction
    {
        trigger     = "server",
        description = "Build and run server",     
        execute = function ()
            if os.execute "make -j32 server" == 0 then
                os.execute "./bin/server"
            end
        end
    }

    newaction
    {
        trigger     = "secure_server",
        description = "Build and run secure server",     
        execute = function ()
            if os.execute "make -j32 secure_server" == 0 then
                os.execute "./bin/secure_server"
            end
        end
    }

	newaction
	{
		trigger     = "docker",
		description = "Build and run a yojimbo server inside a docker container",
		execute = function ()
			os.execute "rm -rf docker/libyojimbo && mkdir -p docker/libyojimbo && cp *.h docker/libyojimbo && cp *.cpp docker/libyojimbo && cp premake5.lua docker/libyojimbo && cp -R rapidjson docker/libyojimbo && cd docker && docker build -t \"networkprotocol:yojimbo-server\" . && rm -rf libyojimbo && docker run -ti -p 50000:50000/udp networkprotocol:yojimbo-server"
		end
	}

    newaction
    {
        trigger     = "matcher",
        description = "Build and run the matchmaker web service inside a docker container",
        execute = function ()
            os.execute "cd docker/matcher && docker build -t networkprotocol:yojimbo-matcher . && docker run -ti -p 8080:8080 networkprotocol:yojimbo-matcher"
        end
    }

    newaction
    {
        trigger     = "connect",
        description = "Build and run connect test program",
        execute = function ()
            if os.execute "make -j32 connect" == 0 then
                os.execute "./bin/connect"
            end
        end
    }

    newaction
    {
        trigger     = "stress",
        description = "Launch 64 connect instances to stress the matcher and server",
        execute = function ()
            if os.execute "make -j32 connect" == 0 then
                for i = 0, 63 do
                    os.execute "./bin/connect &"
                end
            end
        end
    }

    newaction
    {
        trigger     = "cppcheck",
        description = "Run cppcheck over the source code and write to cppcheck.txt",
        execute = function ()
            os.execute "cppcheck *.h *.cpp --force --std=c++03 --language=c++ --quiet -U min -U max 2>&1 --config-exclude=rapidjson --suppress=cstyleCast --suppress=unusedFunction --suppress=unusedStructMember --suppress=variableScope --suppress=memsetClassFloat --enable=warning --enable=performance --enable=style --platform=native -j 32 | tee -a cppcheck.txt"
        end
    }

    newaction
    {
        trigger     = "release",
        description = "Create a release of this project",
        execute = function ()
            _ACTION = "clean"
            premake.action.call( "clean" )
            files_to_zip = "README.md BUILDING.md CHANGES.md ROADMAP.md *.cpp *.h premake5.lua docker rapidjson windows"
            os.execute( "rm -rf *.zip *.tar.gz *.7z" );
            os.execute( "rm -rf docker/libyojimbo" );
            os.execute( "zip -9r libyojimbo-" .. libyojimbo_version .. ".zip " .. files_to_zip )
            os.execute( "7z a -y -mx=9 -p\"information wants to be free\" libyojimbo-" .. libyojimbo_version .. ".7z " .. files_to_zip )
            os.execute( "unzip libyojimbo-" .. libyojimbo_version .. ".zip -d libyojimbo-" .. libyojimbo_version );
            os.execute( "tar -zcvf libyojimbo-" .. libyojimbo_version .. ".tar.gz libyojimbo-" .. libyojimbo_version );
            os.execute( "rm -rf libyojimbo-" .. libyojimbo_version );
            os.execute( "mkdir -p release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".7z release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".zip release" );
            os.execute( "mv libyojimbo-" .. libyojimbo_version .. ".tar.gz release" );
            os.execute( "echo" );
            os.execute( "echo \"*** SUCCESSFULLY CREATED RELEASE - libyojimbo-" .. libyojimbo_version .. " *** \"" );
            os.execute( "echo" );
        end
    }

else

    -- Windows

    newaction
    {
        trigger     = "solution",
        description = "Open Yojimbo.sln",
        execute = function ()
            os.execute "premake5 vs2015"
            os.execute "start Yojimbo.sln"
        end
    }

	newaction
	{
		trigger     = "docker",
		description = "Build and run a yojimbo server inside a docker container",
		execute = function ()
			os.execute "cd docker && copyFiles.bat && buildServer.bat && runServer.bat"
		end
	}
{'fraction_non_alphanumeric': 0.11870266710569641, 'fraction_numerical': 0.008890352321369773, 'mean_word_length': 1.926919370382268, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2427824', 'n_tokens_mistral': 5806, 'n_tokens_neox': 5494, 'n_words': 1476}