Skip to content

Commit

Permalink
Force download works again.
Browse files Browse the repository at this point in the history
  • Loading branch information
ginkgo committed Aug 17, 2012
1 parent 76afd2f commit 0fcb00a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
14 changes: 7 additions & 7 deletions examples/CMakeLists.txt
@@ -1,6 +1,6 @@

cmake_minimum_required(VERSION 2.8)
project(minimal)
project(example)

find_package(PythonInterp REQUIRED)
find_package(OpenGL REQUIRED)
Expand All @@ -18,10 +18,10 @@ add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/generated/flextGL.h" "${PROJECT
${PROJECT_SOURCE_DIR}/../templates/glfw/flextGL.c.template)


add_executable(minimal minimal.cpp mesh.cpp utility.cpp generated/flextGL.c)
target_link_libraries(minimal ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES})
add_executable(example example.cpp mesh.cpp utility.cpp generated/flextGL.c)
target_link_libraries(example ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES})

add_custom_command(TARGET minimal COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/minimal.frag" $<TARGET_FILE_DIR:minimal>)
add_custom_command(TARGET minimal COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/minimal.vert" $<TARGET_FILE_DIR:minimal>)
add_custom_command(TARGET example COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/example.frag" $<TARGET_FILE_DIR:example>)
add_custom_command(TARGET example COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/example.vert" $<TARGET_FILE_DIR:example>)
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 30 additions & 20 deletions flext.py
@@ -1,3 +1,4 @@
import time, os
import urllib.request
import os.path
from glob import glob
Expand All @@ -22,6 +23,10 @@
tm_file = '%s/gl.tm' % spec_dir


def file_age(filename):
return time.time() - os.path.getmtime(filename) / 3600.0;


def parse_args():
parser = OptionParser(usage='Usage: %prog [options] filename')
parser.add_option('-d', '--download',
Expand All @@ -48,6 +53,31 @@ def parse_args():
return options, args[0]


def download_spec(always_download = False):

if not os.path.exists(spec_dir):
os.makedirs(spec_dir)

if (24 * 3 < max([file_age(tm_file),
file_age(spec_file),
file_age(enumext_file)])):
always_download = True

if ( not always_download and
os.path.exists(spec_file) and
os.path.exists(tm_file) and
os.path.exists(enumext_file) ):
return


print ('Downloading gl.tm')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/gl.tm', tm_file)
print ('Downloading gl.spec')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/gl.spec', spec_file)
print ('Downloading enumext.spec')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/enumext.spec', enumext_file)


class Version():
def __init__(self, major, minor, core):
self.major = int(major)
Expand Down Expand Up @@ -100,26 +130,6 @@ def parse_profile(filename):
return version, extensions


def download_spec(always_download = False):

if not os.path.exists(spec_dir):
os.makedirs(spec_dir)

if ( not always_download and
os.path.exists(spec_file) and
os.path.exists(tm_file) and
os.path.exists(enumext_file) ):
return


print ('Downloading gl.tm')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/gl.tm', tm_file)
print ('Downloading gl.spec')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/gl.spec', spec_file)
print ('Downloading enumext.spec')
urllib.request.urlretrieve('http://www.opengl.org/registry/api/enumext.spec', enumext_file)


def parse_typemap():
typemap_pattern = re.compile('(\w+),\*,\*,\s*([A-Za-z0-9 \*_]+),*,*')

Expand Down
10 changes: 1 addition & 9 deletions flextGLgen.py
Expand Up @@ -5,20 +5,12 @@ def main():
options,profile = flext.parse_args()
version,extensions = flext.parse_profile(profile)

flext.download_spec(False)
flext.download_spec(options.download)
typemap = flext.parse_typemap()

categories = flext.find_categories(version, extensions, False)
enums = flext.parse_enums()
functions, passthru = flext.parse_functions(categories, typemap)
#print (sorted(categories))
#print (enums)
#for t in sorted(typemap.keys()):
# print ('%s %s' % ((t+":").ljust(40), typemap[t]))
# for cat,fs in sorted(functions.items()):
# print ('Category %s' % cat)
# for f in fs:
# print ('\t%s' % f.to_string())

flext.generate_source(options, version, enums, functions, passthru, extensions)

Expand Down

0 comments on commit 0fcb00a

Please sign in to comment.