   (let [f (io/file fpath)]
     (when-let [dir (.getParentFile f)] (.mkdirs dir))))
 
-(defn get-build-options
-  ([build]
+(defn get-build-options [build]
    (or (:build-options build) (:compiler build) {}))
-  ([build key]
-   (get (get-build-options build) key)))
-
-(defn ensure-output-dirs* [{:keys [build-options compiler]}]
-  (let [{:keys [output-to]} (or build-options compiler)]
+
+(defn optimizations-none?
+  "Given a map of compiler options returns true if a build will be
+  compiled in :optimizations :none mode"
+  [{:keys [optimizations]}]
+  (or (nil? optimizations) (= optimizations :none)))
+
+;; TODO compiler probably handles this now
+(defn ensure-output-dirs!
+  "Given a build config ensures the existence of the output directories."
+  [build]
+  (let [{:keys [output-to]} (get-build-options build)]
     (when output-to
-      (mkdirs output-to))))
-
-(defn optimizations-none?
-  "returns true if a build has :optimizations set to :none"
-  [build]
-  (let [opt (get-build-options build :optimizations)]
-    (or (nil? opt) (= :none opt))))
-
-;; checking to see if output dir is in right directory
-(defn norm-path
-  "Normalize paths to a forward slash separator to fix windows paths"
-  [p] (string/replace p  "\\" "/"))
-
-(defn relativize-resource-paths
-  "Relativize to the local root just in case we have an absolute path"
-  [resource-paths]
-  (mapv #(string/replace-first (norm-path (.getCanonicalPath (io/file %)))
-                               (str (norm-path (.getCanonicalPath (io/file ".")))
-                                    "/") "") resource-paths))
-
-(defn make-serve-from-display [{:keys [http-server-root resource-paths] :as opts}]
-  (let [paths (relativize-resource-paths resource-paths)]
-    (str "(" (string/join "|" paths) ")/" http-server-root)))
-
-(defn output-dir-in-resources-root?
-  "Check if the build output directory is in or below any of the configured resources directories."
-  [{:keys [output-dir] :as build-options}
-   {:keys [resource-paths http-server-root] :as opts}]
-  (and output-dir
-       (first (filter (fn [x] (.startsWith output-dir (str x "/" http-server-root)))
-                      (relativize-resource-paths resource-paths)))))
+      (mkdirs output-to))
+    build))
+
+(defn no-seqs
+  "Given a walkable Clojure data structure turns the seqs into
+  vectors. This is mainly used to help get build configurations across
+  the serialization boundary from the lein plugin to the subprocess."
+  [b]
+  (walk/postwalk #(if (seq? %) (vec %) %) b))
+
+;; fixing up the :figwheel client side options
+
+(defn fix-symbol-vals
+  "Given a map found make all symbol values into strings."
+  [mappish]
+  (zipmap (keys mappish)
+          (map #(if (symbol? %) (name %) %) (vals mappish))))
+
+(defn append-build-id
+  "Given a build config forward the build :id to the figwheel client config as a :build-id"
+  [figwheel build-id]
+  (if build-id
+    (assoc figwheel :build-id build-id)
+    figwheel))
+
+(defn forward-devcard-option
+  "Given a build-config has a [:figwheel :devcards] config it make
+  sure that the :build-options has :devcards set to true"
+  [{:keys [figwheel] :as build}]
+  (if (and figwheel (:devcards figwheel))
+    (assoc-in build [:build-options :devcards] true)
+    build))
+
+(defn prep-build-for-figwheel-client
+  "Given a build config that has a :figwheel config in it "
+  [{:keys [id figwheel] :as build}]
+  (if figwheel
+    (assoc build :figwheel
+           (-> (if (map? figwheel) figwheel {})
+               (append-build-id id)
+               fix-symbol-vals))
+    build))
+
+(defn figwheel-build? [{:keys [build-options] :as build}]
+  (and (optimizations-none? build-options)
+       (:figwheel build)))
 
 (defn map-to-vec-builds
   "Cljsbuild allows a builds to be specified as maps. We acommodate that with this function

                  module-map))
    module-map))

(defn opt-none? [{:keys [optimizations]}]
  (or (nil? optimizations) (= optimizations :none)))

;; TODO this is a hack need to check all the places that I'm checking for
;; :optimizations :none and check for nil? or :none
(defn default-optimizations-to-none [build-options]
  (if (opt-none? build-options)
    (assoc build-options :optimizations :none)
    build-options))


(defn prep-builds [builds]
  (-> builds
      map-to-vec-builds
      (->> (mapv prep-build))))

(defn prep-options
  "Normalize various configuration input."
