DlangScience / scid

Scientific library for the D programming language
Boost Software License 1.0
90 stars 31 forks source link

build.d able to build as sharedlib with ldc 2 #8

Closed bioinfornatics closed 9 years ago

bioinfornatics commented 11 years ago
diff -up scid-20120429git51236f3/build.d.fix scid-20120429git51236f3/build.d
--- scid-20120429git51236f3/build.d.fix 2012-04-26 19:19:05.000000000 +0200
+++ scid-20120429git51236f3/build.d 2012-10-11 01:00:47.433973977 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env dmd -run
+#!/usr/bin/env ldc2 -run

 /** Build system for SciD

@@ -8,26 +8,26 @@
     Usage:
     To build the library and generate header (.di) files, run
     ---
-    rdmd build
+    ./build
     ---
     To build only the library file, run
     ---
-    rdmd build lib
+    ./build lib
     ---
     To only generate header files, run
     ---
-    rdmd build headers
+    ./build headers
     ---
     To make the documentation, run
     ---
-    rdmd build html
+    ./build html
     ---

     Any command line arguments beyond the first one will be passed
     on to the compiler.  For example, to enable optimisations and
     inlining when building the library, run
     ---
-    rdmd build lib -O -inline
+    ./build lib -O -inline
     ---
 */
 import std.algorithm, std.array, std.exception, std.file, std.getopt, std.path,
@@ -69,7 +69,7 @@ in { assert (args.length > 0); }
 body
 {
     bool gdc;
-    string compiler = "dmd";
+    string compiler = "ldc2";

     getopt(args, std.getopt.config.passThrough, "gdc", &gdc);
     if(gdc)
@@ -109,15 +109,15 @@ void buildLib(string compiler, string[]
     ensureDir(libDir);
     auto sources = getSources();

-    version (Posix)     immutable libFile = "lib"~libName~".a";
+    version (Posix)     immutable libFile = "lib"~libName~"-ldc.so";
     version (Windows)   immutable libFile = libName~".lib";

-    immutable buildCmd = compiler ~ " "
+    immutable buildldc = compiler ~ " "
         ~std.string.join(sources, " ")
-        ~" -lib -od"~libDir~" -of"~libFile
+        ~" -shared -soname "~ libFile~".1"~" -od"~libDir~" -of"~libFile~".1.0.0"
         ~" "~std.string.join(extraOptions, " ");
-    writeln(buildCmd);
-    enforce(system(buildCmd) == 0, "Error building library");
+    writeln(buildldc);
+    enforce(system(buildldc) == 0, "Error building library");
 }

@@ -201,7 +201,7 @@ void buildClean()
     rm(libDir);
     rm(headerDir);
     rm(htmlDir);
-    rm(__FILE__~".deps");   // Clean up after rdmd as well
+    rm(__FILE__~".deps");   // Clean up after ./as well
 }