scons: make embedding orthogonal to the platform
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 17 Jun 2011 13:48:28 +0000 (14:48 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 17 Jun 2011 13:50:37 +0000 (14:50 +0100)
To enable embedding in platforms other than linux.

13 files changed:
SConstruct
common.py
scons/gallium.py
src/gallium/SConscript
src/gallium/auxiliary/os/os_memory.h
src/gallium/auxiliary/os/os_misc.h
src/gallium/auxiliary/os/os_thread.h
src/gallium/auxiliary/os/os_time.c
src/gallium/auxiliary/util/u_debug.c
src/gallium/drivers/llvmpipe/SConscript
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/include/pipe/p_config.h
src/glsl/SConscript

index 8607d2cd8e0ab726039d02202e067c158ae75ff4..dc5fd776a713bb4ce861b1df2996da68a77346de 100644 (file)
@@ -80,23 +80,6 @@ env.Append(CPPPATH = [
 if env['msvc']:
     env.Append(CPPPATH = ['#include/c99'])
 
-# Embedded
-if env['platform'] == 'embedded':
-       env.Append(CPPDEFINES = [
-               '_POSIX_SOURCE',
-               ('_POSIX_C_SOURCE', '199309L'), 
-               '_SVID_SOURCE',
-               '_BSD_SOURCE', 
-               '_GNU_SOURCE',
-               
-               'PTHREADS',
-       ])
-       env.Append(LIBS = [
-               'm',
-               'pthread',
-               'dl',
-       ])
-
 # Posix
 if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
        env.Append(CPPDEFINES = [
@@ -130,7 +113,7 @@ if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
 #
 
 # Create host environent
-if env['crosscompile'] and env['platform'] != 'embedded':
+if env['crosscompile'] and not env['embedded']:
     host_env = Environment(
         options = opts,
         # no tool used
index 0a3dcdcf54309995dbdcd5176a5080dab44604f3..052929e2bb087f95c335d31b0bbf2283b2df8ca3 100644 (file)
--- a/common.py
+++ b/common.py
@@ -83,7 +83,8 @@ def AddOptions(opts):
        opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
                                                                                         allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
        opts.Add(EnumOption('platform', 'target platform', host_platform,
-                                                                                        allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin', 'sunos', 'freebsd8')))
+                                                                                        allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'cygwin', 'sunos', 'freebsd8')))
+       opts.Add(BoolOption('embedded', 'embedded build', 'no'))
        opts.Add('toolchain', 'compiler toolchain', default_toolchain)
        opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
        opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
index a94bf7364808a492b24e773b7b94eb57dac7d33b..57acfe032f269275c62dab4703a8a6cd54becdf2 100755 (executable)
@@ -247,6 +247,8 @@ def generate(env):
     # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
     build_topdir = 'build'
     build_subdir = env['platform']
+    if env['embedded']:
+        build_subdir =  'embedded-' + build_subdir
     if env['machine'] != 'generic':
         build_subdir += '-' + env['machine']
     if env['build'] != 'release':
@@ -349,8 +351,8 @@ def generate(env):
     if platform == 'wince':
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
-    if platform == 'embedded':
-        cppdefines += ['PIPE_OS_EMBEDDED']
+    if env['embedded']:
+        cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED']
     env.Append(CPPDEFINES = cppdefines)
 
     # C compiler options
index 428bc31f86b626b5d21a703a88fbad8f065c8d6f..3072ee936f2793a834f55bacec6875485cba1d2b 100644 (file)
@@ -53,7 +53,7 @@ if env['drm']:
 # Needed by some state trackers
 SConscript('winsys/sw/null/SConscript')
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript('state_trackers/vega/SConscript')
     SConscript('state_trackers/egl/SConscript')
 
@@ -66,8 +66,8 @@ if env['platform'] != 'embedded':
     if env['dri'] and env['xorg']:
         SConscript('state_trackers/xorg/SConscript')
 
-if env['platform'] == 'windows':
-    SConscript('state_trackers/wgl/SConscript')
+    if env['platform'] == 'windows':
+        SConscript('state_trackers/wgl/SConscript')
 
 #
 # Winsys
@@ -83,55 +83,55 @@ SConscript([
     'targets/graw-null/SConscript',
 ])
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript([
         'targets/egl-static/SConscript'
     ])
 
-if env['x11']:
-    SConscript([
-        'targets/graw-xlib/SConscript',
-        'targets/libgl-xlib/SConscript',
-    ])
+    if env['x11']:
+        SConscript([
+            'targets/graw-xlib/SConscript',
+            'targets/libgl-xlib/SConscript',
+        ])
 
-if env['platform'] == 'windows':
-    SConscript([
-        'targets/graw-gdi/SConscript',
-        'targets/libgl-gdi/SConscript',
-    ])
+    if env['platform'] == 'windows':
+        SConscript([
+            'targets/graw-gdi/SConscript',
+            'targets/libgl-gdi/SConscript',
+        ])
 
-if env['dri']:
-    SConscript([
-        'targets/SConscript.dri',
-        'targets/dri-swrast/SConscript',
-        'targets/dri-vmwgfx/SConscript',
-        #'targets/dri-nouveau/SConscript',
-    ])
-    if env['drm_intel']:
+    if env['dri']:
         SConscript([
-            'targets/dri-i915/SConscript',
-            'targets/dri-i965/SConscript',
+            'targets/SConscript.dri',
+            'targets/dri-swrast/SConscript',
+            'targets/dri-vmwgfx/SConscript',
+            #'targets/dri-nouveau/SConscript',
         ])
-    if env['drm_radeon']:
+        if env['drm_intel']:
+            SConscript([
+                'targets/dri-i915/SConscript',
+                'targets/dri-i965/SConscript',
+            ])
+        if env['drm_radeon']:
+            SConscript([
+                'targets/dri-r300/SConscript',
+                'targets/dri-r600/SConscript',
+            ])
+
+    if env['xorg'] and env['drm']:
         SConscript([
-            'targets/dri-r300/SConscript',
-            'targets/dri-r600/SConscript',
+            #'targets/xorg-i915/SConscript',
+            #'targets/xorg-i965/SConscript',
+            #'targets/xorg-nouveau/SConscript',
+            #'targets/xorg-radeon/SConscript',
+            'targets/xorg-vmwgfx/SConscript',
         ])
 
-if env['xorg'] and env['drm']:
-    SConscript([
-        #'targets/xorg-i915/SConscript',
-        #'targets/xorg-i965/SConscript',
-        #'targets/xorg-nouveau/SConscript',
-        #'targets/xorg-radeon/SConscript',
-        'targets/xorg-vmwgfx/SConscript',
-    ])
-
 
 #
 # Unit tests & tools
 #
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     SConscript('tests/unit/SConscript')
     SConscript('tests/graw/SConscript')
index 556662d35e1f88161a383bc0d8ff6613d1d38b90..91a84a24bc80ea1d727d58e8afa4e6bfb8c26e7f 100644 (file)
@@ -39,7 +39,7 @@
 #include "pipe/p_compiler.h"
 
 
-#if defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_SUBSYSTEM_EMBEDDED)
 
 #ifdef __cplusplus
 extern "C" {
index d59f9819feca69f144610a07cc0c7225232b14d3..48522dac4d72795c903012945ae68d198b67bbed 100644 (file)
@@ -58,8 +58,6 @@ extern "C" {
 #  define os_break()  __debugbreak()
 #elif defined(PIPE_OS_UNIX)
 #  define os_break() kill(getpid(), SIGTRAP)
-#elif defined(PIPE_OS_EMBEDDED)
-void os_break(void);
 #else
 #  define os_break() abort()
 #endif
@@ -70,8 +68,6 @@ void os_break(void);
  */
 #if defined(DEBUG) || defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
 #  define os_abort() os_break()
-#elif defined(PIPE_OS_EMBEDDED)
-void os_abort(void);
 #else
 #  define os_abort() abort()
 #endif
index 6b4281ad661cceecf7181ea298c880ab75636e19..8f1245bff550d6b2a8420ab9e9fb2f6c6d52d621 100644 (file)
@@ -40,7 +40,7 @@
 #include "util/u_debug.h" /* for assert */
 
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
 
 #include <pthread.h> /* POSIX threads headers */
 #include <stdio.h> /* for perror() */
@@ -314,7 +314,7 @@ typedef int64_t pipe_condvar;
  * pipe_barrier
  */
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
 
 typedef pthread_barrier_t pipe_barrier;
 
@@ -442,7 +442,7 @@ pipe_semaphore_wait(pipe_semaphore *sema)
  */
 
 typedef struct {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    pthread_key_t key;
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
    DWORD key;
@@ -457,7 +457,7 @@ typedef struct {
 static INLINE void
 pipe_tsd_init(pipe_tsd *tsd)
 {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
       perror("pthread_key_create(): failed to allocate key for thread specific data");
       exit(-1);
@@ -474,7 +474,7 @@ pipe_tsd_get(pipe_tsd *tsd)
    if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
       pipe_tsd_init(tsd);
    }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    return pthread_getspecific(tsd->key);
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
    assert(0);
@@ -491,7 +491,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
    if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
       pipe_tsd_init(tsd);
    }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN)
    if (pthread_setspecific(tsd->key, value) != 0) {
       perror("pthread_set_specific() failed");
       exit(-1);
index 325f316784c0d850687be0a84d0a6e05f60e863b..73d86296d91a5ae9d29d38d83dc3827afda9168b 100644 (file)
@@ -35,8 +35,6 @@
 
 #include "pipe/p_config.h"
 
-#if !defined(PIPE_OS_EMBEDDED)
-
 #if defined(PIPE_OS_UNIX)
 #  include <sys/time.h> /* timeval */
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
@@ -123,6 +121,3 @@ os_time_sleep(int64_t usecs)
 }
 
 #endif
-
-
-#endif /* !PIPE_OS_EMBEDDED */
index 36ce4b577133741bd00be89cfbdcbf022acac63c..004df439ff516b32a76a0bb044b165335006956e 100644 (file)
@@ -48,7 +48,7 @@
 
 void _debug_vprintf(const char *format, va_list ap)
 {
-#if defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_EMBEDDED)
+#if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED)
    /* We buffer until we find a newline. */
    static char buf[4096] = {'\0'};
    size_t len = strlen(buf);
index c10a8cbc12c8e406fbb22323fec2d6a996bf0cd4..d6b20ceb5ce1280cd47379382f86edabab11cf4c 100644 (file)
@@ -79,7 +79,7 @@ llvmpipe = env.ConvenienceLibrary(
 env.Alias('llvmpipe', llvmpipe)
 
 
-if env['platform'] != 'embedded':
+if not env['embedded']:
     env = env.Clone()
 
     env.Prepend(LIBS = [llvmpipe] + gallium)
index 036a6e0c3796b702e1fee22817b316b0457d15fe..4b2ae1436ea6f55819b0a9ef708fa090414fbbb4 100644 (file)
@@ -423,7 +423,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
    lp_jit_screen_init(screen);
 
    screen->num_threads = util_cpu_caps.nr_cpus > 1 ? util_cpu_caps.nr_cpus : 0;
-#ifdef PIPE_OS_EMBEDDED
+#ifdef PIPE_SUBSYSTEM_EMBEDDED
    screen->num_threads = 0;
 #endif
    screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
index 40f6f2bcb5ffe6e159b03ad5aeb84121a1b425bd..eea3d79e64baa5d2ba84c18ad81a56443db1569f 100644 (file)
 #error Unknown Endianness
 #endif
 
-#if !defined(PIPE_OS_EMBEDDED)
-
 /*
  * Auto-detect the operating system family.
  * 
 #endif
 #endif /* PIPE_OS_WINDOWS */
 
-#endif /* !PIPE_OS_EMBEDDED */
-
 
 #endif /* P_CONFIG_H_ */
index c3255835fb4af8cdd33392cd3bd04d3255e390a1..1441cc74bd8f8036d1ef22e646402ce25c15f6d3 100644 (file)
@@ -102,7 +102,7 @@ if env['msvc']:
     env.Prepend(CPPPATH = ['#/src/getopt'])
     env.PrependUnique(LIBS = [getopt])
 
-if env['crosscompile'] and env['platform'] != 'embedded':
+if env['crosscompile'] and not env['embedded']:
     Import('builtin_glsl_function')
 else:
     # Copy these files to avoid generation object files into src/mesa/program
@@ -156,7 +156,7 @@ Export('glsl')
 
 # Skip building these programs as they will cause SCons error "Two environments
 # with different actions were specified for the same target"
-if env['crosscompile'] or env['platform'] == 'embedded':
+if env['crosscompile'] or env['embedded']:
     Return()
 
 env = env.Clone()