sip: build test with sip's build system
and set PYTHONPATH for the bot. Closes Homebrew/homebrew#36676.
This commit is contained in:
parent
87d0a2919b
commit
dba92ceb1e
1 changed files with 13 additions and 12 deletions
|
@ -78,23 +78,24 @@ class Sip < Formula
|
||||||
void test();
|
void test();
|
||||||
};
|
};
|
||||||
EOS
|
EOS
|
||||||
|
(testpath/"generate.py").write <<-EOS.undent
|
||||||
|
from sipconfig import SIPModuleMakefile, Configuration
|
||||||
|
m = SIPModuleMakefile(Configuration(), "test.build")
|
||||||
|
m.extra_libs = ["test"]
|
||||||
|
m.extra_lib_dirs = ["."]
|
||||||
|
m.generate()
|
||||||
|
EOS
|
||||||
(testpath/"run.py").write <<-EOS.undent
|
(testpath/"run.py").write <<-EOS.undent
|
||||||
from test import Test
|
from test import Test
|
||||||
t = Test()
|
t = Test()
|
||||||
t.test()
|
t.test()
|
||||||
EOS
|
EOS
|
||||||
system "#{bin}/sip", "-c", ".", "test.sip"
|
system ENV.cxx, "-shared", "-o", "libtest.dylib", "test.cpp"
|
||||||
Language::Python.each_python(build) do |python, _version|
|
system "#{bin}/sip", "-b", "test.build", "-c", ".", "test.sip"
|
||||||
cppflags = `#{python}-config --cflags`.strip.split
|
Language::Python.each_python(build) do |python, version|
|
||||||
ldflags = `#{python}-config --ldflags`.strip.split
|
ENV["PYTHONPATH"] = lib/"python#{version}/site-packages"
|
||||||
cppflags << "-I#{include}"
|
system python, "generate.py"
|
||||||
ldflags += %w[-L#{lib} -shared -undefined dynamic_lookup]
|
system "make", "-j1", "clean", "all"
|
||||||
Dir[testpath/"*.cpp"].each do |source|
|
|
||||||
object = File.basename(source, ".cpp") + ".o"
|
|
||||||
system ENV.cxx, "-c", source, "-o", object, *cppflags
|
|
||||||
end
|
|
||||||
link_args= Dir[testpath/"*.o"] + %w[-o test.so] + ldflags
|
|
||||||
system ENV.cxx, *link_args
|
|
||||||
system python, "run.py"
|
system python, "run.py"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue