From 79e7296b63cc6bab9ef5779895aed3d426a46bbc Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 15 Aug 2024 21:00:08 +0800 Subject: [PATCH] Split ocaml out --- include/source.h | 10 ------- src/chsrc.c | 40 +--------------------------- src/recipe/catalog.c | 2 +- src/recipe/lang/ocaml.c | 58 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 50 deletions(-) create mode 100644 src/recipe/lang/ocaml.c diff --git a/include/source.h b/include/source.h index 1b05c7e..51f1a4f 100644 --- a/include/source.h +++ b/include/source.h @@ -184,15 +184,6 @@ pl_haskell_sources[] = { }, -/** - * @time 2023-09-15 更新 - */ -pl_ocaml_sources[] = { - {&Upstream, NULL}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/git/opam-repository.git"} -}, - - /** @@ -733,7 +724,6 @@ wr_tex_sources[] = { def_sources_n(pl_clojure); def_sources_n(pl_dotnet); def_sources_n(pl_dart); def_sources_n(pl_haskell); -def_sources_n(pl_ocaml); def_sources_n(pl_r); def_sources_n(pl_julia); def_sources_n(os_ubuntu); def_sources_n(os_mint); diff --git a/src/chsrc.c b/src/chsrc.c index a6b4925..046f0cf 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -175,45 +175,7 @@ pl_haskell_setsrc (char *option) } - -void -pl_ocaml_check_cmd () -{ - chsrc_ensure_program ("opam"); -} - -void -pl_ocaml_getsrc(char *option) -{ - pl_ocaml_check_cmd (); - chsrc_run ("opam repo get-url default", RunOpt_Default); -} - -/** - * 参考: https://mirrors.sjtug.sjtu.edu.cn/docs/git/opam-repository.git - */ -void -pl_ocaml_setsrc(char *option) -{ - pl_ocaml_check_cmd (); - - SourceInfo source; - chsrc_yield_source (pl_ocaml); - chsrc_confirm_source (&source); - - char *cmd = xy_strjoin (3, "opam repo set-url default ", - source.url, - " --all --set-default"); - - chsrc_run (cmd, RunOpt_Default); - - chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化"); - puts (xy_2strjoin ("opam init default ", source.url)); - - chsrc_say_lastly (&source, ChsrcTypeSemiAuto); -} - - +#include "recipe/lang/ocaml.c" void pl_r_getsrc (char *option) diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 4cc2940..d4f425e 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -8,7 +8,7 @@ * ------------------------------------------------------------*/ /* Begin Target Matrix */ -def_target(pl_dart); def_target(pl_ocaml); +def_target(pl_dart); def_target(pl_r); def_target(pl_julia); def_target_noget (pl_clojure); def_target_noget (pl_dotnet); diff --git a/src/recipe/lang/ocaml.c b/src/recipe/lang/ocaml.c new file mode 100644 index 0000000..b98b8bb --- /dev/null +++ b/src/recipe/lang/ocaml.c @@ -0,0 +1,58 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created on : <2023-09-15> + * Last modified : <2024-08-15> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-15 更新 + */ +static SourceInfo +pl_ocaml_sources[] = { + {&Upstream, NULL}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/git/opam-repository.git"} +}; +def_sources_n(pl_ocaml); + + +void +pl_ocaml_check_cmd () +{ + chsrc_ensure_program ("opam"); +} + +void +pl_ocaml_getsrc(char *option) +{ + pl_ocaml_check_cmd (); + chsrc_run ("opam repo get-url default", RunOpt_Default); +} + +/** + * 参考: https://mirrors.sjtug.sjtu.edu.cn/docs/git/opam-repository.git + */ +void +pl_ocaml_setsrc(char *option) +{ + pl_ocaml_check_cmd (); + + SourceInfo source; + chsrc_yield_source (pl_ocaml); + chsrc_confirm_source (&source); + + char *cmd = xy_strjoin (3, "opam repo set-url default ", + source.url, + " --all --set-default"); + + chsrc_run (cmd, RunOpt_Default); + + chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化"); + puts (xy_2strjoin ("opam init default ", source.url)); + + chsrc_say_lastly (&source, ChsrcTypeSemiAuto); +} + +def_target(pl_ocaml);