Skip to content

Instantly share code, notes, and snippets.

@keleshev
Last active August 29, 2015 14:19
Show Gist options
  • Save keleshev/a4982b234b0aa62d2f70 to your computer and use it in GitHub Desktop.
Save keleshev/a4982b234b0aa62d2f70 to your computer and use it in GitHub Desktop.
task :default => :test
PACKAGES = ['core', 'sexplib.syntax']
MENHIR = 'menhir --explain'
TEST_SOURCES = FileList['**/test_*.ml'].exclude(/build\//)
TEST_BINARIES = TEST_SOURCES.pathmap 'build/%X.d.byte'
task :test do |t|
ocamlbuild TEST_BINARIES
TEST_BINARIES.each do |binary|
sh binary
end
end
task :clean do
sh 'rm -rf *build *.byte *.native'
end
# Build any `ocamlbuild` target, for example:
# $ rake build/test_foo.d.byte
# $ rake build/foo/test_bar.native
rule(/^build\//) do |task|
ocamlbuild task.name.sub(/^build\//, '')
end
def ocamlbuild targets
targets = targets.map {|target| target.sub /^build\//, ''}.join ' '
sh "ocamlbuild -build-dir build -syntax camlp4o -cflags '-w @a-6-4-27-44' \
-tag thread -use-ocamlfind -quiet \
-use-menhir -menhir '#{MENHIR}' \
-pkg #{PACKAGES.join ','} \
#{targets}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment