<commit_before>
task :clean => [] do
    sh "rm -f *.o"
    sh "rm -rf obj"
    sh "rm -f test/*.o"
end

directory "obj"
directory "test_obj"

INC = FileList[ 'src/*.h' ]
SRC = FileList[ 'src/*.cpp' ]
OBJ = SRC.sub( /\.cpp$/, '.o' ).sub( /^src\//, 'obj/' )
INC.freeze
SRC.freeze
OBJ.freeze
TEST_INC = FileList[ 'test/*.h' ]
TEST_SRC = FileList[ 'test/*.cpp' ]
TEST_SRC.exclude( 'testpp_test.cpp' )
TEST_OBJ = TEST_SRC.sub( /\.cpp$/, '.o' ).sub( /^test\//, 'test_obj/' )
TEST_INC.freeze
TEST_SRC.freeze
TEST_OBJ.freeze


# rule '.o' => ['.cpp'] do |t|
    # sh %{g++ -c -g -Isrc -o #{t.name} #{t.source}}
# end

def obj_dep( o )
    deps = []
    cpp = o.sub(/\.o$/,'.cpp').sub(/^obj\//, 'src/') \
        .sub(/^test_obj\//, 'test/')
    deps << cpp
    deps << cpp.sub( /\.cpp$/,'.h')
    return deps
end

rule '.o' => [
    proc { |o| obj_dep( o ) }
] do |t|
    sh %{g++ -c -g -Isrc -o #{t.name} #{t.source}}
end


file "shessiond" => [ :compile ] do |t|
    sh "g++ -o shessiond #{OBJ}"
end


file "test_shessiond" => [ :compile, :compile_test ] do |t|
    no_main_obj = OBJ.clone
    no_main_obj.exclude( 'main.o' )
    sh "g++ -o test_shessiond #{no_main_obj} #{TEST_OBJ}"
end


file "load_shessiond" => [ :compile, "load/load.cpp" ] do |t|
    no_main_obj = OBJ.clone
    no_main_obj.exclude( 'main.o' )
    sh "g++ -Isrc -o load_shessiond #{no_main_obj} load/load.cpp"
end



task :default => [ :compile ]


desc "Compile all source files into objects"
task :compile => [ "obj" ] + OBJ

desc "Compile all test files into objects"
task :compile_test => [ "test_obj" ] + TEST_OBJ


desc "Build the main executable"
task :build => [ "shessiond" ]

desc "Build the test executable"
task :build_test => [ "test_shessiond" ]

desc "Build the test executable"
task :build_load => [ "load_shessiond" ]


desc "Make and run tests"<commit_msg>rolled back the header dependency.  cleaned up the rakefile. put all source under obj/<commit_after>
task :clean => [] do
    sh "rm -f *.o"
    sh "rm -rf obj"
    sh "rm -f test/*.o"
end

directory "obj/src"
directory "obj/test"

INC = FileList[ 'src/*.h' ]
SRC = FileList[ 'src/*.cpp' ]
OBJ = SRC.sub( /\.cpp$/, '.o' ).sub( /^src\//, 'obj/src/' )
INC.freeze
SRC.freeze
OBJ.freeze
TEST_INC = FileList[ 'test/*.h' ]
TEST_SRC = FileList[ 'test/*.cpp' ]
TEST_SRC.exclude( 'testpp_test.cpp' )
TEST_OBJ = TEST_SRC.sub( /\.cpp$/, '.o' ).sub( /^test\//, 'obj/test/' )
TEST_INC.freeze
TEST_SRC.freeze
TEST_OBJ.freeze


# Return dependencies for an object file.
def obj_dep( o )
    deps = []
    cpp = o.sub(/\.o$/,'.cpp').sub(/^obj\/src\//, 'src/') \
        .sub(/^obj\/test\//, 'test/')
    deps << cpp
    return deps
end


rule '.o' => [ proc { |o| obj_dep( o ) } ] do |t|
    sh %{g++ -c -g -Isrc -o #{t.name} #{t.source}}
end


file "shessiond" => [ :compile ] do |t|
    sh "g++ -o shessiond #{OBJ}"
end


file "test_shessiond" => [ :compile, :compile_test ] do |t|
    no_main_obj = OBJ.clone
    no_main_obj.exclude( 'main.o' )
    sh "g++ -o test_shessiond #{no_main_obj} #{TEST_OBJ}"
end


file "load_shessiond" => [ :compile, "load/load.cpp" ] do |t|
    no_main_obj = OBJ.clone
    no_main_obj.exclude( 'main.o' )
    sh "g++ -Isrc -o load_shessiond #{no_main_obj} load/load.cpp"
end



task :default => [ :compile ]


desc "Compile all source files into objects"
task :compile => [ "obj/src" ] + OBJ

desc "Compile all test files into objects"
task :compile_test => [ "obj/test" ] + TEST_OBJ


desc "Build the main executable"
task :build => [ "shessiond" ]

desc "Build the test executable"
task :build_test => [ "test_shessiond" ]

desc "Build the test executable"
task :build_load => [ "load_shessiond" ]


desc "Make and run tests"
{'fraction_non_alphanumeric': 0.19674355495251017, 'fraction_numerical': 0.0, 'mean_word_length': 2.9634408602150537, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 26, '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': '557836', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1519, 'n_words': 407}