Permalink
Browse files

Merge branch 'master' of github.com:clojure/clojurescript into ext-rdr

  • Loading branch information...
2 parents 7516411 + 1028ca1 commit 8106d2521f850b9f9d9acc267fc322123ea8e853 @fogus fogus committed Feb 3, 2012
Showing with 335 additions and 15 deletions.
  1. +77 −0 pom.template.xml
  2. +59 −0 script/build
  3. +55 −10 src/clj/cljs/closure.clj
  4. +1 −3 src/clj/cljs/core.clj
  5. +1 −1 src/cljs/cljs/core.cljs
  6. +142 −1 test/cljs/cljs/core_test.cljs
View
@@ -0,0 +1,77 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.clojure</groupId>
+ <artifactId>clojurescript</artifactId>
+ <!-- Version number will be replaced by script/build -->
+ <version>CLOJURESCRIPT_VERSION</version>
+ <packaging>jar</packaging>
+ <name>ClojureScript</name>
+
+ <url>https://github.com/clojure/clojurescript</url>
+
+ <description>
+ ClojureScript compiler and core runtime library.
+ </description>
+
+ <licenses>
+ <license>
+ <name>Eclipse Public License 1.0</name>
+ <url>http://opensource.org/licenses/eclipse-1.0.php</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>r1592</version>
+ </dependency>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>google-closure-library</artifactId>
+ <version>0.0-790</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mozilla</groupId>
+ <artifactId>rhino</artifactId>
+ <version>1.7R3</version>
+ </dependency>
+ </dependencies>
+
+ <developers>
+ <developer><id>abedra</id><name>Aaron Bedra</name></developer>
+ <developer><id>alandipert</id><name>Alan Dipert</name></developer>
+ <developer><id>amalloy</id><name>Alan Malloy</name></developer>
+ <developer><id>aredington</id><name>Alex Redington</name></developer>
+ <developer><id>billdozr</id><name>Alen Ribic</name></developer>
+ <developer><id>bobby</id><name>Bobby Calderwood</name></developer>
+ <developer><id>brentonashworth</id><name>Brenton Ashworth</name></developer>
+ <developer><id>Chouser</id><name>Chris Houser</name></developer>
+ <developer><id>devn</id><name>Devin Walters</name></developer>
+ <developer><id>ffailla</id><name>Frank Failla</name></developer>
+ <developer><id>fogus</id><name>Fogus</name></developer>
+ <developer><id>hozumi</id><name>Takahiro Hozumi</name></developer>
+ <developer><id>hugoduncan</id><name>Hugo Duncan</name></developer>
+ <developer><id>jessmartin</id><name>Jess Martin</name></developer>
+ <developer><id>jli</id><name>John Li</name></developer>
+ <developer><id>juergenhoetzel</id><name>Jürgen Hötzel</name></developer>
+ <developer><id>levand</id><name>Luke VanderHart</name></developer>
+ <developer><id>lynaghk</id><name>Kevin Lynagh</name></developer>
+ <developer><id>michalmarczyk</id><name>Micha Marczyk</name></developer>
+ <developer><id>pmbauer</id><name>Paul Michael Bauer</name></developer>
+ <developer><id>redinger</id><name>Christopher</name></developer>
+ <developer><id>richhickey</id><name>Rich Hickey</name></developer>
+ <developer><id>stuarthalloway</id><name>Stuart Halloway</name></developer>
+ <developer><id>stuartsierra</id><name>Stuart Sierra</name></developer>
+ <developer><id>swannodette</id><name>David Nolen</name></developer>
+ <developer><id>thickey</id><name>Tom Hickey</name></developer>
+ <developer><id>wilkes</id><name>Wilkes Joiner</name></developer>
+ </developers>
+
+ <scm>
+ <connection>scm:git:git://github.com/clojure/clojurescript.git</connection>
+ <developerConnection>scm:git:git@github.com:clojure/clojurescript.git</developerConnection>
+ <url>https://github.com/clojure/clojurescript</url>
+ </scm>
+</project>
View
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+
+# This script must be run within the ClojureScript top-level project
+# directory.
+
+set -ex
+
+cd `dirname $0`/..
+
+DATE=`date '+%Y%m%d%H%M%S'`
+WORKING="clojurescript_release_$DATE"
+mkdir "$WORKING"
+
+POM_TEMPLATE="pom.template.xml"
+
+# The command `git describe --match v0.0` will return a string like
+#
+# v0.0-856-g329708b
+#
+# where 856 is the number of commits since the v0.0 tag. It will always
+# find the v0.0 tag and will always return the total number of commits (even
+# if the tag is v0.0.1).
+REVISION=`git describe --match v0.0`
+
+# Extract the version number from the string. Do this in two steps so
+# it is a little easier to understand.
+REVISION=${REVISION:5} # drop the first 5 characters
+REVISION=${REVISION:0:${#REVISION}-9} # drop the last 9 characters
+
+TAG=r$REVISION
+
+POM_FILE="$WORKING/clojurescript-0.0-$REVISION.pom"
+JAR_FILE="$WORKING/clojurescript-0.0-$REVISION.jar"
+
+
+# `jar cf` errors on duplicate entries,
+# so we have to assemble the directory manually
+mkdir "$WORKING/jar_contents"
+
+cp -R epl-v10.html src/clj/cljs src/cljs/cljs src/cljs/clojure \
+ "$WORKING/jar_contents"
+
+jar cf "$JAR_FILE" -C "$WORKING/jar_contents" .
+
+sed -e s/CLOJURESCRIPT_VERSION/0.0-$REVISION/ < "$POM_TEMPLATE" > "$POM_FILE"
+
+mvn install:install-file -Dfile="$JAR_FILE" -DpomFile="$POM_FILE"
+
+# For Hudson server
+if [ "$HUDSON" == "true" ]; then
+ echo "Creating tag $TAG"
+ git tag -f "$TAG"
+ git push origin "$TAG"
+
+ mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile="$POM_FILE" -Dfile="$JAR_FILE"
+ mvn nexus:staging-close nexus:staging-release -DtargetRepositoryId=releases -Dnexus.promote.autoSelectOverride=true
+else
+ echo "Skipping Maven deployment and Git push because we are not on Hudson."
+fi
View
@@ -94,6 +94,54 @@
(set-options opts compiler-options)
compiler-options)))
+
+
+(defn jar-entry-names* [jar-path]
+ (with-open [z (java.util.zip.ZipFile. jar-path)]
+ (doall (map #(.getName %) (enumeration-seq (.entries z))))))
+
+(def jar-entry-names (memoize jar-entry-names*))
+
+(defn find-js-jar
+ "finds js resources from a given path in a jar file"
+ [jar-path lib-path]
+ (doall
+ (map #(io/resource %)
+ (filter #(do
+ (and
+ (.startsWith % lib-path)
+ (.endsWith % ".js")))
+ (jar-entry-names jar-path)))))
+(declare to-url)
+(defn find-js-fs
+ "finds js resources from a path on the files system"
+ [path]
+ (let [file (io/file path)]
+ (when (.exists file)
+ (map to-url (filter #(.endsWith (.getName %) ".js") (file-seq (io/file path)))))))
+
+
+(defn find-js-classpath [path]
+ "finds all js files on the classpath matching the path provided"
+ (let [process-entry #(if (.endsWith % ".jar")
+ (find-js-jar % path)
+ (find-js-fs (str % "/" path)))
+ cpath-list (let [sysp (System/getProperty "java.class.path" )]
+ (if (.contains sysp ";")
+ (string/split sysp #";")
+ (string/split sysp #":")))]
+ (doall (reduce #(let [p (process-entry %2)]
+ (if p (concat %1 p) %1)) [] cpath-list))))
+
+(defn find-js-resources [path]
+ "finds js resources in a given path on either the file system or
+ the classpath"
+ (let [file (io/file path)]
+ (if (.exists file)
+ (find-js-fs path)
+ (find-js-classpath path))))
+
+
(defn load-externs
"Externs are JavaScript files which contain empty definitions of
functions which will be provided by the envorinment. Any function in
@@ -104,16 +152,14 @@
the default externs should be excluded."
[{:keys [externs use-only-custom-externs target]}]
(letfn [(filter-js [paths]
- (for [p paths f (file-seq (io/file p))
- :when (.endsWith (.toLowerCase (.getName f)) ".js")]
- (.getAbsolutePath f)))
+ (for [p paths u (find-js-resources p)] u))
(add-target [ext]
(if (= :nodejs target)
- (cons (.getFile (io/resource "cljs/nodejs_externs.js"))
+ (cons (io/resource "cljs/nodejs_externs.js")
(or ext []))
ext))
(load-js [ext]
- (map #(js-source-file % (io/input-stream %)) ext))]
+ (map #(js-source-file (.getFile %) (slurp %)) ext))]
(let [js-sources (-> externs filter-js add-target load-js)]
(if use-only-custom-externs
js-sources
@@ -393,7 +439,6 @@
and :url"
[lib-spec]
(merge lib-spec {:foreign true
- :requires nil
:url (find-url (:file lib-spec))}))
(def load-foreign-library (memoize load-foreign-library*))
@@ -403,12 +448,12 @@
containing Javascript files, return a list of maps
containing :provides, :requires, :file and :url."
[path]
- (letfn [(graph-node [f]
- (-> (io/reader f)
+ (letfn [(graph-node [u]
+ (-> (io/reader u)
line-seq
parse-js-ns
- (assoc :file (.getPath f) :url (to-url f))))]
- (let [js-sources (filter #(.endsWith (.getName %) ".js") (file-seq (io/file path)))]
+ (assoc :url u)))]
+ (let [js-sources (find-js-resources path)]
(filter #(seq (:provides %)) (map graph-node js-sources)))))
(def load-library (memoize load-library*))
View
@@ -67,7 +67,6 @@
([x y & more] `(+ (+ ~x ~y) ~@more)))
(defmacro -
- ([] 0)
([x] (list 'js* "(- ~{})" x))
([x y] (list 'js* "(~{} - ~{})" x y))
([x y & more] `(- (- ~x ~y) ~@more)))
@@ -79,8 +78,7 @@
([x y & more] `(* (* ~x ~y) ~@more)))
(defmacro /
- ([] 1)
- ([x] `(/ 1 x))
+ ([x] `(/ 1 ~x))
([x y] (list 'js* "(~{} / ~{})" x y))
([x y & more] `(/ (/ ~x ~y) ~@more)))
View
@@ -835,7 +835,7 @@ reduces them without incurring seq initialization"
"If no denominators are supplied, returns 1/numerator,
else returns numerator divided by all of the denominators."
([x] (/ 1 x))
- ([x y] (/ x y))
+ ([x y] (js* "(~{x} / ~{y})")) ;; FIXME: waiting on cljs.core//
([x y & more] (reduce / (/ x y) more)))
(defn <
Oops, something went wrong.

0 comments on commit 8106d25

Please sign in to comment.