Created
April 13, 2012 10:07
-
-
Save ymotongpoo/2375548 to your computer and use it in GitHub Desktop.
Pavement for building dmd, druntime and phobos from trunk. Original version is written by repeatedly in rake style. see 329850
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from paver.easy import * | |
| import os | |
| import os.path | |
| import subprocess | |
| def run_git(dirname): | |
| print "git update %s" % dirname | |
| sh("git pull ") | |
| def which(target): | |
| cmd = ['which'] | |
| cmd.append(target) | |
| stdout = subprocess.check_output(cmd) | |
| return stdout.split('\n')[0] | |
| PLATFORM = os.name | |
| ROOT_DIR = os.getcwd() | |
| DMD_BIN_PATH = os.getenv('DMD_PATH', '/opt/d/bin') | |
| DMD_SRC_PATH = os.path.join(os.path.dirname(DMD_BIN_PATH), 'src') | |
| PROJECT_MAP = { | |
| 'dmd': os.path.join('dmd', 'src'), | |
| 'druntime': "druntime", | |
| 'phobos': "phobos" | |
| } | |
| @task | |
| def all(): | |
| for f in [clean, build]: | |
| os.chdir(ROOT_DIR) | |
| f() | |
| print "All task finished" | |
| @task | |
| def build(): | |
| for f in [fetch, dmd, druntime, phobos]: | |
| os.chdir(ROOT_DIR) | |
| f() | |
| print "Complete building!" | |
| @task | |
| def dmd(): | |
| os.chdir(os.path.join(ROOT_DIR, PROJECT_MAP['dmd'])) | |
| sh("make -f %s.mak dmd" % PLATFORM) | |
| sh("cp -f dmd %s" % DMD_BIN_PATH) | |
| sh("cp -rf ../src %s" % DMD_SRC_PATH) | |
| print "Successfully built dmd compiler" | |
| @task | |
| def druntime(): | |
| """Build druntime""" | |
| os.chdir(os.path.join(ROOT_DIR,PROJECT_MAP['druntime'])) | |
| sh("make DMD=../dmd/src/dmd -f %s.mak" % PLATFORM) | |
| sh("cp -rf ../druntime %s" % DMD_SRC_PATH) | |
| sh("cp -rf ../druntime ../phobos") | |
| print "Successfully built druntime" | |
| @task | |
| def phobos(): | |
| """Build phobos""" | |
| os.chdir(os.path.join(ROOT_DIR, PROJECT_MAP['phobos'])) | |
| sh("make -f %s.mak" % PLATFORM) | |
| lib_dir = os.path.join(os.path.dirname(DMD_BIN_PATH), 'lib') | |
| if os.path.exists(lib_dir): | |
| os.mkdir(lib_dir) | |
| sh("cp -f generated/osx/release/32/libphobos2.a %s" % lib_dir) | |
| sh("cp -rf ../phobos %s" % DMD_SRC_PATH) | |
| print "Successfully built Phobos" | |
| @task | |
| def fetch(): | |
| """Fetch some projects for building""" | |
| for project in PROJECT_MAP.keys(): | |
| project_dir = os.path.join(ROOT_DIR, project) | |
| if os.path.exists(project_dir): | |
| os.chdir(project_dir) | |
| run_git(project_dir) | |
| os.chdir(ROOT_DIR) | |
| else: | |
| sh("git clone git@github.com:D-Programming-Language/%s.git" % project) | |
| print "Successfully fetched %s" % ' '.join(PROJECT_MAP.keys()) | |
| @task | |
| def clean(): | |
| """Clean up previous garbage""" | |
| dirs = [d for d in PROJECT_MAP.keys()] | |
| sh("rm -rf %s" % dirs.join(' ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment