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 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 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 build_c(): global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/c/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/c/coco.h') copy_file('code-experiments/src/best_values_hyp.txt', 'code-experiments/build/c/best_values_hyp.txt') write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") make("code-experiments/build/c", "clean") make("code-experiments/build/c", "all")
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 build_c(): """ Builds the C source code """ global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/c/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/c/coco.h') copy_file('code-experiments/build/c/coco.c', 'code-experiments/examples/bbob2009-c-cmaes/coco.c') copy_file('code-experiments/build/c/coco.h', 'code-experiments/examples/bbob2009-c-cmaes/coco.h') write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") make("code-experiments/build/c", "clean") make("code-experiments/build/c", "all")
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 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 build_c(): """ Builds the C source code """ global RELEASE amalgamate(CORE_FILES + ['code-experiments/src/profiler/IOHprofiler_runtime_c.c'], 'code-experiments/build/c/IOHprofiler.c', RELEASE, {"IOHprofiler_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/profiler/IOHprofiler.h', 'code-experiments/build/c/profiler/IOHprofiler.h', {"IOHprofiler_VERSION": git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") if 11 < 3: python('code-experiments/build/c', ['make.py', 'clean'], verbose=_verbosity) python('code-experiments/build/c', ['make.py', 'all'], verbose=_verbosity) else: make("code-experiments/build/c", "clean", verbose=_verbosity) make("code-experiments/build/c", "all", verbose=_verbosity)
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_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_c(): """ Builds the C source code """ global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/c/coco.c', release, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-experiments/build/c/coco.h', {"COCO_VERSION": git_version(pep440=True)}) copy_file('code-experiments/build/c/coco.c', 'code-experiments/examples/bbob2009-c-cmaes/coco.c') expand_file('code-experiments/build/c/coco.h', 'code-experiments/examples/bbob2009-c-cmaes/coco.h', {'COCO_VERSION': git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") if 11 < 3: python('code-experiments/build/c', ['make.py', 'clean'], verbose=verbosity) python('code-experiments/build/c', ['make.py', 'all'], verbose=verbosity) else: make("code-experiments/build/c", "clean", verbose=verbosity) make("code-experiments/build/c", "all", verbose=verbosity)
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 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) copy_file('code-experiments/src/coco.h', 'code-experiments/build/java/coco.h') 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']) run('code-experiments/build/java', ['javah', 'CocoJNI']) # 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']) # 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']) # 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']) # 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']) run('code-experiments/build/java', ['gcc', '-I', jdkpath1, '-I', jdkpath2, '-o', 'libCocoJNI.so', '-fPIC', '-shared', 'CocoJNI.c']) # 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']) run('code-experiments/build/java', ['gcc', '-dynamiclib', '-o', 'libCocoJNI.jnilib', 'CocoJNI.o']) run('code-experiments/build/java', ['javac', 'Problem.java']) run('code-experiments/build/java', ['javac', 'Benchmark.java']) run('code-experiments/build/java', ['javac', 'Observer.java']) run('code-experiments/build/java', ['javac', 'Suite.java']) run('code-experiments/build/java', ['javac', 'ExampleExperiment.java'])
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)