Created
May 17, 2022 13:00
-
-
Save ageldama/c18cd1ad1671fde808e552aeb886b318 to your computer and use it in GitHub Desktop.
Rakefile: cc with separated build dir
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
require 'pathname' | |
SRCS = FileList['**/*.c'] | |
DSTS = SRCS.ext('o').pathmap('build/%d/%f').map do |f| | |
Pathname.new(f).cleanpath.to_s | |
end | |
DST_TO_SRC_H = DSTS.zip(SRCS).to_h | |
task :compile => DSTS | |
task :clean do |t| | |
DSTS.each do |f| | |
rm f, force: true | |
end | |
end | |
rule '.o' => ->(f){DSTS.zip(SRCS).to_h[f]} do |t| | |
mkdir_p t.name.pathmap('%d') | |
sh "cc -c -o #{t.name} #{t.source}" | |
end | |
task :default => :compile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment