diff --git a/build/artefact.rb b/build/artefact.rb index a74951e5..5c3bab50 100644 --- a/build/artefact.rb +++ b/build/artefact.rb @@ -119,6 +119,16 @@ end.join(" ") + USE_COMPONENT.map {|i| "#{ENV['CORTO_HOME']}/lib/corto/#{VERSION}/components/lib" + i + ".so"}.join(" ") + USE_LIBRARY.map {|i| "#{ENV['CORTO_HOME']}/lib/corto/#{VERSION}/libraries/lib" + i + ".so"}.join(" ") + + # Check if there were any new files created during code generation + Rake::FileList["src/*.c"].each do |file| + if not SOURCES.include? file + obj = file.ext(".o").pathmap(".corto/obj/%f") + build_source(file, obj, true) + objects += " " + obj + end + end + cc_command = "cc #{objects} #{cflags} #{corto_lib} #{libpath} #{libmapping} #{use_link} #{lflags}" sh cc_command if ENV['silent'] != "true" then @@ -130,19 +140,19 @@ task :postbuild rule '__api.o' => ->(t){t.pathmap(".corto/%f").ext(".c")} do |task| - build_source(task, false) + build_source(task.source, task.name, false) end rule '__meta.o' => ->(t){t.pathmap(".corto/%f").ext(".c")} do |task| - build_source(task, false) + build_source(task.source, task.name, false) end rule '__wrapper.o' => ->(t){t.pathmap(".corto/%f").ext(".c")} do |task| - build_source(task, false) + build_source(task.source, task.name, false) end rule '__load.o' => ->(t){t.pathmap(".corto/%f").ext(".c")} do |task| - build_source(task, false) + build_source(task.source, task.name, false) end rule '.o' => ->(t){t.pathmap("src/%f").ext(".c")} do |task| - build_source(task, true) + build_source(task.source, task.name, true) end task :all => :default @@ -153,15 +163,15 @@ sh "corto test" end -def build_source(task, echo) +def build_source(source, target, echo) verbose(false) if not File.exists? ".corto/obj" then sh "mkdir -p .corto/obj" end if echo if ENV['silent'] != "true" then - sh "echo '#{task.source}'" + sh "echo '#{source}'" end end - sh "cc -c #{CFLAGS.join(" ")} #{DEFINES.map {|d| "-D" + d}.join(" ")} #{INCLUDE.map {|i| "-I" + i}.join(" ")} #{task.source} -o #{task.name}" + sh "cc -c #{CFLAGS.join(" ")} #{DEFINES.map {|d| "-D" + d}.join(" ")} #{INCLUDE.map {|i| "-I" + i}.join(" ")} #{source} -o #{target}" end diff --git a/build/package.rb b/build/package.rb index 303f6dc7..5c58b7f1 100644 --- a/build/package.rb +++ b/build/package.rb @@ -63,71 +63,15 @@ end end -task :default => "include/#{TARGET}__type.h" do - require "./.corto/dep.rb" - - # Delay running inherited tasks - we first need to run - # code generation for us to know which source files - # have to be compiled. - require "#{ENV['CORTO_BUILD']}/component" - Rake::Task["prebuild"].invoke - Rake::Task["binary"].invoke - Rake::Task["postbuild"].invoke -end - -clobber_count = 1 -clean_count = 1 -collect_count = 1 -install_count = 1 - -task :clean do - # Recursively call clean, prevent infinite recursion - if clean_count == 1 then - clean_count += 1 - Rake::Task["clean"].reenable - require "#{ENV['CORTO_BUILD']}/component" - Rake::Task["clean"].execute - if File.exists?(".corto/dep.rb") - sh "rake clean -f .corto/dep.rb" - end - end -end - -task :clobber do - # Recursively call clobber, prevent infinite recursion - if clobber_count == 1 then - clobber_count += 1 - Rake::Task["clobber"].reenable - require "#{ENV['CORTO_BUILD']}/component" - Rake::Task["clobber"].execute - if File.exists?(".corto/dep.rb") - sh "rake clobber -f .corto/dep.rb" - end - end -end - -task :collect do - # Recursively call collect, prevent infinite recursion - if collect_count == 1 then - collect_count += 1 - Rake::Task["collect"].reenable - require "#{ENV['CORTO_BUILD']}/component" - Rake::Task["collect"].execute - end -end - -task :install do - # Recursively call collect, prevent infinite recursion - if install_count == 1 then - install_count += 1 - Rake::Task["install"].reenable - require "#{ENV['CORTO_BUILD']}/component" - Rake::Task["install"].execute - end -end +task :default => "include/#{TARGET}__type.h" if File.exists? "test" then COMPONENTS ||=[] << "test" end +if File.exists? "./.corto/dep.rb" + require "./.corto/dep.rb" +end + +require "#{ENV['CORTO_BUILD']}/component" require "#{ENV['CORTO_BUILD']}/subrake"