From: dsc Date: Sun, 9 Jan 2011 05:22:02 +0000 (-0800) Subject: Moves logic that was in the deploy script into the build script. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=bc93948ee98042db9159e72c5bef340252d94174;p=tanks.git Moves logic that was in the deploy script into the build script. --- diff --git a/.gitignore b/.gitignore index 0afc988..dd91076 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ tmp/ build/ .commonjs *.md.html -*.pyc -www/versioned-deps.html +*.py[co] google74dcf785afbc60e0.html +deps.html +versioned-deps.html +versioned-build.html + diff --git a/bin/deploy.sh b/bin/deploy.sh index 11fd870..9ea6ba2 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -29,7 +29,6 @@ Options: -v Verbose -n Dry-run -C Clean before rebuilding - -G Only emit the deploy version (Git commit abbreviation: $GIT_VERSION) HALP } @@ -47,17 +46,11 @@ while getopts ":vnCG" opt; do v ) VERBOSE="-v"; incshift ;; n ) DRY_RUN="--dry-run"; incshift ;; C ) CLEAN="--clean"; incshift ;; - G ) GIT_VERSION_ONLY=1; incshift ;; * ) fail "Unknown option: $OPTARG" ;; esac done shift $SHIFT -if test "$GIT_VERSION_ONLY"; then - echo "$GIT_VERSION" - exit -fi - cat <<-SWEET_ART .__ __, ,/__\=: The Littlest Deployer of Battletanks :=/__\. @@ -81,8 +74,6 @@ fi printf "Building and generating dep-graph...\t" paver -q build || fail "Error building modules!" -echo "" > www/versioned-deps.html -sed -E 's|src="build/([^"]+)"|src="build/'$GIT_VERSION'/\1"|' www/deps.html >> www/versioned-deps.html echo "hokay" printf "Uploading files...\t\t\t" diff --git a/pavement.py b/pavement.py index c8acb1a..f9866ca 100755 --- a/pavement.py +++ b/pavement.py @@ -5,6 +5,8 @@ import yaml, json, os, sys BUILD_DIR = path('build') SRC_DIRS = [ path('src')/d for d in ('Y', 'ezl', 'tanks') ] DATA_DIR = path('data') +TAGS = None +GIT_VERSION = sh("git show --oneline . | head -n1 | cut -d ' ' -f 1", capture=True).strip() def commonjs(*args, **kw): @@ -19,10 +21,18 @@ def commonjs(*args, **kw): if v is not True: kwargs.append(str(v)) return sh('commonjs %s' % ' '.join( SRC_DIRS + kwargs + list(args)), capture=capture) +def sourceTags(tags=None): + global TAGS + if tags is not None: + TAGS = tags + elif TAGS is None: + with path('build/deps.html').open('rU') as f: + TAGS = f.read() + return TAGS @task def build_data(): - "Convert all yaml files to json" + "Converts all data files and core injects config." info('Building data files...') for dirpath, dirs, files in os.walk(DATA_DIR): indir = path(dirpath) @@ -47,25 +57,41 @@ def build_data(): @task def build_scripts(): - "Builds js modules" + "Builds js modules." info('Building scripts...') sh('rm build/tanks/config.js') - tags = commonjs(script_tags=True, capture=True) - with path('www/deps.html').open('w') as f: + tags = sourceTags( commonjs(script_tags=True, capture=True) ) + with path('build/deps.html').open('w') as f: f.write(tags) @task +def update_version(): + "Updates dependency file and build version file." + tags = sourceTags() + info('Build Version: {}'.format(GIT_VERSION)) + with path('build/versioned-deps.html').open('w') as f: + f.write(tags.replace('src="build/', 'src="build/{}/'.format(GIT_VERSION))) + with path('build/versioned-build.html').open('w') as f: + f.write('\n'.format(GIT_VERSION)) + +@task +def build_version(): + "Displays build version only (use -q to suppress paver garbage)." + print GIT_VERSION + +@task +@needs('update_version') @needs('build_data') @needs('build_scripts') def build(): "Builds the Tanks project" pass - @task def clean(): "Cleans dep cache and build files" commonjs(clean=True) build() + default = build diff --git a/www/build.html b/www/build.html new file mode 100644 index 0000000..ddd91cf --- /dev/null +++ b/www/build.html @@ -0,0 +1 @@ + diff --git a/www/deps.html b/www/deps.html deleted file mode 100644 index 817a88d..0000000 --- a/www/deps.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/scripts.html b/www/scripts.html index a09ca20..d71deaf 100644 --- a/www/scripts.html +++ b/www/scripts.html @@ -1,4 +1,5 @@
- + +
diff --git a/www/scripts.php b/www/scripts.php index a7e0016..4355a6f 100644 --- a/www/scripts.php +++ b/www/scripts.php @@ -5,8 +5,9 @@ require "commonjs.php"; $errors = commonjs('src/{Y,ezl,tanks}'); if ($errors) echo "
$errors
"; -// Precompiled dependency list -require "deps.html"; +// Compiled dependency list +require "build.html"; +require "build/deps.html"; ?> \ No newline at end of file