summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-10-25 11:24:16 -0400
committerGitHub <noreply@github.com>2018-10-25 11:24:16 -0400
commit4f0415e338862ffec50c2d47eddea958255b504e (patch)
tree084c8e25552e328ed14eafcf0431493f58f973e8 /tools
parent2700a89f8c80620f1d523563cc80ec0da39e9761 (diff)
Feature/premake linux (#689)
* Premake work in progress for linux. * Added dump function. * Remove examples on linux Small warning fix. * * Don't build render-test on linux * Removed work around virtual destructor warning, and just used virtual dtor for simplicity * Git ignore obj directories * Fix premake working on windows. * * Fix sprintf_s functions * Make generates arg parsing more robust * Added FloatIntUnion to avoid type punning/strong aliasing issues, and repeated union definitions. * Work around problems building on linux with getClass claiming a strict aliasing issue. * Fix for targetBlock appearing potentiall used unintialized to gcc. * Linux slang link options -fPIC to make dll. * Add -fPIC to build options on linux. * Add -ldl for linux on slang. * Fixes to try and get premake working with .so on linux. * Make core compile with -fPIC * Try to fix linux linking with --no-as-needed before -ldl * Add rpath back. * Remove render-gl from linux build. * Re-add location for linux. * Don't include <malloc.h> except on windows. * Remove unused line to fix warning on osx. * Remove ambiguity on OSX for operator <<. * Fixing ambiguity with operator overloading and Int types for OSX. * Fix ambiguity around UInt and operator * Fix ambiguity of UInt conversion for OSX. * Added UnambiguousInt and UnambiguousUInt to make it easier to work around OSX integer coercion for UInt/Int types.
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/model.cpp7
-rw-r--r--tools/gfx/model.h1
-rw-r--r--tools/gfx/render.h6
-rw-r--r--tools/gfx/window.cpp1
-rw-r--r--tools/gfx/window.h4
-rw-r--r--tools/render-test/options.cpp2
-rw-r--r--tools/slang-generate/main.cpp79
-rw-r--r--tools/slang-test/main.cpp2
8 files changed, 57 insertions, 45 deletions
diff --git a/tools/gfx/model.cpp b/tools/gfx/model.cpp
index 62e6ec1fd..ce176727b 100644
--- a/tools/gfx/model.cpp
+++ b/tools/gfx/model.cpp
@@ -195,6 +195,11 @@ RefPtr<TextureResource> loadTextureImage(
return texture;
}
+static std::string makeString(const char* start, const char* end)
+{
+ return std::string(start, size_t(end - start));
+}
+
Result ModelLoader::load(
char const* inputPath,
void** outModel)
@@ -208,7 +213,7 @@ Result ModelLoader::load(
std::string baseDir;
if( auto lastSlash = strrchr(inputPath, '/') )
{
- baseDir = std::string(inputPath, lastSlash);
+ baseDir = makeString(inputPath, lastSlash);
}
std::string diagnostics;
diff --git a/tools/gfx/model.h b/tools/gfx/model.h
index b92dfda76..17b16510e 100644
--- a/tools/gfx/model.h
+++ b/tools/gfx/model.h
@@ -5,6 +5,7 @@
#include "vector-math.h"
#include <vector>
+#include <string>
namespace gfx {
diff --git a/tools/gfx/render.h b/tools/gfx/render.h
index f59a5ef9f..bfbe0f82a 100644
--- a/tools/gfx/render.h
+++ b/tools/gfx/render.h
@@ -5,6 +5,8 @@
//#include "shader-input-layout.h"
+#include <float.h>
+
#include "../../slang-com-helper.h"
#include "../../source/core/smart-pointer.h"
@@ -424,6 +426,10 @@ class TextureResource: public Resource
Desc m_desc;
};
+// Needed for building on cygwin with gcc
+#undef Always
+#undef None
+
enum class ComparisonFunc : uint8_t
{
Never = 0,
diff --git a/tools/gfx/window.cpp b/tools/gfx/window.cpp
index 8456e1ead..9e2195141 100644
--- a/tools/gfx/window.cpp
+++ b/tools/gfx/window.cpp
@@ -1,6 +1,5 @@
// window.cpp
#include "window.h"
-#pragma once
#include <stdio.h>
diff --git a/tools/gfx/window.h b/tools/gfx/window.h
index e154acec3..e6f886f42 100644
--- a/tools/gfx/window.h
+++ b/tools/gfx/window.h
@@ -5,7 +5,7 @@
namespace gfx {
-typedef struct Window Window;
+struct Window;
enum class KeyCode
{
@@ -94,7 +94,7 @@ int runApplication(
#define GFX_CONSOLE_MAIN(APPLICATION_ENTRY) \
int main(int argc, char** argv) { \
- return gfx::runApplication(&(APPLIATION_ENTRY), argc, argv); \
+ return gfx::runApplication(&(APPLICATION_ENTRY), argc, argv); \
}
#ifdef _WIN32
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index 54aa3c429..ec0bc0844 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -147,7 +147,7 @@ SlangResult parseOptions(int* argc, char** argv)
}
// any arguments left over were positional arguments
- argCount = (int)(writeCursor - argv);
+ argCount = (int)(writeCursor - (const char**)argv);
argCursor = argv;
argEnd = argCursor + argCount;
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index 6b51f0e47..78097d1f1 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -625,28 +625,35 @@ void usage(char const* appName)
fprintf(stderr, "usage: %s <input>\n", appName);
}
-char* readAllText(char const * fileName)
+SlangResult readAllText(char const * fileName, String& stringOut)
{
FILE * f;
fopen_s(&f, fileName, "rb");
if (!f)
{
- return "";
+ stringOut = "";
+ return SLANG_FAIL;
}
else
{
+ stringOut =
fseek(f, 0, SEEK_END);
auto size = ftell(f);
- char * buffer = new char[size + 1];
- memset(buffer, 0, size + 1);
+
+ StringRepresentation* stringRep = StringRepresentation::createWithCapacityAndLength(size, size);
+ stringOut = String(stringRep);
+
+ char * buffer = stringRep->getData();
+ memset(buffer, 0, size);
fseek(f, 0, SEEK_SET);
fread(buffer, sizeof(char), size, f);
fclose(f);
- return buffer;
+
+ return SLANG_OK;
}
}
-void writeAllText(char const *srcFileName, char const* fileName, char* content)
+void writeAllText(char const *srcFileName, char const* fileName, const char* content)
{
FILE * f = nullptr;
fopen_s(&f, fileName, "wb");
@@ -751,34 +758,28 @@ List<SourceFile*> gSourceFiles;
int main(
int argc,
- char** argv)
+ const char*const* argv)
{
// Parse command-line arguments.
- char** argCursor = argv;
- char** argEnd = argv + argc;
-
+ List<const char*> inputPaths;
char const* appName = "slang-generate";
- if( argCursor != argEnd )
- {
- appName = *argCursor++;
- }
-
- char** writeCursor = argv;
- char const* const* inputPaths = writeCursor;
-
- while(argCursor != argEnd)
- {
- *writeCursor++ = *argCursor++;
- }
- size_t inputPathCount = writeCursor - inputPaths;
- if(inputPathCount == 0)
{
- usage(appName);
- exit(1);
+ const char*const* argCursor = argv;
+ const char*const* argEnd = argv + argc;
+ // Copy the app name
+ if( argCursor != argEnd )
+ {
+ appName = *argCursor++;
+ }
+ // Copy the input paths
+ for (; argCursor != argEnd; ++argCursor)
+ {
+ inputPaths.Add(*argCursor);
+ }
}
- if( argCursor != argEnd )
+ if(inputPaths.Count() == 0)
{
usage(appName);
exit(1);
@@ -786,9 +787,8 @@ int main(
// Read each input file and process it according
// to the type of treatment it requires.
- for (size_t ii = 0; ii < inputPathCount; ++ii)
+ for (const char* inputPath: inputPaths)
{
- char const* inputPath = inputPaths[ii];
SourceFile* sourceFile = parseSourceFile(inputPath);
if (sourceFile)
{
@@ -804,27 +804,28 @@ int main(
auto node = sourceFile->node;
// write output to a temporary file first
- char outputPath[1024];
- sprintf_s(outputPath, "%s.temp.h", inputPath);
+ StringBuilder outputPath;
+ outputPath << inputPath << ".temp.h";
FILE* outputStream;
- fopen_s(&outputStream, outputPath, "w");
+ fopen_s(&outputStream, outputPath.Buffer(), "w");
emitTemplateNodes(outputStream, node);
fclose(outputStream);
// update final output only when content has changed
- char outputPathFinal[1024];
- sprintf_s(outputPathFinal, "%s.h", inputPath);
+ StringBuilder outputPathFinal;
+ outputPathFinal << inputPath << ".h";
- char * allTextOld = readAllText(outputPathFinal);
- char * allTextNew = readAllText(outputPath);
- if (strcmp(allTextNew, allTextOld) != 0)
+ String allTextOld, allTextNew;
+ readAllText(outputPathFinal.Buffer(), allTextOld);
+ readAllText(outputPath.Buffer(), allTextNew);
+ if (allTextOld != allTextNew)
{
- writeAllText(inputPath, outputPathFinal, allTextNew);
+ writeAllText(inputPath, outputPathFinal.Buffer(), allTextNew.Buffer());
}
- remove(outputPath);
+ remove(outputPath.Buffer());
}
return 0;
diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp
index af9a9b9f0..8eda760d4 100644
--- a/tools/slang-test/main.cpp
+++ b/tools/slang-test/main.cpp
@@ -392,7 +392,7 @@ void skipToEndOfLine(char const** ioCursor)
cursor++;
}
}
- // fall through to:
+ ; // fall through to:
case 0:
*ioCursor = cursor;
return;