Skip to content

Commit

Permalink
Merge b3eef0b into 3ecb1e3
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Colvin committed Jun 27, 2017
2 parents 3ecb1e3 + b3eef0b commit 00a52fa
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 14 deletions.
8 changes: 5 additions & 3 deletions source/dub/compilers/buildsettings.d
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ enum BuildOption {
deprecationErrors = 1<<19, /// Stop compilation upon usage of deprecated features (-de)
property = 1<<20, /// DEPRECATED: Enforce property syntax (-property)
profileGC = 1<<21, /// Profile runtime allocations
pic = 1<<22, /// Generate position independent code
// for internal usage
_docs = 1<<22, // Write ddoc to docs
_ddox = 1<<23, // Compile docs.json
_docs = 1<<23, // Write ddoc to docs
_ddox = 1<<24 // Compile docs.json
}

struct BuildOptions {
Expand Down Expand Up @@ -326,4 +327,5 @@ enum BuildOptions inheritedBuildOptions = BuildOption.debugMode | BuildOption.re
| BuildOption.noBoundsCheck | BuildOption.profile | BuildOption.ignoreUnknownPragmas
| BuildOption.syntaxOnly | BuildOption.warnings | BuildOption.warningsAsErrors
| BuildOption.ignoreDeprecations | BuildOption.deprecationWarnings
| BuildOption.deprecationErrors | BuildOption.property | BuildOption.profileGC;
| BuildOption.deprecationErrors | BuildOption.property | BuildOption.profileGC
| BuildOption.pic;
3 changes: 1 addition & 2 deletions source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import std.conv;
import std.exception;
import std.file;
import std.process;
import std.random;
import std.typecons;


Expand Down Expand Up @@ -117,7 +116,7 @@ class DMDCompiler : Compiler {
}

version (Posix) {
if (settings.targetType == TargetType.dynamicLibrary)
if (settings.options & BuildOption.pic)
settings.addDFlags("-fPIC");
}

Expand Down
3 changes: 1 addition & 2 deletions source/dub/compilers/gdc.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import std.conv;
import std.exception;
import std.file;
import std.process;
import std.random;
import std.typecons;


Expand Down Expand Up @@ -119,7 +118,7 @@ class GDCCompiler : Compiler {
settings.lflags = null;
}

if (settings.targetType == TargetType.dynamicLibrary)
if (settings.options & BuildOption.pic)
settings.addDFlags("-fPIC");

assert(fields & BuildSetting.dflags);
Expand Down
3 changes: 1 addition & 2 deletions source/dub/compilers/ldc.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import std.conv;
import std.exception;
import std.file;
import std.process;
import std.random;
import std.typecons;


Expand Down Expand Up @@ -117,7 +116,7 @@ class LDCCompiler : Compiler {
settings.lflags = null;
}

if (settings.targetType == TargetType.dynamicLibrary)
if (settings.options & BuildOption.pic)
settings.addDFlags("-relocation-model=pic");

assert(fields & BuildSetting.dflags);
Expand Down
4 changes: 4 additions & 0 deletions source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ class ProjectGenerator
main_files ~= buildsettings.mainSourceFile;
}

// set pic for dynamic library builds.
if (buildsettings.targetType == TargetType.dynamicLibrary)
buildsettings.addOptions(BuildOption.pic);

logDiagnostic("Generate target %s (%s %s %s)", pack.name, buildsettings.targetType, buildsettings.targetPath, buildsettings.targetName);
if (is_target)
targets[pack.name] = TargetInfo(pack, [pack], configs[pack.name], buildsettings, null);
Expand Down
1 change: 0 additions & 1 deletion test/1-dynLib-simple/.no_build

This file was deleted.

Empty file.
Empty file.
Empty file added test/1-dynLib-simple/.no_run
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions test/2-dynLib-with-staticLib-dep/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "dynlib-with-staticlib-dep",
"targetType": "dynamicLibrary",
"dependencies": {
"staticlib-simple": { "path": "../1-staticLib-simple/" }
}
}
8 changes: 8 additions & 0 deletions test/2-dynLib-with-staticLib-dep/source/dynlib/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module dynlib.app;
import std.stdio;
import staticlib.app;

void foo()
{
entry();
}
13 changes: 9 additions & 4 deletions test/run-unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [ -z ${DC} ]; then
DC=dmd
fi

DC_BIN=$(basename "$DC")
CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

for script in $(ls $CURR_DIR/*.sh); do
Expand All @@ -39,25 +40,29 @@ done

for pack in $(ls -d $CURR_DIR/*/); do
if [ -e $pack/.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $pack/.min_frontend) ]; then continue; fi

# First we build the packages
if [ ! -e $pack/.no_build ]; then # For sourceLibrary
if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_build_$DC_BIN ]; then # For sourceLibrary
build=1
if [ -e $pack/.fail_build ]; then
log "Building $pack, expected failure..."
$DUB build --force --root=$pack --compiler=$DC 2>/dev/null && logError "Error: Failure expected, but build passed."
else
log "Building $pack..."
$DUB build --force --root=$pack --compiler=$DC || logError "Build failure."
fi
else
build=0
fi

# We run the ones that are supposed to be ran
if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_run ]; then
# We run the ones that are supposed to be run
if [ $build -eq 1 ] && [ ! -e $pack/.no_run ] && [ ! -e $pack/.no_run_$DC_BIN ]; then
log "Running $pack..."
$DUB run --force --root=$pack --compiler=$DC || logError "Run failure."
fi

# Finally, the unittest part
if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_test ]; then
if [ $build -eq 1 ] && [ ! -e $pack/.no_test ] && [ ! -e $pack/.no_test_$DC_BIN ]; then
log "Testing $pack..."
$DUB test --force --root=$pack --compiler=$DC || logError "Test failure."
fi
Expand Down

0 comments on commit 00a52fa

Please sign in to comment.