diff --git a/.gitignore b/.gitignore index 6d0964b..6d538b9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ /test/ignore-hidden-2/ignore-hidden-2 /test/expected-import-path-output /test/expected-string-import-path-output -/test/expected-describe-data-output +/test/expected-describe-data-dmd-output +/test/expected-describe-data-list-output /test/describe-project/dummy.dat /test/describe-project/dummy-dep1.dat diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 1c103d6..3b00dd6 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -750,10 +750,13 @@ bool m_importPaths = false; bool m_stringImportPaths = false; string[] m_data; + string m_dataFormat; } this() { + m_dataFormat = m_compilerName; // Default compiler + this.name = "describe"; this.argumentsPattern = "[]"; this.description = "Prints a JSON description of the project and its dependencies"; @@ -788,11 +791,11 @@ super.prepare(args); args.getopt("import-paths", &m_importPaths, [ - "Shortcut for --data=import-paths" + "Shortcut for --data=import-paths --data-format=list" ]); args.getopt("string-import-paths", &m_stringImportPaths, [ - "Shortcut for --data=string-import-paths" + "Shortcut for --data=string-import-paths --data-format=list" ]); args.getopt("data", &m_data, [ @@ -800,6 +803,12 @@ "package alone or recursively including all dependencies. See "~ "above for more details and accepted possibilities for VALUE." ]); + + args.getopt("data-format", &m_dataFormat, [ + "Specifies the output format for --data. Possible values:", + " "~["list", "dmd", "gdc", "ldc", "gdmd", "ldmd"].join(", "), + "Default value: "~m_dataFormat, + ]); } override int execute(Dub dub, string[] free_args, string[] app_args) @@ -833,7 +842,7 @@ } else if (m_stringImportPaths) { dub.listStringImportPaths(m_buildPlatform, config, m_buildType); } else if (m_data) { - dub.listProjectData(m_buildPlatform, config, m_buildType, m_data); + dub.listProjectData(m_buildPlatform, config, m_buildType, m_data, m_dataFormat); } else { auto desc = dub.project.describe(m_buildPlatform, config, m_buildType); writeln(desc.serializeToPrettyJson()); diff --git a/source/dub/dub.d b/source/dub/dub.d index 7b7d810..ae319ce 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -439,11 +439,11 @@ } } - void listProjectData(BuildPlatform platform, string config, string buildType, string[] requestedData) + void listProjectData(BuildPlatform platform, string config, string buildType, string[] requestedData, string format) { import std.stdio; - foreach(data; m_project.listBuildSettings(platform, config, buildType, requestedData)) { + foreach(data; m_project.listBuildSettings(platform, config, buildType, requestedData, format)) { writeln(data); } } diff --git a/source/dub/project.d b/source/dub/project.d index 79f91e2..9be594f 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -620,12 +620,119 @@ dst[key] = value; } - private string[] listBuildSetting(string attributeName)(BuildPlatform platform, string config, ProjectDescription projectDescription) + private string[] listBuildSetting(string attributeName)(BuildPlatform platform, string config, ProjectDescription projectDescription, Compiler compiler) { - return listBuildSetting!attributeName(platform, getPackageConfigs(platform, config), projectDescription); + return listBuildSetting!attributeName(platform, getPackageConfigs(platform, config), projectDescription, compiler); } - private string[] listBuildSetting(string attributeName)(BuildPlatform platform, string[string] configs, ProjectDescription projectDescription) + private string[] listBuildSetting(string attributeName)(BuildPlatform platform, string[string] configs, ProjectDescription projectDescription, Compiler compiler) + { + if (compiler) + return formatBuildSettingCompiler!attributeName(platform, configs, projectDescription, compiler); + else + return formatBuildSettingPlain!attributeName(platform, configs, projectDescription); + } + + // Output a build setting formatted for a compiler + private string[] formatBuildSettingCompiler(string attributeName)(BuildPlatform platform, string[string] configs, ProjectDescription projectDescription, Compiler compiler) + { + import std.process : escapeShellFileName; + import std.path : dirSeparator; + + assert(compiler); + + static BuildSetting getBuildSettingBitField(string requestedData) + { + switch (requestedData) + { + case "dflags": return BuildSetting.dflags; + case "lflags": return BuildSetting.lflags; + case "libs": return BuildSetting.libs; + case "sourceFiles": return BuildSetting.sourceFiles; + case "copyFiles": return BuildSetting.copyFiles; + case "versions": return BuildSetting.versions; + case "debugVersions": return BuildSetting.debugVersions; + case "importPaths": return BuildSetting.importPaths; + case "stringImportPaths": return BuildSetting.stringImportPaths; + case "options": return BuildSetting.options; + default: assert(0); + } + } + + auto targetDescription = projectDescription.targetLookup[projectDescription.rootPackage]; + auto buildSettings = targetDescription.buildSettings; + + string[] values; + switch (attributeName) + { + case "dflags": + case "mainSourceFile": + case "libFiles": + case "importFiles": + values = formatBuildSettingPlain!attributeName(platform, configs, projectDescription); + break; + + case "lflags": + case "sourceFiles": + case "versions": + case "debugVersions": + case "importPaths": + case "stringImportPaths": + case "options": + auto bs = buildSettings.dup; + bs.dflags = null; + + // Ensure trailing slash on directory paths + auto ensureTrailingSlash = (string path) => path.endsWith(dirSeparator) ? path : path ~ dirSeparator; + static if (attributeName == "importPaths") + bs.importPaths = bs.importPaths.map!(ensureTrailingSlash).array(); + else static if (attributeName == "stringImportPaths") + bs.stringImportPaths = bs.stringImportPaths.map!(ensureTrailingSlash).array(); + + compiler.prepareBuildSettings(bs, BuildSetting.all & ~getBuildSettingBitField(attributeName)); + values = bs.dflags; + break; + + case "libs": + auto bs = buildSettings.dup; + bs.dflags = null; + bs.lflags = null; + bs.sourceFiles = null; + + compiler.prepareBuildSettings(bs, BuildSetting.all & ~getBuildSettingBitField(attributeName)); + + if (bs.lflags) + values = bs.lflags; + else if (bs.sourceFiles) + values = bs.sourceFiles; + else + values = bs.dflags; + + break; + + default: assert(0); + } + + // Escape filenames and paths + switch (attributeName) + { + case "mainSourceFile": + case "libFiles": + case "copyFiles": + case "importFiles": + case "stringImportFiles": + case "sourceFiles": + case "importPaths": + case "stringImportPaths": + return values.map!(escapeShellFileName).array(); + + default: + return values; + } + } + + // Output a build setting without formatting for any particular compiler + private string[] formatBuildSettingPlain(string attributeName)(BuildPlatform platform, string[string] configs, ProjectDescription projectDescription) { import std.path : buildPath, dirSeparator; import std.range : only; @@ -715,33 +822,62 @@ return list; } - private string[] listBuildSetting(BuildPlatform platform, string[string] configs, ProjectDescription projectDescription, string requestedData) + // The "compiler" arg is for choosing which compiler the output should be formatted for, + // or null to imply "list" format. + private string[] listBuildSetting(BuildPlatform platform, string[string] configs, + ProjectDescription projectDescription, string requestedData, Compiler compiler) { - switch(requestedData) + // Certain data cannot be formatter for a compiler + if (compiler) { - case "target-type": return listBuildSetting!"targetType"(platform, configs, projectDescription); - case "target-path": return listBuildSetting!"targetPath"(platform, configs, projectDescription); - case "target-name": return listBuildSetting!"targetName"(platform, configs, projectDescription); - case "working-directory": return listBuildSetting!"workingDirectory"(platform, configs, projectDescription); - case "main-source-file": return listBuildSetting!"mainSourceFile"(platform, configs, projectDescription); - case "dflags": return listBuildSetting!"dflags"(platform, configs, projectDescription); - case "lflags": return listBuildSetting!"lflags"(platform, configs, projectDescription); - case "libs": return listBuildSetting!"libs"(platform, configs, projectDescription); - case "lib-files": return listBuildSetting!"libFiles"(platform, configs, projectDescription); - case "source-files": return listBuildSetting!"sourceFiles"(platform, configs, projectDescription); - case "copy-files": return listBuildSetting!"copyFiles"(platform, configs, projectDescription); - case "versions": return listBuildSetting!"versions"(platform, configs, projectDescription); - case "debug-versions": return listBuildSetting!"debugVersions"(platform, configs, projectDescription); - case "import-paths": return listBuildSetting!"importPaths"(platform, configs, projectDescription); - case "string-import-paths": return listBuildSetting!"stringImportPaths"(platform, configs, projectDescription); - case "import-files": return listBuildSetting!"importFiles"(platform, configs, projectDescription); - case "string-import-files": return listBuildSetting!"stringImportFiles"(platform, configs, projectDescription); - case "pre-generate-commands": return listBuildSetting!"preGenerateCommands"(platform, configs, projectDescription); - case "post-generate-commands": return listBuildSetting!"postGenerateCommands"(platform, configs, projectDescription); - case "pre-build-commands": return listBuildSetting!"preBuildCommands"(platform, configs, projectDescription); - case "post-build-commands": return listBuildSetting!"postBuildCommands"(platform, configs, projectDescription); - case "requirements": return listBuildSetting!"requirements"(platform, configs, projectDescription); - case "options": return listBuildSetting!"options"(platform, configs, projectDescription); + switch (requestedData) + { + case "target-type": + case "target-path": + case "target-name": + case "working-directory": + case "string-import-files": + case "copy-files": + case "pre-generate-commands": + case "post-generate-commands": + case "pre-build-commands": + case "post-build-commands": + enforce(false, "--data="~requestedData~" can only be used with --data-format=list."); + break; + + case "requirements": + enforce(false, "--data=requirements can only be used with --data-format=list. Use --data=options instead."); + break; + + default: break; + } + } + + switch (requestedData) + { + case "target-type": return listBuildSetting!"targetType"(platform, configs, projectDescription, compiler); + case "target-path": return listBuildSetting!"targetPath"(platform, configs, projectDescription, compiler); + case "target-name": return listBuildSetting!"targetName"(platform, configs, projectDescription, compiler); + case "working-directory": return listBuildSetting!"workingDirectory"(platform, configs, projectDescription, compiler); + case "main-source-file": return listBuildSetting!"mainSourceFile"(platform, configs, projectDescription, compiler); + case "dflags": return listBuildSetting!"dflags"(platform, configs, projectDescription, compiler); + case "lflags": return listBuildSetting!"lflags"(platform, configs, projectDescription, compiler); + case "libs": return listBuildSetting!"libs"(platform, configs, projectDescription, compiler); + case "lib-files": return listBuildSetting!"libFiles"(platform, configs, projectDescription, compiler); + case "source-files": return listBuildSetting!"sourceFiles"(platform, configs, projectDescription, compiler); + case "copy-files": return listBuildSetting!"copyFiles"(platform, configs, projectDescription, compiler); + case "versions": return listBuildSetting!"versions"(platform, configs, projectDescription, compiler); + case "debug-versions": return listBuildSetting!"debugVersions"(platform, configs, projectDescription, compiler); + case "import-paths": return listBuildSetting!"importPaths"(platform, configs, projectDescription, compiler); + case "string-import-paths": return listBuildSetting!"stringImportPaths"(platform, configs, projectDescription, compiler); + case "import-files": return listBuildSetting!"importFiles"(platform, configs, projectDescription, compiler); + case "string-import-files": return listBuildSetting!"stringImportFiles"(platform, configs, projectDescription, compiler); + case "pre-generate-commands": return listBuildSetting!"preGenerateCommands"(platform, configs, projectDescription, compiler); + case "post-generate-commands": return listBuildSetting!"postGenerateCommands"(platform, configs, projectDescription, compiler); + case "pre-build-commands": return listBuildSetting!"preBuildCommands"(platform, configs, projectDescription, compiler); + case "post-build-commands": return listBuildSetting!"postBuildCommands"(platform, configs, projectDescription, compiler); + case "requirements": return listBuildSetting!"requirements"(platform, configs, projectDescription, compiler); + case "options": return listBuildSetting!"options"(platform, configs, projectDescription, compiler); default: enforce(false, "--data="~requestedData~ @@ -752,7 +888,7 @@ } /// Outputs requested data for the project, optionally including its dependencies. - string[] listBuildSettings(BuildPlatform platform, string config, string buildType, string[] requestedData) + string[] listBuildSettings(BuildPlatform platform, string config, string buildType, string[] requestedData, string format) { auto projectDescription = describe(platform, config, buildType); auto configs = getPackageConfigs(platform, config); @@ -777,24 +913,43 @@ } } - return requestedData - .map!(dataName => listBuildSetting(platform, configs, projectDescription, dataName)) - .joiner([""]) // Blank line between each type of requestedData - .array(); + // Genrate results + if (format == "list") + { + return requestedData + .map!(dataName => listBuildSetting(platform, configs, projectDescription, dataName, null)) + .joiner([""]) // Blank line between each type of requestedData + .array(); + } + else + { + Compiler compiler; + try + compiler = getCompiler(format); + catch + enforce(false, "--data-format="~format~ + " is not a valid option. See 'dub describe --help' for accepted --data-format= values."); + + return [ + requestedData + .map!(dataName => listBuildSetting(platform, configs, projectDescription, dataName, compiler)) + .join().join(" ") + ]; + } } /// Outputs the import paths for the project, including its dependencies. string[] listImportPaths(BuildPlatform platform, string config, string buildType) { auto projectDescription = describe(platform, config, buildType); - return listBuildSetting!"importPaths"(platform, config, projectDescription); + return listBuildSetting!"importPaths"(platform, config, projectDescription, null); } /// Outputs the string import paths for the project, including its dependencies. string[] listStringImportPaths(BuildPlatform platform, string config, string buildType) { auto projectDescription = describe(platform, config, buildType); - return listBuildSetting!"stringImportPaths"(platform, config, projectDescription); + return listBuildSetting!"stringImportPaths"(platform, config, projectDescription, null); } void saveSelections() diff --git a/test/4-describe-data-dmd.sh b/test/4-describe-data-dmd.sh new file mode 100755 index 0000000..00b9c18 --- /dev/null +++ b/test/4-describe-data-dmd.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +set -e -o pipefail + +cd "$CURR_DIR"/describe-project + +temp_file=`mktemp` + +function cleanup { + rm $temp_file +} + +trap cleanup EXIT + +if ! $DUB describe --compiler=$COMPILER --data-format=dmd \ + --data=main-source-file \ + --data=dflags \ + --data=lflags \ + --data=libs \ + --data=lib-files \ + --data=source-files \ + --data=versions \ + --data=debug-versions \ + --data=import-paths \ + --data=string-import-paths \ + --data=import-files \ + --data=options \ + > "$temp_file"; then + die 'Printing project data failed!' +fi + +# Create the expected output path file to compare against. +expected_file="$CURR_DIR/expected-describe-data-dmd-output" +# --data=main-source-file +echo -n "'$CURR_DIR/describe-project/src/dummy.d' " > "$expected_file" +# --data=dflags +echo -n "--some-dflag " >> "$expected_file" +echo -n "--another-dflag " >> "$expected_file" +# --data=lflags +echo -n "-L--some-lflag " >> "$expected_file" +echo -n "-L--another-lflag " >> "$expected_file" +# --data=libs +echo -n "-lssl " >> "$expected_file" +echo -n "-lcrypto " >> "$expected_file" +echo -n "-lcurl " >> "$expected_file" +# --data=lib-files +echo -n "'$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a' " >> "$expected_file" +# --data=source-files +echo -n "'$CURR_DIR/describe-project/src/dummy.d' " >> "$expected_file" +echo -n "'$CURR_DIR/describe-dependency-1/source/dummy.d' " >> "$expected_file" +# --data=versions +echo -n "-version=someVerIdent " >> "$expected_file" +echo -n "-version=anotherVerIdent " >> "$expected_file" +echo -n "-version=Have_describe_project " >> "$expected_file" +echo -n "-version=Have_describe_dependency_1 " >> "$expected_file" +echo -n "-version=Have_describe_dependency_2 " >> "$expected_file" +echo -n "-version=Have_describe_dependency_3 " >> "$expected_file" +# --data=debug-versions +echo -n "-debug=someDebugVerIdent " >> "$expected_file" +echo -n "-debug=anotherDebugVerIdent " >> "$expected_file" +# --data=import-paths +echo -n "'-I$CURR_DIR/describe-project/src/' " >> "$expected_file" +echo -n "'-I$CURR_DIR/describe-dependency-1/source/' " >> "$expected_file" +echo -n "'-I$CURR_DIR/describe-dependency-2/some-path/' " >> "$expected_file" +echo -n "'-I$CURR_DIR/describe-dependency-3/dep3-source/' " >> "$expected_file" +# --data=string-import-paths +echo -n "'-J$CURR_DIR/describe-project/views/' " >> "$expected_file" +echo -n "'-J$CURR_DIR/describe-dependency-2/some-extra-string-import-path/' " >> "$expected_file" +echo -n "'-J$CURR_DIR/describe-dependency-3/dep3-string-import-path/' " >> "$expected_file" +# --data=import-files +echo -n "'$CURR_DIR/describe-dependency-2/some-path/dummy.d' " >> "$expected_file" +# --data=options +echo -n "-debug " >> "$expected_file" +echo -n "-release " >> "$expected_file" +echo -n "-g " >> "$expected_file" +echo -n "-wi" >> "$expected_file" +#echo -n "-gx " >> "$expected_file" # Not sure if this (from a sourceLib dependency) should be missing from the result +echo "" >> "$expected_file" + +if ! diff "$expected_file" "$temp_file"; then + die 'The project data did not match the expected output!' +fi + diff --git a/test/4-describe-data-list.sh b/test/4-describe-data-list.sh new file mode 100755 index 0000000..36c689b --- /dev/null +++ b/test/4-describe-data-list.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +set -e -o pipefail + +cd "$CURR_DIR"/describe-project + +temp_file=`mktemp` + +function cleanup { + rm $temp_file +} + +trap cleanup EXIT + +if ! $DUB describe --compiler=$COMPILER --data-format=list \ + --data=target-type \ + --data=target-path \ + --data=target-name \ + --data=working-directory \ + --data=main-source-file \ + --data=dflags \ + --data=lflags \ + --data=libs \ + --data=lib-files \ + --data=source-files \ + --data=copy-files \ + --data=versions \ + --data=debug-versions \ + --data=import-paths \ + --data=string-import-paths \ + --data=import-files \ + --data=string-import-files \ + --data=pre-generate-commands \ + --data=post-generate-commands \ + --data=pre-build-commands \ + --data=post-build-commands \ + --data=requirements \ + --data=options \ + > "$temp_file"; then + die 'Printing project data failed!' +fi + +# Create the expected output path file to compare against. +expected_file="$CURR_DIR/expected-describe-data-output" +# --data=target-type +echo "executable" > "$expected_file" +echo >> "$expected_file" +# --data=target-path +echo "$CURR_DIR/describe-project/" >> "$expected_file" +echo >> "$expected_file" +# --data=target-name +echo "describe-project" >> "$expected_file" +echo >> "$expected_file" +# --data=working-directory +echo "$CURR_DIR/describe-project/" >> "$expected_file" +echo >> "$expected_file" +# --data=main-source-file +echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" +echo >> "$expected_file" +# --data=dflags +echo "--some-dflag" >> "$expected_file" +echo "--another-dflag" >> "$expected_file" +echo >> "$expected_file" +# --data=lflags +echo "--some-lflag" >> "$expected_file" +echo "--another-lflag" >> "$expected_file" +echo >> "$expected_file" +# --data=libs +echo "ssl" >> "$expected_file" +echo "curl" >> "$expected_file" +echo >> "$expected_file" +# --data=lib-files +echo "$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a" >> "$expected_file" +echo >> "$expected_file" +# --data=source-files +echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-1/source/dummy.d" >> "$expected_file" +echo >> "$expected_file" +# --data=copy-files +echo "$CURR_DIR/describe-project/data/dummy.dat" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-1/data/*" >> "$expected_file" +echo >> "$expected_file" +# --data=versions +echo "someVerIdent" >> "$expected_file" +echo "anotherVerIdent" >> "$expected_file" +echo "Have_describe_project" >> "$expected_file" +echo "Have_describe_dependency_1" >> "$expected_file" +echo "Have_describe_dependency_2" >> "$expected_file" +echo "Have_describe_dependency_3" >> "$expected_file" +echo >> "$expected_file" +# --data=debug-versions +echo "someDebugVerIdent" >> "$expected_file" +echo "anotherDebugVerIdent" >> "$expected_file" +echo >> "$expected_file" +# --data=import-paths +echo "$CURR_DIR/describe-project/src/" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-1/source/" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-2/some-path/" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-3/dep3-source/" >> "$expected_file" +echo >> "$expected_file" +# --data=string-import-paths +echo "$CURR_DIR/describe-project/views/" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/" >> "$expected_file" +echo "$CURR_DIR/describe-dependency-3/dep3-string-import-path/" >> "$expected_file" +echo >> "$expected_file" +# --data=import-files +echo "$CURR_DIR/describe-dependency-2/some-path/dummy.d" >> "$expected_file" +echo >> "$expected_file" +# --data=string-import-files +echo "$CURR_DIR/describe-project/views/dummy.d" >> "$expected_file" +#echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/dummy.d" >> "$expected_file" # This is missing from result, is that a bug? +echo >> "$expected_file" +# --data=pre-generate-commands +echo "./do-preGenerateCommands.sh" >> "$expected_file" +echo "../describe-dependency-1/dependency-preGenerateCommands.sh" >> "$expected_file" +echo >> "$expected_file" +# --data=post-generate-commands +echo "./do-postGenerateCommands.sh" >> "$expected_file" +echo "../describe-dependency-1/dependency-postGenerateCommands.sh" >> "$expected_file" +echo >> "$expected_file" +# --data=pre-build-commands +echo "./do-preBuildCommands.sh" >> "$expected_file" +echo "../describe-dependency-1/dependency-preBuildCommands.sh" >> "$expected_file" +echo >> "$expected_file" +# --data=post-build-commands +echo "./do-postBuildCommands.sh" >> "$expected_file" +echo "../describe-dependency-1/dependency-postBuildCommands.sh" >> "$expected_file" +echo >> "$expected_file" +# --data=requirements +echo "allowWarnings" >> "$expected_file" +echo "disallowInlining" >> "$expected_file" +#echo "requireContracts" >> "$expected_file" # Not sure if this (from a sourceLib dependency) should be missing from the result +echo >> "$expected_file" +# --data=options +echo "debugMode" >> "$expected_file" +echo "releaseMode" >> "$expected_file" +echo "debugInfo" >> "$expected_file" +echo "warnings" >> "$expected_file" +#echo "stackStomping" >> "$expected_file" # Not sure if this (from a sourceLib dependency) should be missing from the result + +if ! diff "$expected_file" "$temp_file"; then + die 'The project data did not match the expected output!' +fi + diff --git a/test/4-describe-data.sh b/test/4-describe-data.sh deleted file mode 100755 index 117f4d0..0000000 --- a/test/4-describe-data.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash - -set -e -o pipefail - -cd "$CURR_DIR"/describe-project - -temp_file=`mktemp` - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$COMPILER \ - --data=target-type \ - --data=target-path \ - --data=target-name \ - --data=working-directory \ - --data=main-source-file \ - --data=dflags \ - --data=lflags \ - --data=libs \ - --data=lib-files \ - --data=source-files \ - --data=copy-files \ - --data=versions \ - --data=debug-versions \ - --data=import-paths \ - --data=string-import-paths \ - --data=import-files \ - --data=string-import-files \ - --data=pre-generate-commands \ - --data=post-generate-commands \ - --data=pre-build-commands \ - --data=post-build-commands \ - --data=requirements \ - --data=options \ - > "$temp_file"; then - die 'Printing project data failed!' -fi - -# Create the expected output path file to compare against. -expected_file="$CURR_DIR/expected-describe-data-output" -# --data=target-type -echo "executable" > "$expected_file" -echo >> "$expected_file" -# --data=target-path -echo "$CURR_DIR/describe-project/" >> "$expected_file" -echo >> "$expected_file" -# --data=target-name -echo "describe-project" >> "$expected_file" -echo >> "$expected_file" -# --data=working-directory -echo "$CURR_DIR/describe-project/" >> "$expected_file" -echo >> "$expected_file" -# --data=main-source-file -echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=dflags -echo "--some-dflag" >> "$expected_file" -echo "--another-dflag" >> "$expected_file" -echo >> "$expected_file" -# --data=lflags -echo "--some-lflag" >> "$expected_file" -echo "--another-lflag" >> "$expected_file" -echo >> "$expected_file" -# --data=libs -echo "ssl" >> "$expected_file" -echo "curl" >> "$expected_file" -echo >> "$expected_file" -# --data=lib-files -echo "$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a" >> "$expected_file" -echo >> "$expected_file" -# --data=source-files -echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/source/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=copy-files -echo "$CURR_DIR/describe-project/data/dummy.dat" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/data/*" >> "$expected_file" -echo >> "$expected_file" -# --data=versions -echo "someVerIdent" >> "$expected_file" -echo "anotherVerIdent" >> "$expected_file" -echo "Have_describe_project" >> "$expected_file" -echo "Have_describe_dependency_1" >> "$expected_file" -echo "Have_describe_dependency_2" >> "$expected_file" -echo "Have_describe_dependency_3" >> "$expected_file" -echo >> "$expected_file" -# --data=debug-versions -echo "someDebugVerIdent" >> "$expected_file" -echo "anotherDebugVerIdent" >> "$expected_file" -echo >> "$expected_file" -# --data=import-paths -echo "$CURR_DIR/describe-project/src/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/source/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-2/some-path/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-3/dep3-source/" >> "$expected_file" -echo >> "$expected_file" -# --data=string-import-paths -echo "$CURR_DIR/describe-project/views/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-3/dep3-string-import-path/" >> "$expected_file" -echo >> "$expected_file" -# --data=import-files -echo "$CURR_DIR/describe-dependency-2/some-path/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=string-import-files -echo "$CURR_DIR/describe-project/views/dummy.d" >> "$expected_file" -#echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/dummy.d" >> "$expected_file" # This is missing from result, is that a bug? -echo >> "$expected_file" -# --data=pre-generate-commands -echo "./do-preGenerateCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-preGenerateCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=post-generate-commands -echo "./do-postGenerateCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-postGenerateCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=pre-build-commands -echo "./do-preBuildCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-preBuildCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=post-build-commands -echo "./do-postBuildCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-postBuildCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=requirements -echo "allowWarnings" >> "$expected_file" -echo "disallowInlining" >> "$expected_file" -#echo "requireContracts" >> "$expected_file" # Not sure if this (from a sourceLib dependency) should be missing from the result -echo >> "$expected_file" -# --data=options -echo "debugMode" >> "$expected_file" -echo "releaseMode" >> "$expected_file" -echo "debugInfo" >> "$expected_file" -echo "warnings" >> "$expected_file" -#echo "stackStomping" >> "$expected_file" # Not sure if this (from a sourceLib dependency) should be missing from the result - -if ! diff "$expected_file" "$temp_file"; then - die 'The project data did not match the expected output!' -fi -