diff --git a/bin/dub b/bin/dub deleted file mode 100755 index 38cdf79..0000000 --- a/bin/dub +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -set -e - -# delete old dub.d if another run left it in /tmp -rm -f /tmp/app.d - -# find the executable location (note: must stay mac compatible here) -DUB_BINARY=$(readlink "$0" || true) -if [ ! -n "$DUB_BINARY" ]; then DUB_BINARY="$0"; fi -DUB_BIN=$(dirname "$DUB_BINARY") -DUB_SOURCE=$DUB_BIN/../source -VIBE_SOURCE=$DUB_SOURCE/../../vibe.d/source - -# use pkg-config if possible or fallback to default flags -LIBS=$(pkg-config --libs libevent libevent_pthreads libssl 2>/dev/null || echo "-levent_pthreads -levent -lssl -lcrypto") -LIBS=$(echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g') -export LIBS - -# generate a file name for the temporary compile/run script -START_SCRIPT=`mktemp -t dub.start.XXXXXXXX` - -# copy dub.d to /tmp and make it deletable by anyone -cp -p "$DUB_SOURCE"/app.d /tmp/app.d -chmod 666 /tmp/app.d - -# run VPM and delete the dub.d file again, VPM will output the compile/run script -rdmd -g -w -property -I"$DUB_SOURCE" -I"$VIBE_SOURCE" $LIBS -Jviews -Isource /tmp/app.d "$VIBE_SOURCE" "$START_SCRIPT" $1 $2 $3 $4 $5 $6 $7 $8 $9 -rm /tmp/app.d - -# compile/run the application -chmod +x "$START_SCRIPT" -"$START_SCRIPT" -rm "$START_SCRIPT" diff --git a/bin/dub.cmd b/bin/dub.cmd deleted file mode 100644 index 0146cca..0000000 --- a/bin/dub.cmd +++ /dev/null @@ -1,22 +0,0 @@ -@echo off -set DUB_BIN=%~dps0 -set DUB_SOURCE=%DUB_BIN%..\source -set VIBE_SOURCE=%DUB_BIN%..\..\vibe.d\source -set LIBDIR=%VIBE_SOURCE%\..\lib\win-i386 -set BINDIR=%DUB_BIN%..\lib\bin -set LIBS="%LIBDIR%\event2.lib" "%LIBDIR%\eay.lib" "%LIBDIR%\ssl.lib" ws2_32.lib -set EXEDIR=%TEMP%\.rdmd\source -set START_SCRIPT=%EXEDIR%\vibe.cmd - -if NOT EXIST %EXEDIR% ( - mkdir %EXEDIR% -) -copy "%DUB_BIN%*.dll" %EXEDIR% > nul 2>&1 -if "%1" == "build" copy "%DUB_BIN%*.dll" . > nul 2>&1 -copy "%DUB_SOURCE%\app.d" %EXEDIR% > nul 2>&1 - -rem Run, execute, do everything.. -rdmd -debug -g -w -property -of%EXEDIR%\dub.exe -I%DUB_SOURCE% -I%VIBE_SOURCE% %LIBS% %EXEDIR%\app.d %VIBE_SOURCE% %START_SCRIPT% %* - -rem Finally, start the app, if dub succeded. -if ERRORLEVEL 0 %START_SCRIPT% diff --git a/source/app.d b/source/app.d index 2980230..2cf3fd4 100644 --- a/source/app.d +++ b/source/app.d @@ -21,7 +21,7 @@ import std.exception; import std.file; import std.getopt; -import std.process; +import stdx.process; int main(string[] args) @@ -29,13 +29,6 @@ string cmd; try { - if( args.length < 3 ){ - logError("Usage: %s [] [args...] [-- [applicatio args]]\n", args[0]); - // vibe-binary-path: the installation folder of the vibe installation - // start-script-output-file: destination of the script, which can be used to run the app - return 1; - } - // parse general options bool verbose, vverbose, quiet, vquiet; bool help, nodeps, annotate; @@ -57,20 +50,11 @@ setLogLevel(loglevel); if( loglevel >= LogLevel.Info ) setPlainLogging(true); - - // extract the destination paths - enforce(isDir(args[1]), "Specified binary path is not a directory."); - Path vibedDir = Path(args[1]); - Path dstScript = Path(args[2]); - // extract the command - if( args.length > 3 && !args[3].startsWith("-") ){ - cmd = args[3]; - args = args[0] ~ args[4 .. $]; - } else { - cmd = "run"; - args = args[0] ~ args[3 .. $]; - } + if( args.length > 1 && !args[1].startsWith("-") ){ + cmd = args[1]; + args = args[0] ~ args[2 .. $]; + } else cmd = "run"; // contrary to the documentation, getopt does not remove -- if( args.length >= 2 && args[1] == "--" ) args = args[0] ~ args[2 .. $]; @@ -83,7 +67,6 @@ auto appPath = getcwd(); string del_exe_file; - string appStartScript; Url registryUrl = Url.parse("http://registry.vibed.org/"); logDebug("Using vpm registry url '%s'", registryUrl); @@ -129,17 +112,16 @@ } } flags ~= "-g"; - flags ~= "-I" ~ (vibedDir ~ ".." ~ "source").toNativeString(); - flags ~= "-Isource"; - flags ~= "-Jviews"; flags ~= vpm.dflags; - flags ~= getLibs(vibedDir); flags ~= getPackagesAsVersion(vpm); flags ~= (mainsrc).toNativeString(); flags ~= args[1 .. $]; - appStartScript = "rdmd " ~ getDflags() ~ " " ~ join(flags, " "); - if( del_exe_file.length ) appStartScript ~= "\r\ndel \""~del_exe_file~"\""; + logInfo("Running %s", "rdmd " ~ getDflags() ~ " " ~ join(flags, " ")); + auto rdmd_pid = spawnProcess("rdmd " ~ getDflags() ~ " " ~ join(flags, " ")); + rdmd_pid.wait(); + + if( del_exe_file.length ) remove(del_exe_file); break; case "upgrade": logInfo("Upgrading application in '%s'", appPath); @@ -149,10 +131,6 @@ break; } - auto script = openFile(to!string(dstScript), FileMode.CreateTrunc); - scope(exit) script.close(); - script.write(appStartScript); - return 0; } catch(Throwable e) @@ -201,22 +179,6 @@ return globVibedDflags; } -private string[] getLibs(Path vibedDir) -{ - version(Windows) - { - auto libDir = vibedDir ~ "..\\lib\\win-i386"; - return ["ws2_32.lib", - (libDir ~ "event2.lib").toNativeString(), - (libDir ~ "eay.lib").toNativeString(), - (libDir ~ "ssl.lib").toNativeString()]; - } - version(Posix) - { - return split(environment.get("LIBS", "-L-levent_openssl -L-levent")); - } -} - private string stripDlangSpecialChars(string s) { char[] ret = s.dup; diff --git a/source/dub/dub.d b/source/dub/dub.d index e5e7dc3..37bb60c 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -518,7 +518,7 @@ Path getPrefix(ZipArchive a) { foreach(ArchiveMember am; a.directory) if( Path(am.name).head == PathEntry("package.json") ) - return Path(am.name).parentPath; + return Path(am.name)[0 .. 1]; // not correct zip packages HACK Path minPath; @@ -533,6 +533,7 @@ // In a github zip, the actual contents are in a subfolder auto prefixInPackage = getPrefix(archive); + logDebug("zip root folder: %s", prefixInPackage); Path getCleanedPath(string fileName) { auto path = Path(fileName); @@ -575,6 +576,12 @@ journal.add(Journal.Entry(Journal.Type.RegularFile, cleanedPath)); } + { // write package.json (this one includes a version field) + auto pj = openFile(to!string(destination~"package.json"), FileMode.CreateTrunc); + scope(exit) pj.close(); + pj.write(m_packageSupplier.packageJson(packageId, dep).toString()); + } + // Write journal logTrace("Saving installation journal..."); journal.add(Journal.Entry(Journal.Type.RegularFile, Path("journal.json")));