OSDN Git Service

Update to BUILD.gn files
authorAlexis Hetu <sugoi@google.com>
Wed, 6 Jul 2016 21:43:22 +0000 (17:43 -0400)
committerAlexis Hétu <sugoi@google.com>
Thu, 7 Jul 2016 20:58:23 +0000 (20:58 +0000)
- Now compiles for all combinations of "component"/"not component",
  debug/release on Linux/Windows
- Cleaned up dependencies
- Added some Windows specific flags

Change-Id: I09c2eaec096ac7f73fdd5b9ab0d407fa29369b4c
Reviewed-on: https://swiftshader-review.googlesource.com/5785
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
12 files changed:
BUILD.gn
src/Common/BUILD.gn
src/Main/BUILD.gn
src/OpenGL/common/BUILD.gn
src/OpenGL/compiler/BUILD.gn
src/OpenGL/compiler/preprocessor/BUILD.gn
src/OpenGL/libEGL/BUILD.gn
src/OpenGL/libGLESv2/BUILD.gn
src/Reactor/BUILD.gn
src/Renderer/BUILD.gn
src/Shader/BUILD.gn
third_party/LLVM/BUILD.gn

index 37e34b0..97f37ec 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -19,7 +19,7 @@ config("swiftshader_config") {
     ]
 
     if (is_debug) {
-        cflags += [
+      cflags += [
         "-g",
       ]
     } else { # Release
@@ -27,10 +27,8 @@ config("swiftshader_config") {
       cflags += [
         "-ffunction-sections",
         "-fdata-sections",
-        "-Wl",
-        "--gc-sections",
-        "-s",
         "-fomit-frame-pointer",
+        "-DANGLE_DISABLE_TRACE",
       ]
 
       # Choose the right Release architecture
@@ -55,18 +53,35 @@ config("swiftshader_config") {
         "-m32",
       ]
     }
+  } else {
+    if (host_os == "win") {
+      cflags = [
+        "/GS", # Detects some buffer overruns
+        "/Zc:wchar_t",
+        "/D_CRT_SECURE_NO_DEPRECATE",
+        "/DNOMINMAX",
+        "/D_WINDLL",
+        "/EHsc",
+        "/nologo",
+        "/Gd", # Default calling convention
+      ]
+
+      if (is_debug) {
+        cflags += [
+          "/RTC1", # Run-Time Error Checks
+        ]
+      } else {
+        cflags += [
+          "/DANGLE_DISABLE_TRACE",
+        ]
+      }
+    }
   }
 }
 
