|
| 1 | +(* Copyright (C) 2019 - Authors of BuckleScript |
| 2 | + * |
| 3 | + * This program is free software: you can redistribute it and/or modify |
| 4 | + * it under the terms of the GNU Lesser General Public License as published by |
| 5 | + * the Free Software Foundation, either version 3 of the License, or |
| 6 | + * (at your option) any later version. |
| 7 | + * |
| 8 | + * In addition to the permissions granted to you by the LGPL, you may combine |
| 9 | + * or link a "work that uses the Library" with a publicly distributed version |
| 10 | + * of this file to produce a combined library or application, then distribute |
| 11 | + * that combined work under the terms of your choosing, with no requirement |
| 12 | + * to comply with the obligations normally placed on you by section 4 of the |
| 13 | + * LGPL version 3 (or the corresponding section of a later version of the LGPL |
| 14 | + * should you choose to use a later version). |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU Lesser General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU Lesser General Public License |
| 22 | + * along with this program; if not, write to the Free Software |
| 23 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) |
| 24 | + |
| 25 | +#if BS_NATIVE then |
| 26 | +let cmdline_backend = ref None |
| 27 | + |
| 28 | +(* If cmdline_backend is set we use it, otherwise we use the first entry's backend. *) |
| 29 | +let backend = lazy |
| 30 | + begin match !cmdline_backend with |
| 31 | + | Some cmdline_backend -> cmdline_backend |
| 32 | + | None -> |
| 33 | + let entries = Bsb_config_parse.entries_from_bsconfig Bsb_global_paths.cwd in |
| 34 | + let new_cmdline_backend = begin match entries with |
| 35 | + | [] -> Bsb_config_types.Js |
| 36 | + | (Bsb_config_types.JsTarget _) :: _ -> Bsb_config_types.Js |
| 37 | + | (Bsb_config_types.NativeTarget _) :: _ -> Bsb_config_types.Native |
| 38 | + | (Bsb_config_types.BytecodeTarget _) :: _ -> Bsb_config_types.Bytecode |
| 39 | + end in |
| 40 | + cmdline_backend := Some (new_cmdline_backend); |
| 41 | + new_cmdline_backend |
| 42 | + end |
| 43 | +#else |
| 44 | +let backend = lazy Bsb_config_types.Js |
| 45 | + |
| 46 | +(* No cost of using this variable below when compiled in JS mode. *) |
| 47 | +let cmdline_backend = ref (Some Bsb_config_types.Js) |
| 48 | +#end |
| 49 | + |
| 50 | +let (//) = Ext_path.combine |
| 51 | + |
| 52 | +let lib_artifacts_dir = lazy |
| 53 | + begin match Lazy.force backend with |
| 54 | + | Bsb_config_types.Js -> Bsb_config.lib_bs |
| 55 | + | Bsb_config_types.Native -> Bsb_config.lib_lit // "native" |
| 56 | + | Bsb_config_types.Bytecode -> Bsb_config.lib_lit // "bytecode" |
| 57 | + end |
0 commit comments