"Fossies" - the Fresh Open Source Software Archive

Member "ponyc-0.33.2/wscript" (3 Feb 2020, 19574 Bytes) of package /linux/misc/ponyc-0.33.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "wscript": 0.33.1_vs_0.33.2.

    1 #! /usr/bin/env python
    2 # encoding: utf-8
    3 
    4 # This script is used to configure and build the Pony compiler.
    5 # Target definitions are in the build() function.
    6 
    7 import sys, subprocess
    8 from waflib import TaskGen
    9 
   10 TaskGen.declare_chain(
   11     rule    = '${LLVM_LLC} -filetype=obj -o ${TGT} ${SRC}',
   12     ext_in  = '.ll',
   13     ext_out = '.o'
   14 )
   15 
   16 # check if the operating system's description contains a string
   17 def os_is(name):
   18     return (sys.platform.lower().rfind(name) > -1)
   19 
   20 # runs a shell command and captures its standard output
   21 def cmd_output(cmd):
   22     if (sys.version_info > (3,0)):
   23         return str(subprocess.check_output(cmd), 'utf-8').strip('\n').strip('\'')
   24     else:
   25         return str(subprocess.check_output(cmd)).strip('\n').strip('\'')
   26 
   27 # build ponyc version string
   28 APPNAME = 'ponyc'
   29 VERSION = '?'
   30 with open('VERSION') as v:
   31     VERSION = v.read().strip()
   32     try:
   33         rev = '-' + cmd_output(['git', 'rev-parse', '--short', 'HEAD'])
   34         VERSION = VERSION + rev
   35     except:
   36         pass
   37 
   38 # source and build directories
   39 top = '.'
   40 out = 'build'
   41 
   42 # various configuration parameters
   43 CONFIGS = [
   44     'release',
   45     'debug'
   46 ]
   47 
   48 MSVC_VERSIONS = [ '16.4', '16.3', '16.2', '16.1', '16.0', '15.9', '15.8', '15.7', '15.6', '15.4', '15.0' ]
   49 
   50 # keep these in sync with the list in .appveyor.yml
   51 LLVM_VERSIONS = [
   52     '7.1.0',
   53     '8.0.1',
   54     '9.0.0'
   55 ]
   56 
   57 LIBRESSL_VERSION = "3.0.0"
   58 PCRE2_VERSION = "10.33"
   59 WINDOWS_LIBS_TAG = "v1.9.0"
   60 
   61 # Adds an option for specifying debug or release mode.
   62 def options(ctx):
   63     ctx.add_option('--config', action='store', default=CONFIGS[0], help='debug or release build')
   64     ctx.add_option('--llvm', action='store', default=LLVM_VERSIONS[0], help='llvm version')
   65     ctx.add_option('--msvc', action='store', default=None, help='MSVC version')
   66 
   67 # This replaces the default versions of these context classes with subclasses
   68 # that set their "variant", i.e. build directory, to the debug or release config.
   69 def init(ctx):
   70     from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
   71     for c in (BuildContext, CleanContext, InstallContext, UninstallContext, testContext, examplesContext):
   72         name = c.__name__.replace('Context','').lower()
   73         class tmp(c):
   74             cmd = name
   75             variant = ctx.options.config.lower() + '-llvm-' + ctx.options.llvm
   76 
   77 # sets up one-time configuration for the build variants
   78 def configure(ctx):
   79     ctx.env.append_value('DEFINES', [
   80         'PONY_VERSION="' + VERSION + '"',
   81         'PONY_USE_BIGINT',
   82     ])
   83 
   84     if os_is('win32'):
   85         import os
   86 
   87         base_env = ctx.env
   88         if ctx.options.msvc is None:
   89             base_env.MSVC_VERSIONS = [ 'msvc ' + v for v in MSVC_VERSIONS ]
   90         else:
   91             base_env.MSVC_VERSIONS = [ 'msvc ' + ctx.options.msvc ]
   92         base_env.MSVC_TARGETS = [ 'x64' ]
   93         ctx.load('msvc')
   94 
   95         base_env.append_value('DEFINES', [
   96             '_CRT_SECURE_NO_WARNINGS', '_MBCS',
   97             'PLATFORM_TOOLS_VERSION=%d0' % base_env.MSVC_VERSION,
   98             'BUILD_COMPILER="msvc-%d-x64"' % base_env.MSVC_VERSION
   99         ])
  100         base_env.append_value('LIBPATH', [ base_env.LLVM_DIR ])
  101 
  102         for llvm_version in LLVM_VERSIONS:
  103             bld_env = base_env.derive()
  104             bld_env.PONYLIBS_DIR = 'ThirdParty'
  105             bld_env.LIBRESSL_DIR = os.path.join(bld_env.PONYLIBS_DIR, \
  106                 'lib', 'libressl-' + LIBRESSL_VERSION)
  107             bld_env.PCRE2_DIR = os.path.join(bld_env.PONYLIBS_DIR, \
  108                 'lib', 'pcre2-' + PCRE2_VERSION)
  109             bld_env.append_value('DEFINES', [
  110                 'LLVM_VERSION="' + llvm_version + '"',
  111                 'PONY_VERSION_STR="' + \
  112                     '%s [%s]\\ncompiled with: llvm %s -- msvc-%d-x64"' % \
  113                     (VERSION, ctx.options.config, \
  114                         llvm_version, base_env.MSVC_VERSION)
  115             ])
  116 
  117             libs_name = 'PonyWinLibs' + \
  118                 '-LLVM-' + llvm_version + \
  119                 '-LibreSSL-' + LIBRESSL_VERSION + \
  120                 '-PCRE2-' + PCRE2_VERSION + '-' + \
  121                 WINDOWS_LIBS_TAG
  122 
  123             # Debug configuration
  124             bldName = 'debug-llvm-' + llvm_version
  125             ctx.setenv(bldName, env = bld_env)
  126             ctx.env.PONYLIBS_NAME = libs_name + '-Debug'
  127             ctx.env.LLVM_DIR = os.path.join(ctx.env.PONYLIBS_DIR, \
  128                 'lib', 'LLVM-' + llvm_version + '-Debug')
  129 
  130             ctx.env.append_value('DEFINES', [
  131                 'DEBUG',
  132                 'PONY_BUILD_CONFIG="debug"',
  133                 '_SCL_SECURE_NO_WARNINGS'
  134             ])
  135             msvcDebugFlags = [
  136                 '/EHsc', '/MP', '/GS', '/W3', '/Zc:wchar_t', '/Zi',
  137                 '/Gm-', '/Od', '/Zc:inline', '/fp:precise', '/WX',
  138                 '/Zc:forScope', '/Gd', '/MDd', '/FS', '/DEBUG'
  139             ]
  140             ctx.env.append_value('CFLAGS', msvcDebugFlags)
  141             ctx.env.append_value('CXXFLAGS', msvcDebugFlags)
  142             ctx.env.append_value('LINKFLAGS', [
  143                 '/NXCOMPAT', '/SUBSYSTEM:CONSOLE', '/DEBUG', '/ignore:4099'
  144             ])
  145             ctx.env.PONYC_EXTRA_LIBS = [
  146                 'kernel32', 'user32', 'gdi32', 'winspool', 'comdlg32',
  147                 'advapi32', 'shell32', 'ole32', 'oleaut32', 'uuid',
  148                 'odbc32', 'odbccp32', 'vcruntimed', 'ucrtd', 'Ws2_32',
  149                 'dbghelp', 'Shlwapi'
  150             ]
  151 
  152             # Release configuration
  153             bldName = 'release-llvm-' + llvm_version
  154             ctx.setenv(bldName, env = bld_env)
  155             ctx.env.PONYLIBS_NAME = libs_name + '-Release'
  156             ctx.env.LLVM_DIR = os.path.join(ctx.env.PONYLIBS_DIR, \
  157                 'lib', 'LLVM-' + llvm_version + '-Release')
  158 
  159             ctx.env.append_value('DEFINES', [
  160                 'NDEBUG',
  161                 'PONY_BUILD_CONFIG="release"'
  162             ])
  163             msvcReleaseFlags = [
  164                 '/EHsc', '/MP', '/GS', '/W3', '/Gy', '/Zc:wchar_t',
  165                 '/Gm-', '/O2', '/Zc:inline', '/fp:precise', '/GF', '/WX',
  166                 '/Zc:forScope', '/Gd', '/Oi', '/MD', '/FS'
  167             ]
  168             ctx.env.append_value('CFLAGS', msvcReleaseFlags)
  169             ctx.env.append_value('CXXFLAGS', msvcReleaseFlags)
  170             ctx.env.append_value('LINKFLAGS', [
  171                 '/NXCOMPAT', '/SUBSYSTEM:CONSOLE'
  172             ])
  173             ctx.env.PONYC_EXTRA_LIBS = [
  174                 'kernel32', 'user32', 'gdi32', 'winspool', 'comdlg32',
  175                 'advapi32', 'shell32', 'ole32', 'oleaut32', 'uuid',
  176                 'odbc32', 'odbccp32', 'vcruntime', 'ucrt', 'Ws2_32',
  177                 'dbghelp', 'Shlwapi'
  178             ]
  179 
  180 # specifies build targets
  181 def build(ctx):
  182     import os
  183 
  184     buildDir = ctx.bldnode.abspath()
  185     packagesDir = os.path.join(ctx.srcnode.abspath(), 'packages')
  186 
  187     llvmIncludes = []
  188     llvmLibs = []
  189     llvmBuildMode = ''
  190     sslIncludes = []
  191 
  192     # download windows libraries needed for building
  193     if (os_is('win32')):
  194         libsName = ctx.env.PONYLIBS_NAME
  195         libsDir = os.path.join(buildDir, ctx.env.PONYLIBS_DIR)
  196         libresslDir = os.path.join(buildDir, ctx.env.LIBRESSL_DIR)
  197         pcre2Dir = os.path.join(buildDir, ctx.env.PCRE2_DIR)
  198         llvmDir = os.path.join(buildDir, ctx.env.LLVM_DIR)
  199 
  200         if (ctx.cmd == 'clean'): # make sure to delete the libs directory
  201             import shutil
  202             if os.path.exists(libsDir):
  203                 shutil.rmtree(libsDir)
  204         else:
  205             llvmIncludes.append(os.path.join(llvmDir, 'include'))
  206             ctx.env.append_value('LIBPATH', os.path.join(llvmDir, 'lib'))
  207 
  208             sslIncludes.append(os.path.join(libresslDir, 'include'))
  209 
  210             if not (os.path.exists(libsDir) \
  211                 and os.path.exists(libresslDir) \
  212                 and os.path.exists(pcre2Dir) \
  213                 and os.path.exists(llvmDir)):
  214                 libsZip = libsName + '.zip'
  215                 libsFname = os.path.join(buildDir, '..', libsZip)
  216                 if not os.path.isfile(libsFname):
  217                     libsUrl = 'https://github.com/kulibali/ponyc-windows-libs/releases/download/' \
  218                         + WINDOWS_LIBS_TAG + '/' + libsZip
  219                     print('downloading ' + libsUrl)
  220                     if (sys.version_info > (3,0)):
  221                         import urllib.request
  222                         urllib.request.urlretrieve(libsUrl, libsFname)
  223                     else:
  224                         import urllib2
  225                         buf = urllib2.urlopen(libsUrl)
  226                         with open(libsFname, 'wb') as output:
  227                             while True:
  228                                 data = buf.read(65536)
  229                                 if data:
  230                                     output.write(data)
  231                                 else:
  232                                     break
  233                 print('unzipping ' + libsZip)
  234                 import zipfile
  235                 if not (os.path.exists(libsDir)):
  236                     os.makedirs(libsDir)
  237                 with zipfile.ZipFile(libsFname) as zf:
  238                     zf.extractall(libsDir)
  239 
  240                 import shutil
  241                 if (ctx.options.config == 'debug'):
  242                     shutil.copy(os.path.join(pcre2Dir, 'pcre2-8d.lib'), buildDir)
  243                     shutil.copy(os.path.join(pcre2Dir, 'pcre2-8d.lib'), os.path.join(buildDir, 'pcre2-8.lib'))
  244                 else:
  245                     shutil.copy(os.path.join(pcre2Dir, 'pcre2-8.lib'), buildDir)
  246                 shutil.copy(os.path.join(libresslDir, 'lib', 'crypto.lib'), buildDir)
  247                 shutil.copy(os.path.join(libresslDir, 'lib', 'ssl.lib'), buildDir)
  248                 shutil.copy(os.path.join(libresslDir, 'lib', 'tls.lib'), buildDir)
  249 
  250             llvmConfig = os.path.join(llvmDir, 'bin', 'llvm-config.exe')
  251             ctx.env.LLVM_LLC = os.path.join(llvmDir, 'bin', 'llc.exe')
  252             llvmLibFiles = cmd_output([llvmConfig, '--libs'])
  253             import re
  254             llvmLibs = [re.sub(r'.*[\\\/]([^\\\/)]+)$', r'\1', x) for x in llvmLibFiles.split('.lib') if x]
  255 
  256             llvmBuildMode = cmd_output([llvmConfig, '--build-mode'])
  257             if llvmBuildMode.upper() == 'RELEASE':
  258                 llvmBuildMode = 'LLVM_BUILD_MODE_Release'
  259             elif llvmBuildMode.upper() == 'RELWITHDEBINFO':
  260                 llvmBuildMode = 'LLVM_BUILD_MODE_RelWithDebInfo'
  261             elif llvmBuildMode.upper() == 'MINSIZEREL':
  262                 llvmBuildMode = 'LLVM_BUILD_MODE_MinSizeRel'
  263             elif llvmBuildMode.upper() == 'DEBUG':
  264                 llvmBuildMode = 'LLVM_BUILD_MODE_Debug'
  265             else:
  266                 print('Unknown llvm build-mode of {0}'.format(llvmBuildMode))
  267                 sys.exit(1)
  268             llvmBuildMode = 'LLVM_BUILD_MODE={0}'.format(llvmBuildMode)
  269 
  270     # build targets:
  271 
  272     # gtest
  273     ctx(
  274         features = 'cxx cxxstlib seq',
  275         target   = 'gtest',
  276         source   = ctx.path.ant_glob('lib/gtest/*.cc'),
  277         defines  = [ '_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING' ]
  278     )
  279 
  280     # libgbenchmark
  281     ctx(
  282         features = 'cxx cxxstlib seq',
  283         target   = 'libgbenchmark',
  284         source   = ctx.path.ant_glob('lib/gbenchmark/src/*.cc'),
  285         includes = [ 'lib/gbenchmark/include' ],
  286         defines  = [ 'HAVE_STD_REGEX', 'HAVE_STEADY_CLOCK' ]
  287     )
  288 
  289     # blake2
  290     ctx(
  291         features = 'c seq',
  292         target   = 'blake2',
  293         source   = ctx.path.ant_glob('lib/blake2/*.c'),
  294     )
  295 
  296     # libponyrt
  297     ctx(
  298         features = 'c cxx cxxstlib seq',
  299         target   = 'libponyrt',
  300         source   = ctx.path.ant_glob('src/libponyrt/**/*.c') + \
  301                    ctx.path.ant_glob('src/libponyrt/**/*.ll'),
  302         includes = [ 'src/common', 'src/libponyrt' ] + sslIncludes,
  303         cflags   = [ '/TP' ]
  304     )
  305 
  306     # libponyrt.benchmarks
  307     ctx(
  308         features = 'cxx cxxprogram seq',
  309         target   = 'libponyrt.benchmarks',
  310         source   = ctx.path.ant_glob('benchmark/libponyrt/**/*.cc'),
  311         includes = [ 'lib/gbenchmark/include', 'src/common', 'src/libponyrt' ],
  312         use      = [ 'libponyrt', 'libgbenchmark' ],
  313         lib      = ctx.env.PONYC_EXTRA_LIBS
  314     )
  315 
  316     # libponyrt.tests
  317     ctx(
  318         features  = 'c cxx cxxprogram seq',
  319         target    = 'libponyrt.tests',
  320         source    = ctx.path.ant_glob('test/libponyrt/**/*.cc'),
  321         includes  = [ 'src/common', 'src/libponyrt', 'lib/gtest' ],
  322         defines   = [ '_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING' ],
  323         use       = [ 'gtest', 'libponyrt' ],
  324         lib       = ctx.env.PONYC_EXTRA_LIBS
  325     )
  326 
  327     # libponyc
  328     ctx(
  329         features  = 'c cxx cxxstlib seq',
  330         target    = 'libponyc',
  331         source    = ctx.path.ant_glob('src/libponyc/**/*.c') + \
  332                     ctx.path.ant_glob('src/libponyc/**/*.cc'),
  333         includes  = [ 'src/common', 'lib/blake2' ] + llvmIncludes + sslIncludes,
  334         defines   = [ 'PONY_ALWAYS_ASSERT', llvmBuildMode ],
  335         cflags    = [ '/TP' ],
  336         use       = [ 'blake2' ]
  337     )
  338 
  339     # libponyc.benchmarks
  340     ctx(
  341         features = 'cxx cxxprogram seq',
  342         target   = 'libponyc.benchmarks',
  343         source   = ctx.path.ant_glob('benchmark/libponyc/**/*.cc'),
  344         includes = [ 'lib/gbenchmark/include', 'src/common', 'src/libponyrt' ],
  345         defines  = [ llvmBuildMode ],
  346         use      = [ 'libponyc', 'libgbenchmark' ],
  347         lib      = ctx.env.PONYC_EXTRA_LIBS
  348     )
  349 
  350     # libponyc.tests
  351     testcUses = [ 'gtest', 'libponyc', 'libponyrt' ]
  352     testcLibs = llvmLibs + ctx.env.PONYC_EXTRA_LIBS
  353     if os_is('win32'):
  354         testcUses = [ 'gtest', 'libponyc' ]
  355         testcLibs = [ '/WHOLEARCHIVE:libponyrt' ] + testcLibs
  356 
  357     ctx(
  358         features  = 'c cxx cxxprogram seq',
  359         target    = 'libponyc.tests',
  360         source    = ctx.path.ant_glob('test/libponyc/**/*.cc'),
  361         includes  = [ 'src/common', 'src/libponyc', 'src/libponyrt',
  362                       'lib/gtest' ] + llvmIncludes,
  363         defines   = [
  364             'PONY_ALWAYS_ASSERT',
  365             'PONY_PACKAGES_DIR="' + packagesDir.replace('\\', '\\\\') + '"',
  366             '_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING',
  367             llvmBuildMode
  368         ],
  369         use       = testcUses,
  370         lib       = testcLibs,
  371         linkflags = [ '/INCREMENTAL:NO' ]
  372     )
  373 
  374     # ponyc
  375     ctx(
  376         features  = 'c cxx cxxprogram seq',
  377         target    = 'ponyc',
  378         source    = ctx.path.ant_glob('src/ponyc/**/*.c'),
  379         includes  = [ 'src/common' ],
  380         defines   = [ 'PONY_ALWAYS_ASSERT' ],
  381         cflags    = [ '/TP' ],
  382         use       = [ 'libponyc', 'libponyrt' ],
  383         lib       = llvmLibs + ctx.env.PONYC_EXTRA_LIBS
  384     )
  385 
  386 
  387 # this command builds and runs the test suites
  388 def test(ctx):
  389     import os
  390 
  391     # stdlib tests
  392     stdlibDebugBinary = 'stdlib-debug'
  393     stdlibDebugTarget = stdlibDebugBinary
  394     if os_is('win32'):
  395         stdlibDebugTarget = 'stdlib-debug.exe'
  396 
  397     ctx(
  398         features = 'seq',
  399         rule     = '"' + os.path.join(ctx.bldnode.abspath(), 'ponyc') + '" -d --checktree --verify -b ' + stdlibDebugBinary + ' ../../packages/stdlib',
  400         target   = stdlibDebugTarget,
  401         source   = ctx.bldnode.ant_glob('ponyc*') + ctx.path.ant_glob('packages/**/*.pony'),
  402     )
  403 
  404     if not ctx.variant.startswith('debug'):
  405         stdlibReleaseBinary = 'stdlib-release'
  406         stdlibReleaseTarget = stdlibReleaseBinary
  407         if os_is('win32'):
  408             stdlibReleaseTarget = 'stdlib-release.exe'
  409 
  410         ctx(
  411             features = 'seq',
  412             rule     = '"' + os.path.join(ctx.bldnode.abspath(), 'ponyc') + '" -s --checktree --verify -b ' + stdlibReleaseBinary + ' ../../packages/stdlib',
  413             target   = stdlibReleaseTarget,
  414             source   = ctx.bldnode.ant_glob('ponyc*') + ctx.path.ant_glob('packages/**/*.pony'),
  415         )
  416 
  417     # grammar file
  418     ctx(
  419         features = 'seq',
  420         rule     = '"' + os.path.join(ctx.bldnode.abspath(), 'ponyc') + '" --antlr > pony.g.new',
  421         target   = 'pony.g.new',
  422     )
  423 
  424     def run_tests(ctx):
  425         buildDir = ctx.bldnode.abspath()
  426         sourceDir = ctx.srcnode.abspath()
  427 
  428         ponyc = os.path.join(buildDir, 'ponyc')
  429         subprocess.call([ ponyc, '--version' ])
  430 
  431         total = 0
  432         passed = 0
  433 
  434         total = total + 1
  435         testc = os.path.join(buildDir, 'libponyc.tests')
  436         returncode = subprocess.call([ testc, '--gtest_shuffle' ])
  437         if returncode == 0:
  438             passed = passed + 1
  439 
  440         total = total + 1
  441         testrt = os.path.join(buildDir, 'libponyrt.tests')
  442         print(testrt)
  443         returncode = subprocess.call([ testrt, '--gtest_shuffle' ])
  444         if returncode == 0:
  445             passed = passed + 1
  446 
  447         total = total + 1
  448         stdlib = os.path.join(buildDir, 'stdlib-debug')
  449         print(stdlib)
  450         returncode = subprocess.call([ stdlib, '--sequential' ])
  451         if returncode == 0:
  452             passed = passed + 1
  453 
  454         if not ctx.variant.startswith('debug'):
  455             total = total + 1
  456             stdlib = os.path.join(buildDir, 'stdlib-release')
  457             print(stdlib)
  458             returncode = subprocess.call([ stdlib, '--sequential' ])
  459             if returncode == 0:
  460                 passed = passed + 1
  461 
  462         total = total + 1
  463         ponyg = os.path.join(sourceDir, 'pony.g')
  464         ponygNew = os.path.join(buildDir, 'pony.g.new')
  465         with open(ponyg, 'r') as pg:
  466             with open(ponygNew, 'r') as pgn:
  467                 if pg.read() != pgn.read():
  468                     print('Generated grammar file differs from baseline')
  469                 else:
  470                     passed = passed + 1
  471 
  472         print('')
  473         print('{0} test suites; {1} passed; {2} failed'.format(total, passed, total - passed))
  474         if passed < total:
  475             sys.exit(1)
  476 
  477     ctx.add_post_fun(run_tests)
  478 
  479 
  480 # this command builds the example programs
  481 def examples(ctx):
  482     ctx(
  483         features = 'c cxxstlib seq',
  484         target   = 'ffi-callbacks',
  485         source   = 'examples/ffi-callbacks/callbacks.c'
  486     )
  487 
  488     ctx(
  489         features = 'c cxxstlib seq',
  490         target   = 'ffi-struct',
  491         source   = 'examples/ffi-struct/struct.c'
  492     )
  493 
  494     def build_examples(ctx):
  495         if ctx.variant.startswith('debug'):
  496             return
  497 
  498         import os
  499         import os.path
  500 
  501         buildDir = ctx.bldnode.abspath()
  502         ponyc = os.path.join(buildDir, 'ponyc')
  503 
  504         program_ffi_lib = os.path.join('examples', 'ffi-callbacks', 'ffi-callbacks.lib')
  505         if os.path.isfile(program_ffi_lib):
  506             os.remove(program_ffi_lib)
  507         program_ffi_lib = os.path.join('examples', 'ffi-struct', 'ffi-struct.lib')
  508         if os.path.isfile(program_ffi_lib):
  509             os.remove(program_ffi_lib)
  510 
  511         for path in os.listdir('examples'):
  512             dirname = os.path.join('examples', path)
  513             if os.path.isdir(dirname) and any(f.endswith('.pony') for f in os.listdir(dirname)):
  514                 os.chdir(os.path.join(buildDir, '..', '..', dirname))
  515                 returncode = subprocess.call([ponyc, '.'])
  516                 if returncode != 0:
  517                     print(path + ' failed to build!')
  518                     sys.exit(1)
  519                 os.chdir(os.path.join(buildDir, '..', '..'))
  520 
  521     ctx.add_post_fun(build_examples)
  522 
  523 
  524 # subclass the build context for the test command,
  525 # otherwise the context wouldn't be set up
  526 from waflib.Build import BuildContext
  527 class testContext(BuildContext):
  528     cmd = 'test'
  529     fun = 'test'
  530 class examplesContext(BuildContext):
  531     cmd = 'examples'
  532     fun = 'examples'