-component("swiftshader") {
-  configs -= [ "//build/config/compiler:chromium_code" ]
-  configs += [
-    "//build/config/compiler:no_chromium_code",
-    ":swiftshader_config",
-  ]
-
+group("swiftshader") {
   deps = [
-    "src/OpenGL/libEGL:swiftshader_libEGL",
     "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
+    "src/OpenGL/libEGL:swiftshader_libEGL",
   ]
 }
\ No newline at end of file
index 5d1fc65..c68e9da 100644 (file)
@@ -19,12 +19,6 @@ config("swiftshader_common_private_config") {
       "-DLOG_TAG=\"swiftshader_common\"",
       "-msse2",
     ]
-
-    if (!is_debug) {
-      cflags += [
-        "-DANGLE_DISABLE_TRACE",
-      ]
-    }
   } else {
     if (host_os == "win") {
       cflags = [
index ac84b5b..361ae54 100644 (file)
@@ -26,12 +26,6 @@ config("swiftshader_main_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_main") {
index 653db78..97e2f05 100644 (file)
@@ -26,12 +26,6 @@ config("swiftshader_opengl_common_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_opengl_common") {
index e0c7171..0f958d3 100644 (file)
@@ -19,6 +19,12 @@ config("swiftshader_opengl_compiler_private_config") {
       "-DLOG_TAG=\"swiftshader_opengl_compiler\"",
       "-Wno-sign-compare",
     ]
+
+    if (!is_debug) {
+      cflags += [
+        "-Wno-unused-variable", # local variable is initialized but not referenced (variables only used in ASSERTS)
+      ]
+    }
   } else {
     if (host_os == "win") {
       cflags = [
@@ -27,13 +33,13 @@ config("swiftshader_opengl_compiler_private_config") {
         "/wd4267", # conversion from size_t to int/unsigned int
         "/wd4702", # unreachable code (in autogenerated code)
       ]
-    }
-  }
 
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
+      if (!is_debug) {
+        cflags += [
+          "/wd4189", # local variable is initialized but not referenced (variables only used in ASSERTS)
+        ]
+      }
+    }
   }
 }
 
index f5feb01..71ba50d 100644 (file)
@@ -27,12 +27,6 @@ config("swiftshader_opengl_preprocessor_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_opengl_preprocessor") {
index bed0df0..514ffdd 100644 (file)
@@ -26,39 +26,31 @@ config("swiftshader_libEGL_private_config") {
       cflags = [
         "/DEGLAPI=",
         "/DEGL_EGLEXT_PROTOTYPES",
+        "/DLIBEGL_EXPORTS",
         "/wd4201", # nameless struct/union
         "/wd4065", # switch statement contains 'default' but no 'case' labels
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 shared_library("swiftshader_libEGL") {
-  deps = [
-    "../../Common:swiftshader_common",
-    "../../Reactor:swiftshader_reactor",
-    "../../Renderer:swiftshader_renderer",
-    "../../OpenGL/common:swiftshader_opengl_common",
-    "../../OpenGL/compiler:swiftshader_opengl_compiler",
-    "../../Shader:swiftshader_shader",
-    "../../Main:swiftshader_main",
-    "../../../third_party/LLVM:swiftshader_llvm",
-  ]
-
   sources = [
     "Config.cpp",
     "Display.cpp",
     "Surface.cpp",
     "libEGL.cpp",
     "main.cpp",
+    "../common/Object.cpp",
   ]
 
+  if(is_debug)
+  {
+    sources += [
+      "../common/debug.cpp",
+    ]
+  }
+
   if (host_os == "mac") {
     sources += [
       "OSXUtils.mm",
@@ -67,9 +59,16 @@ shared_library("swiftshader_libEGL") {
     configs -= [
       "//build/config/win:unicode"
     ]
+  } else if (host_os == "linux") {
+    sources += [
+      "../../Main/libX11.cpp",
+    ]
   }
 
+  configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
+    "//build/config/compiler:no_chromium_code",
+    "//third_party/swiftshader:swiftshader_config",
     ":swiftshader_libEGL_private_config",
   ]
 
index 2f8f935..73d584a 100644 (file)
@@ -37,24 +37,13 @@ config("swiftshader_libGLESv2_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 shared_library("swiftshader_libGLESv2") {
   deps = [
-    "../../Common:swiftshader_common",
+    "../../OpenGL/compiler:swiftshader_opengl_compiler",
     "../../Reactor:swiftshader_reactor",
     "../../Renderer:swiftshader_renderer",
-    "../../OpenGL/common:swiftshader_opengl_common",
-    "../../OpenGL/compiler:swiftshader_opengl_compiler",
-    "../../Shader:swiftshader_shader",
-    "../../Main:swiftshader_main",
-    "../../../third_party/LLVM:swiftshader_llvm",
   ]
 
   sources = [
@@ -85,7 +74,10 @@ shared_library("swiftshader_libGLESv2") {
     ]
   }
 
+  configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
+    "//build/config/compiler:no_chromium_code",
+    "//third_party/swiftshader:swiftshader_config",
     ":swiftshader_libGLESv2_private_config",
   ]
 
index 98b33fc..86132fe 100644 (file)
@@ -30,17 +30,11 @@ config("swiftshader_reactor_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_reactor") {
   deps = [
-    "../Common:swiftshader_common",
+    "../OpenGL/common:swiftshader_opengl_common",
     "../../third_party/LLVM:swiftshader_llvm",
   ]
 
index 2cdcf78..86e581a 100644 (file)
@@ -29,19 +29,11 @@ config("swiftshader_renderer_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_renderer") {
   deps = [
-    "../Common:swiftshader_common",
     "../Shader:swiftshader_shader",
-    "../Main:swiftshader_main",
   ]
 
   sources = [
index a5e9262..7d15f85 100644 (file)
@@ -27,17 +27,10 @@ config("swiftshader_shader_private_config") {
       ]
     }
   }
-
-  if (!is_debug) {
-    cflags += [
-      "-DANGLE_DISABLE_TRACE",
-    ]
-  }
 }
 
 source_set("swiftshader_shader") {
   deps = [
-    "../Common:swiftshader_common",
     "../Main:swiftshader_main",
   ]
 
index d886ad5..eac83d4 100644 (file)
@@ -47,6 +47,12 @@ config("swiftshader_llvm_private_config") {
         "/wd4706",
         "/wd4800",
       ]
+
+      if (!is_debug) {
+        cflags += [
+          "/wd4324",
+        ]
+      }
     }
   }
 }
@@ -437,13 +443,24 @@ source_set("swiftshader_llvm") {
   ]
 
   include_dirs = [
-    "include",
     "lib/Target/X86",
   ]
 
+  # The "include" directory includes common files and the Windows specific config file.\r
+  # The "include-<platform>" directory includes the <platform> specific config file.
+  # Non-Windows platforms must add their platform specific include directory before the "include" directory
+  # is added, otherwise, the Windows specific config file will be used and compilation will fail.
   if (host_os == "linux") {
     include_dirs += [
       "include-linux",
     ]
+  } else if (host_os == "mac") {
+    include_dirs += [
+      "include-mac",
+    ]
   }
+
+  include_dirs += [
+    "include",
+  ]
 }
\ No newline at end of file