diff --git a/project.janet b/project.janet index 3a1366e..692a48d 100644 --- a/project.janet +++ b/project.janet @@ -1,12 +1,33 @@ -(declare-project :name "geom") +(declare-project :name "geom" + :dependencies ["https://github.com/joy-framework/tester"]) -(os/shell (string/join [ - "mkdir" "-p" "lib2geom/build" "&&" - "cd" "lib2geom/build" "&&" - "cmake" ".." "-D2GEOM_BUILD_SHARED:BOOL=ON" "&&" - "make" "2geom"] " ")) +(def- is-win (= (os/which) :windows)) +(def- sep (if is-win "\\" "/")) +(def- modext (if is-win ".dll" ".so")) +(def- statext (if is-win ".static.lib" ".a")) + +(rule "lib2geom.a" [] + (def olddir (os/cwd)) + (try + (do + (shell "pwd") + (os/mkdir "lib2geom/build") + (os/cd "lib2geom/build") + (shell "cmake" ".." "-DCMAKE_CXX_FLAGS:STRING=-fPIC") + (shell "make" "2geom")) + ([err] (print "Error compiling lib2geom.a: " err))) + (os/cd olddir)) +(add-body "clean" + (shell "rm" "-rf" "lib2geom/build") + (print "Deleted lib2geom build directory.")) + (declare-native :name "geom" :source @["src/point.cpp" "src/main.cpp"] :compiler "g++" :linker "g++" - :cflags ["-Wall" "-Wextra" "-Iinclude" "-Ilib2geom/src" "-Llib2geom/build/src/2geom"] - :lflags ["-l2geom" "-ldl" "-ldouble-conversion" "-lgsl" "-lgslcblas" "-lm"]) + :cflags ["-Wall" "-Wextra" "-Iinclude" "-Ilib2geom/src"] + :lflags ["lib2geom/build/src/2geom/lib2geom.a" "-ldl" "-ldouble-conversion" "-lgsl" "-lgslcblas" "-lm"]) + +(def- lname (string "build" sep "geom" statext)) +(def- sname (string "build" sep "geom" modext)) +(add-dep lname "lib2geom.a") +(add-dep sname "lib2geom.a")