File: config.py

package info (click to toggle)
pyopengl 2.0.1.08-5.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,484 kB
  • ctags: 9,036
  • sloc: pascal: 64,950; xml: 28,088; ansic: 20,696; python: 19,761; tcl: 668; makefile: 240; sh: 25
file content (67 lines) | stat: -rw-r--r-- 1,483 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import distutils.command.config
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils.ccompiler import CompileError
from util import *


glu_body = '''
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef __APPLE_CC__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#ifdef GLU_VERSION_1_2
GLUnurbs *x;
GLUtesselator *y;
GLUquadric *z;
#endif
'''

texture_object_body = '''
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef __APPLE_CC__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#ifndef GL_EXT_texture_object
void glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences)
{
}
#endif
'''

class config(distutils.command.config.config):

	def run(self):
		self.output_dir = "" # Try by Jack
		self._check_compiler()
		customize_compiler(self.compiler)

		if not self.try_compile(glu_body):
			self.distribution.define_macros.append(('BAD_GLU_HEADER', None))

		if not self.try_compile(texture_object_body):
			self.distribution.define_macros.append(('GL_EXT_texture_object', 1))


	def try_compile (self, body, headers=None, include_dirs=None, lang="c"):
		"""Try to compile a source file built from 'body' and 'headers'.
		Return true on success, false otherwise.
		"""
		
		try:
			self._compile(body, headers, include_dirs, lang)
			ok = 1
		except CompileError:
			ok = 0
		
		return ok