def build_matlab(): global release amalgamate(core_files + ['src/coco_c_runtime.c'], 'build/matlab/coco.c', release) copy_file('src/coco.h', 'build/matlab/coco.h') write_file(hg_revision(), "build/matlab/REVISION") write_file(hg_version(), "build/matlab/VERSION") run('build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def build_matlab(): global release amalgamate(core_files + ['code-experiments/src/coco_runtime_r.c'], 'code-experiments/build/matlab/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h') write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") run('code-experiments/build/matlab', ['octave', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def run_c(): """ Builds and runs the example experiment in C """ build_c() try: run('code-experiments/build/c', ['./example_experiment']) except subprocess.CalledProcessError: sys.exit(-1)
def test_octave(): """ Builds and runs the test in Octave, which is equal to the example experiment """ build_octave() try: run('code-experiments/build/matlab', ['octave', '--no-gui', 'exampleexperiment.m']) except subprocess.CalledProcessError: sys.exit(-1)
def run_c_unit_tests(): """ Runs unit tests in C """ try: run('code-experiments/test/unit-test', ['./unit_test'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def leak_check(): build_c_integration_tests() os.environ['CFLAGS'] = '-g -Os' valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', './test_coco', 'bbob2009_testcases.txt'] run('code-experiments/test/integration-test', valgrind_cmd)
def run_octave(): # remove the mex files for a clean compilation first print('CLEAN\tmex files from code-experiments/build/matlab/') for filename in glob.glob('code-experiments/build/matlab/*.mex*'): os.remove(filename) # Copy octave-coco.bat to the Octave folder under Windows to allow # calling Octave from command line without messing up the system. # Note that 'win32' stands for both Windows 32-bit and 64-bit. if 'win32' in sys.platform: print('SEARCH\tfor Octave folder from C:\\ (can take some time)') lookfor = 'octave.bat' for root, dirs, files in os.walk('C:\\'): if lookfor in files: break copy_file('code-experiments/build/matlab/octave_coco.bat.in', join(root, 'octave_coco.bat')) # amalgamate, copy, and build build_octave() if 'win32' in sys.platform: run('code-experiments/build/matlab', ['octave_coco.bat', '--no-gui', 'exampleexperiment.m'], verbose=_verbosity) else: run('code-experiments/build/matlab', ['octave', '--no-gui', 'exampleexperiment.m'], verbose=_verbosity)
def run_c_example_tests(): """ Runs an example experiment test in C """ try: run('code-experiments/test/example-test', ['./example_experiment'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def run_java(): """ Builds and runs the example experiment in Java """ build_java() try: run('code-experiments/build/java', ['java', '-Djava.library.path=.', 'ExampleExperiment'], verbose=verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def run_c(): """ Builds and runs the example experiment in C """ build_c() try: run('code-experiments/build/c', ['./example_experiment'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def build_matlab_sms(): global release join = os.path.join source_folder = join('code-experiments', 'build', 'matlab') destination_folder = join('code-experiments', 'examples', 'bbob-biobj-matlab-smsemoa') # amalgamate and copy files amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], join(destination_folder, 'coco.c'), release) copy_file('code-experiments/src/coco.h', 'code-experiments/examples/bbob-biobj-matlab-smsemoa/coco.h') write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) files = ['cocoEvaluateFunction.c', 'cocoObserver.c', 'cocoObserverFree.c', 'cocoProblemGetDimension.c', 'cocoProblemGetEvaluations.c', 'cocoProblemGetId.c', 'cocoProblemGetLargestValuesOfInterest.c', 'cocoProblemGetName.c', 'cocoProblemGetNumberOfObjectives.c', 'cocoProblemGetSmallestValuesOfInterest.c', 'cocoProblemIsValid.c', 'cocoSuite.c', 'cocoSuiteFree.c', 'cocoSuiteGetNextProblem.c'] for file in files: copy_file(join(source_folder, file), join(destination_folder, file)) # compile run('code-experiments/examples/bbob-biobj-matlab-smsemoa', ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def leak_check(): """ Performs a leak check in C """ build_c() build_c_integration_tests() os.environ['CFLAGS'] = '-g -Os' valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=yes', './test_bbob-largescale', 'leak_check'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=_verbosity) valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=yes', './test_bbob-mixint', 'leak_check'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=_verbosity) valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=yes', './test_coco', 'bbob2009_testcases.txt'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=_verbosity) valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=yes', './test_biobj', 'leak_check'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=_verbosity) valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=yes', './test_bbob-constrained', 'leak_check'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=_verbosity)
def build_python(): _prep_python() ## Force distutils to use Cython # os.environ['USE_CYTHON'] = 'true' # python('code-experiments/build/python', ['setup.py', 'sdist']) # python(join('code-experiments', 'build', 'python'), ['setup.py', 'install', '--user']) run(join('code-experiments', 'build', 'python'), ['python', 'setup.py', 'install', '--user'])
def test_java(): """ Builds and runs the test in Java, which is equal to the example experiment """ build_java() try: run('code-experiments/build/java', ['java', '-Djava.library.path=.', 'ExampleExperiment']) except subprocess.CalledProcessError: sys.exit(-1)
def test_java(): """ Builds and runs the test in Java, which is equal to the example experiment """ build_java() try: run('code-experiments/build/java', ['java', '-Djava.library.path=.', 'ExampleExperiment'], verbose=verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def run_octave_sms(): """ Builds and runs the SMS-EMOA in Octave Note: does not work yet with all Windows/Octave versions. """ print( 'CLEAN\tmex files from code-experiments/examples/bbob-biobj-matlab-smsemoa/' ) destination_folder = 'code-experiments/examples/bbob-biobj-matlab-smsemoa' # remove the mex files for a clean compilation first for filename in glob.glob(join(destination_folder, '*.mex*')): os.remove(filename) # amalgamate, copy, and build build_octave_sms() wait_for_compilation_to_finish(join(destination_folder, 'paretofront')) # run after compilation finished if 'win32' in sys.platform: run(destination_folder, ['octave_coco.bat', '-nogui', 'run_smsemoa_on_bbob_biobj.m'], verbose=_verbosity) else: run(destination_folder, ['octave', '-nogui', 'run_smsemoa_on_bbob_biobj.m'], verbose=_verbosity)
def test_c(): build_c() try: make("build/c", "clean") make("build/c", "all") run('build/c', ['./coco_test', 'bbob2009_testcases.txt']) except subprocess.CalledProcessError: sys.exit(-1)
def run_octave(): # remove the mex files for a clean compilation first print('CLEAN\t mex files from code-experiments/build/matlab/') for filename in glob.glob('code-experiments/build/matlab/*.mex*'): os.remove(filename) # amalgamate, copy, and build build_octave() run('code-experiments/build/matlab', ['octave', '--no-gui', 'exampleexperiment.m'])
def run_matlab_sms(): # remove the mex files for a clean compilation first for filename in glob.glob('code-experiments/examples/bbob-biobj-matlab-smsemoa/*.mex*') : os.remove( filename ) # amalgamate, copy, and build build_matlab_sms() wait_for_compilation_to_finish('./code-experiments/examples/bbob-biobj-matlab-smsemoa/paretofront') # run after compilation finished run('code-experiments/examples/bbob-biobj-matlab-smsemoa', ['matlab', '-nodisplay', '-nosplash', '-r', 'run_smsemoa_on_bbob_biobj, exit'])
def run_matlab(): # remove the mex files for a clean compilation first for filename in glob.glob('code-experiments/build/matlab/*.mex*') : os.remove( filename ) # amalgamate, copy, and build build_matlab() wait_for_compilation_to_finish('./code-experiments/build/matlab/cocoProblemIsValid') # run after compilation finished run('code-experiments/build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'exampleexperiment, exit'])
def run_java(): """ Builds and runs the example experiment in Java """ build_java() try: run('code-experiments/build/java', ['java', '-classpath', '.', '-Djava.library.path=.', 'ExampleExperiment'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def build_matlab(): """Builds MATLAB example in build/matlab/ but not the one in examples/.""" global release amalgamate(core_files + ['code-experiments/src/coco_runtime_matlab.c'], 'code-experiments/build/matlab/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h') write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") run('code-experiments/build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def build_octave(): """Builds example in build/matlab/ with GNU Octave but not the one in examples/.""" global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/matlab/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h') write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") run('code-experiments/build/matlab', ['octave', '--no-gui', 'setup.m'])
def leak_check(): build_c() os.environ['CFLAGS'] = '-g -Os' make("build/c", "clean") make("build/c", "all") valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', './coco_test', 'bbob2009_testcases.txt'] run('build/c', valgrind_cmd)
def build_r(): global release copy_tree('build/r/skel', 'build/r/pkg') amalgamate(core_files + ['src/coco_r_runtime.c'], 'build/r/pkg/src/coco.c', release) copy_file('src/coco.h', 'build/r/pkg/src/coco.h') expand_file('build/r/pkg/DESCRIPTION.in', 'build/r/pkg/DESCRIPTION', {'COCO_VERSION': hg_version()}) # FIXME: it seems that this doesn't work, because it writes '0.0.789' instead of 0.0.789 rscript('build/r/', ['tools/roxygenize']) run('build/r', ['R', 'CMD', 'build', 'pkg'])
def test_octave(): """ Builds and runs the test in Octave, which is equal to the example experiment """ build_octave() try: if ('win32' in sys.platform): run('code-experiments/build/matlab', ['octave_coco.bat', '--no-gui', 'exampleexperiment.m'], verbose=verbosity) else: run('code-experiments/build/matlab', ['octave', '--no-gui', 'exampleexperiment.m'], verbose=verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def run_matlab(): """ Builds and runs the example experiment in build/matlab/ in MATLAB """ print('CLEAN\tmex files from code-experiments/build/matlab/') # remove the mex files for a clean compilation first for filename in glob.glob('code-experiments/build/matlab/*.mex*'): os.remove(filename) # amalgamate, copy, and build build_matlab() wait_for_compilation_to_finish('./code-experiments/build/matlab/cocoCall') # run after compilation finished run('code-experiments/build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'exampleexperiment, exit'])
def run_python(test=True): """ Builds and installs the Python module `cocoex` and runs the `example_experiment.py` as a simple test case. """ build_python() try: if test: run(os.path.join('code-experiments', 'build', 'python'), ['python', 'coco_test.py']) run(os.path.join('code-experiments', 'build', 'python'), ['python', 'example_experiment.py']) except subprocess.CalledProcessError: sys.exit(-1)
def build_matlab(): """Builds MATLAB example in build/matlab/ but not the one in examples/.""" global release amalgamate(core_files + ['code-experiments/src/coco_runtime_matlab.c'], 'code-experiments/build/matlab/coco.c', release, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h', {'COCO_VERSION': git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") run('code-experiments/build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'], verbose=verbosity)
def run_matlab_sms(): """ Builds and runs the SMS-EMOA in MATLAB """ print('CLEAN\tmex files from code-experiments/examples/bbob-biobj-matlab-smsemoa/') # remove the mex files for a clean compilation first for filename in glob.glob('code-experiments/examples/bbob-biobj-matlab-smsemoa/*.mex*'): os.remove(filename) # amalgamate, copy, and build build_matlab_sms() wait_for_compilation_to_finish('./code-experiments/examples/bbob-biobj-matlab-smsemoa/paretofront') # run after compilation finished run('code-experiments/examples/bbob-biobj-matlab-smsemoa', ['matlab', '-nodisplay', '-nosplash', '-r', 'run_smsemoa_on_bbob_biobj, exit'], verbose=verbosity)
def run_matlab(): """ Builds and runs the example experiment in build/matlab/ in MATLAB """ print('CLEAN\tmex files from code-experiments/build/matlab/') # remove the mex files for a clean compilation first for filename in glob.glob('code-experiments/build/matlab/*.mex*'): os.remove(filename) # amalgamate, copy, and build build_matlab() wait_for_compilation_to_finish('./code-experiments/build/matlab/cocoCall') # run after compilation finished run('code-experiments/build/matlab', ['matlab', '-nodisplay', '-nosplash', '-r', 'exampleexperiment, exit'], verbose=verbosity)
def run_python(test=False): """ Builds and installs the Python module `cocoex` and runs the `example_experiment.py` as a simple test case. If `test` is True, it runs, in addition, the tests in `coco_test.py`.""" build_python() try: if test: run(os.path.join('code-experiments', 'build', 'python'), ['python', 'coco_test.py']) python(os.path.join('code-experiments', 'build', 'python'), ['example_experiment.py']) except subprocess.CalledProcessError: sys.exit(-1)
def leak_check(): """ Performs a leak check in C """ build_c() build_c_integration_tests() os.environ['CFLAGS'] = '-g -Os' valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', './test_coco', 'bbob2009_testcases.txt'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=verbosity) valgrind_cmd = ['valgrind', '--error-exitcode=1', '--track-origins=yes', '--leak-check=full', '--show-reachable=yes', './test_biobj', 'leak_check'] run('code-experiments/test/integration-test', valgrind_cmd, verbose=verbosity)
def _prep_python(): global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/python/cython/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/python/cython/coco.h') copy_file('code-experiments/src/best_values_hyp.txt', 'code-experiments/build/python/best_values_hyp.txt') copy_file('code-experiments/src/bbob2009_testcases.txt', 'code-experiments/build/python/bbob2009_testcases.txt') expand_file('code-experiments/build/python/README.in', 'code-experiments/build/python/README', {'COCO_VERSION': git_version()}) # hg_version()}) expand_file('code-experiments/build/python/setup.py.in', 'code-experiments/build/python/setup.py', {'COCO_VERSION': git_version()}) # hg_version()}) if 'darwin' in sys.platform: run('code-experiments/build/python/cython', ['cython', 'interface.pyx'])
def build_matlab_sms(): """Builds the SMS-EMOA in MATLAB """ global release join = os.path.join destination_folder = 'code-experiments/examples/bbob-biobj-matlab-smsemoa' # amalgamate and copy files amalgamate(core_files + ['code-experiments/src/coco_runtime_matlab.c'], join(destination_folder, 'coco.c'), release) copy_file('code-experiments/src/coco.h', join(destination_folder, 'coco.h')) write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) copy_file('code-experiments/build/matlab/cocoCall.c', join(destination_folder, 'cocoCall.c')) # compile run(destination_folder, ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def run_c_integration_tests(): """ Runs integration tests in C """ try: run('code-experiments/test/integration-test', ['./test_coco', 'bbob2009_testcases.txt'], verbose=_verbosity) run('code-experiments/test/integration-test', ['./test_coco', 'bbob2009_testcases2.txt'], verbose=_verbosity) run('code-experiments/test/integration-test', ['./test_instance_extraction'], verbose=_verbosity) run('code-experiments/test/integration-test', ['./test_biobj'], verbose=_verbosity) run('code-experiments/test/integration-test', ['./test_bbob-constrained'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1)
def build_octave(): """Builds example in build/matlab/ with GNU Octave.""" global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/matlab/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h') write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") # make sure that under Windows, run_octave has been run at least once # before to provide the necessary octave_coco.bat file if ('win32' in sys.platform): run('code-experiments/build/matlab', ['octave_coco.bat', '--no-gui', 'setup.m']) else: run('code-experiments/build/matlab', ['octave', '--no-gui', 'setup.m'])
def run_c_integration_tests(): """ Runs integration tests in C """ try: run('code-experiments/test/integration-test', ['./test_coco', 'bbob2009_testcases.txt']) run('code-experiments/test/integration-test', ['./test_coco', 'bbob2009_testcases2.txt']) run('code-experiments/test/integration-test', ['./test_instance_extraction']) run('code-experiments/test/integration-test', ['./test_biobj']) except subprocess.CalledProcessError: sys.exit(-1)
def build_octave_sms(): """Builds the SMS-EMOA in Octave """ global release join = os.path.join destination_folder = 'code-experiments/examples/bbob-biobj-matlab-smsemoa' # amalgamate and copy files amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], join(destination_folder, 'coco.c'), release) copy_file('code-experiments/src/coco.h', join(destination_folder, 'coco.h')) write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) copy_file('code-experiments/build/matlab/cocoCall.c', join(destination_folder, 'cocoCall.c')) # compile if ('win32' in sys.platform): run(destination_folder, ['octave_coco.bat', '--no-gui', 'setup.m']) else: run(destination_folder, ['octave', '--no-gui', 'setup.m'])
def build_matlab_sms(): global release join = os.path.join source_folder = join('code-experiments', 'build', 'matlab') destination_folder = join('code-experiments', 'examples', 'bbob-biobj-matlab-smsemoa') # amalgamate and copy files amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], join(destination_folder, 'coco.c'), release) copy_file('code-experiments/src/coco.h', 'code-experiments/examples/bbob-biobj-matlab-smsemoa/coco.h') write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) for file in matlab_octave_wrapper_files: copy_file(join(source_folder, file), join(destination_folder, file)) # compile run('code-experiments/examples/bbob-biobj-matlab-smsemoa', ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def build_matlab_sms(): """Builds the SMS-EMOA in MATLAB """ global RELEASE destination_folder = 'code-experiments/examples/bbob-biobj-matlab-smsemoa' # amalgamate and copy files amalgamate(CORE_FILES + ['code-experiments/src/coco_runtime_matlab.c'], join(destination_folder, 'coco.c'), RELEASE, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', join(destination_folder, 'coco.h'), {'COCO_VERSION': git_version(pep440=True)}) for f in MATLAB_FILES: copy_file(join('code-experiments/build/matlab/', f), join(destination_folder, f)) write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) copy_file('code-experiments/build/matlab/cocoCall.c', join(destination_folder, 'cocoCall.c')) # compile run(destination_folder, ['matlab', '-nodisplay', '-nosplash', '-r', 'setup, exit'])
def build_octave(): """Builds example in build/matlab/ with GNU Octave.""" global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/matlab/coco.c', release, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-experiments/build/matlab/coco.h', {'COCO_VERSION': git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/matlab/REVISION") write_file(git_version(), "code-experiments/build/matlab/VERSION") # make sure that under Windows, run_octave has been run at least once # before to provide the necessary octave_coco.bat file if ('win32' in sys.platform): run('code-experiments/build/matlab', ['octave_coco.bat', '--no-gui', 'setup.m'], verbose=verbosity) else: run('code-experiments/build/matlab', ['octave', '--no-gui', 'setup.m'], verbose=verbosity)
def build_octave_sms(): """Builds the SMS-EMOA in Octave """ global RELEASE destination_folder = 'code-experiments/examples/bbob-biobj-matlab-smsemoa' # amalgamate and copy files amalgamate(CORE_FILES + ['code-experiments/src/coco_runtime_c.c'], join(destination_folder, 'coco.c'), RELEASE, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', join(destination_folder, 'coco.h'), {'COCO_VERSION': git_version(pep440=True)}) for f in MATLAB_FILES: copy_file(join('code-experiments/build/matlab/', f), join(destination_folder, f)) write_file(git_revision(), join(destination_folder, "REVISION")) write_file(git_version(), join(destination_folder, "VERSION")) copy_file('code-experiments/build/matlab/cocoCall.c', join(destination_folder, 'cocoCall.c')) # compile if 'win32' in sys.platform: run(destination_folder, ['octave_coco.bat', '--no-gui', 'setup.m']) else: run(destination_folder, ['octave', '--no-gui', 'setup.m'])
def run_c_example_tests(): try: run('code-experiments/test/example-test', ['./example_bbob2009']) run('code-experiments/test/example-test', ['./example_biobj']) run('code-experiments/test/example-test', ['./example_toy']) except subprocess.CalledProcessError: sys.exit(-1)
def uninstall_postprocessing(): run('.', ['pip', 'uninstall', 'cocopp', '-y'], verbose=_verbosity)
def build_java(): """ Builds the example experiment in Java """ global RELEASE amalgamate(CORE_FILES + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/java/coco.c', RELEASE, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-experiments/build/java/coco.h', {'COCO_VERSION': git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/java/REVISION") write_file(git_version(), "code-experiments/build/java/VERSION") run('code-experiments/build/java', ['javac', 'CocoJNI.java'], verbose=_verbosity) run('code-experiments/build/java', ['javah', 'CocoJNI'], verbose=_verbosity) # Finds the path to the headers jni.h and jni_md.h (platform-dependent) # and compiles the CocoJNI library (compiler-dependent). So far, only # the following cases are covered: # 1. Windows with Cygwin (both 64-bit) # Note that 'win32' stands for both Windows 32-bit and 64-bit. # Since platform 'cygwin' does not work as expected, we need to look for it in the PATH. if ('win32' in sys.platform) and ('cygwin' in os.environ['PATH']): jdkpath = check_output(['where', 'javac'], stderr=STDOUT, env=os.environ, universal_newlines=True) jdkpath1 = jdkpath.split("bin")[0] + 'include' jdkpath2 = jdkpath1 + '\\win32' if '64' in platform.machine(): run('code-experiments/build/java', ['x86_64-w64-mingw32-gcc', '-I', jdkpath1, '-I', jdkpath2, '-shared', '-o', 'CocoJNI.dll', 'CocoJNI.c'], verbose=_verbosity) # 2. Windows with Cygwin (both 32-bit) elif '32' in platform.machine() or 'x86' in platform.machine(): run('code-experiments/build/java', ['i686-w64-mingw32-gcc', '-Wl,--kill-at', '-I', jdkpath1, '-I', jdkpath2, '-shared', '-o', 'CocoJNI.dll', 'CocoJNI.c'], verbose=_verbosity) # 3. Windows without Cygwin elif ('win32' in sys.platform) and ('cygwin' not in os.environ['PATH']): jdkpath = check_output(['where', 'javac'], stderr=STDOUT, env=os.environ, universal_newlines=True) jdkpath1 = jdkpath.split("bin")[0] + 'include' jdkpath2 = jdkpath1 + '\\win32' run('code-experiments/build/java', ['gcc', '-Wl,--kill-at', '-I', jdkpath1, '-I', jdkpath2, '-shared', '-o', 'CocoJNI.dll', 'CocoJNI.c'], verbose=_verbosity) # 4. Linux elif 'linux' in sys.platform: jdkpath = check_output(['locate', 'jni.h'], stderr=STDOUT, env=os.environ, universal_newlines=True) jdkpath1 = jdkpath.split("jni.h")[0] jdkpath2 = jdkpath1 + '/linux' run('code-experiments/build/java', ['gcc', '-I', jdkpath1, '-I', jdkpath2, '-c', 'CocoJNI.c'], verbose=_verbosity) run('code-experiments/build/java', ['gcc', '-I', jdkpath1, '-I', jdkpath2, '-o', 'libCocoJNI.so', '-fPIC', '-shared', 'CocoJNI.c'], verbose=_verbosity) # 5. Mac elif 'darwin' in sys.platform: jdkversion = check_output(['javac', '-version'], stderr=STDOUT, env=os.environ, universal_newlines=True) jdkversion = jdkversion.split()[1] jdkpath = '/System/Library/Frameworks/JavaVM.framework/Headers' jdkpath1 = ('/Library/Java/JavaVirtualMachines/jdk' + jdkversion + '.jdk/Contents/Home/include') jdkpath2 = jdkpath1 + '/darwin' run('code-experiments/build/java', ['gcc', '-I', jdkpath, '-I', jdkpath1, '-I', jdkpath2, '-c', 'CocoJNI.c'], verbose=_verbosity) run('code-experiments/build/java', ['gcc', '-dynamiclib', '-o', 'libCocoJNI.jnilib', 'CocoJNI.o'], verbose=_verbosity) run('code-experiments/build/java', ['javac', 'Problem.java'], verbose=_verbosity) run('code-experiments/build/java', ['javac', 'Benchmark.java'], verbose=_verbosity) run('code-experiments/build/java', ['javac', 'Observer.java'], verbose=_verbosity) run('code-experiments/build/java', ['javac', 'Suite.java'], verbose=_verbosity) run('code-experiments/build/java', ['javac', 'ExampleExperiment.java'], verbose=_verbosity)