diff --git a/src/chsrc-main.c b/src/chsrc-main.c index 2bf97cf..506cd2c 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -65,6 +65,11 @@ #include "recipe/lang/JavaScript/Bun.c" #include "recipe/lang/JavaScript/nvm.c" +#include "recipe/lang/Perl.c" +#include "recipe/lang/PHP.c" +#include "recipe/lang/Lua.c" +#include "recipe/lang/Go.c" +#include "recipe/lang/Java.c" diff --git a/src/framework/struct.h b/src/framework/struct.h index c39ab94..6851d0c 100644 --- a/src/framework/struct.h +++ b/src/framework/struct.h @@ -170,6 +170,7 @@ TargetRegisterInfo_t; /* 以下宏仅能放在 prelude() 中使用 */ #define use_this(t) Target_t *this = &t##_target; +#define use_this_source(t) use_this(t); Source_t source = chsrc_yield_source_and_confirm (this, option); #define def_sources_begin() SourceProvider_t upstream = UpstreamProvider; Source_t sources[] = { #define def_sources_end() }; \ diff --git a/src/recipe/lang/Clojure.c b/src/recipe/lang/Clojure.c index 79b4436..4ec7825 100644 --- a/src/recipe/lang/Clojure.c +++ b/src/recipe/lang/Clojure.c @@ -38,7 +38,7 @@ pl_clojure_prelude () void pl_clojure_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_clojure); + use_this_source(pl_clojure); if (chsrc_in_local_mode()) { diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index c3959dc..65e05b2 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -4,16 +4,16 @@ static MirrorSite_t GoProxyCN = { + IS_DedicatedMirrorSite, "goproxy.cn", "Goproxy.cn", "Goproxy.cn (七牛云)", "https://goproxy.cn/", - "https://goproxy.cn/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", // 30 MB - ACCURATE + {NotSkip, NA, NA, "https://goproxy.cn/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB }, GoProxyIO = { + IS_DedicatedMirrorSite, "goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/", - "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", // 30 MB - ACCURATE + {NotSkip, NA, NA, "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB }; def_target(pl_go); @@ -84,7 +84,7 @@ pl_go_setsrc (char *option) { pl_go_check_cmd (); - chsrc_yield_source_and_confirm (pl_go); + use_this_source(pl_go); char *cmd = "go env -w GO111MODULE=on"; chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index fe4414f..6505b78 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -41,7 +41,7 @@ pl_haskell_prelude () void pl_haskell_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_haskell); + use_this_source(pl_haskell); char *content = xy_str_gsub (RAWSTR_pl_haskell_cabal_config, "@url@", source.url); diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 2f16cdb..6562b0e 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -80,7 +80,7 @@ pl_java_setsrc (char *option) bool maven_exist, gradle_exist; pl_java_check_cmd (&maven_exist, &gradle_exist); - chsrc_yield_source_and_confirm (pl_java); + use_this_source(pl_java); if (maven_exist) { diff --git a/src/recipe/lang/JavaScript/nvm.c b/src/recipe/lang/JavaScript/nvm.c index cc268cd..c5040d1 100644 --- a/src/recipe/lang/JavaScript/nvm.c +++ b/src/recipe/lang/JavaScript/nvm.c @@ -48,7 +48,7 @@ pl_js_nvm_getsrc (char *option) void pl_js_nvm_setsrc (char *option) { - Source_t source = chsrc_yield_source_and_confirm (&pl_js_nodejs_binary_target); + Source_t source = chsrc_yield_source_and_confirm (&pl_js_nodejs_binary_target, option); char *w = xy_strjoin (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n"); diff --git a/src/recipe/lang/Julia.c b/src/recipe/lang/Julia.c index 1946d07..ee71479 100644 --- a/src/recipe/lang/Julia.c +++ b/src/recipe/lang/Julia.c @@ -56,7 +56,7 @@ pl_julia_getsrc (char *option) void pl_julia_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_julia); + use_this_source(pl_julia); char *w = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\""); diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index cf75aeb..e2351b8 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -4,9 +4,9 @@ static MirrorSite_t Api7 = { + IS_DedicatedMirrorSite, "api7", "api7.ai", "深圳支流科技有限公司", "https://www.apiseven.com/", - NULL, // no measure URL - ROUGH + {SKIP, ToFill, ToFill, NULL, ROUGH} }; def_target(pl_lua); @@ -30,8 +30,6 @@ pl_lua_prelude () chef_forbid_english(this); chef_allow_user_define(this); - chef_set_note ("目前只有一个源", NULL); - def_sources_begin() {&upstream, NULL, DelegateToUpstream}, {&Api7, "https://luarocks.cn", DelegateToMirror} @@ -52,7 +50,8 @@ pl_lua_getsrc (char *option) void pl_lua_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_lua); + use_this(pl_lua); + Source_t source = chsrc_yield_source_and_confirm (this, option); char *config = xy_strjoin (3, "rocks_servers = {\n" " \"", source.url, "\"\n" diff --git a/src/recipe/lang/OCaml.c b/src/recipe/lang/OCaml.c index a36ac0b..f89f656 100644 --- a/src/recipe/lang/OCaml.c +++ b/src/recipe/lang/OCaml.c @@ -53,7 +53,7 @@ pl_ocaml_setsrc (char *option) { pl_ocaml_check_cmd (); - chsrc_yield_source_and_confirm (pl_ocaml); + use_this_source(pl_ocaml); char *cmd = xy_strjoin (3, "opam repo set-url default ", source.url, diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index 3e322cc..1eb99e9 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -19,7 +19,7 @@ pl_php_prelude () chef_set_sous_chefs (this, 0); chef_set_contributors (this, 0); - chef_allow_local_mode (this, Can, NULL, NULL); + chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_forbid_english(this); chef_allow_user_define(this); @@ -57,7 +57,8 @@ pl_php_setsrc (char *option) { pl_php_check_cmd (); - chsrc_yield_source_and_confirm (pl_php); + use_this(pl_php); + Source_t source = chsrc_yield_source_and_confirm (this, option); char *where = " -g "; if (chsrc_in_local_mode()) diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index ff294f2..7558301 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -59,7 +59,7 @@ pl_perl_getsrc (char *option) void pl_perl_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_perl); + use_this_source(pl_perl); char *cmd = xy_strjoin (3, "perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\""); diff --git a/src/recipe/lang/Ruby/Ruby.c b/src/recipe/lang/Ruby/Ruby.c index e089814..725ec73 100644 --- a/src/recipe/lang/Ruby/Ruby.c +++ b/src/recipe/lang/Ruby/Ruby.c @@ -72,8 +72,7 @@ pl_ruby_setsrc (char *option) { chsrc_ensure_program ("gem"); - use_this(pl_ruby); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(pl_ruby); char *cmd = NULL; diff --git a/src/recipe/lang/Rust/Cargo.c b/src/recipe/lang/Rust/Cargo.c index 587735c..42c83b3 100644 --- a/src/recipe/lang/Rust/Cargo.c +++ b/src/recipe/lang/Rust/Cargo.c @@ -70,7 +70,7 @@ pl_rust_cargo_getsrc (char *option) void pl_rust_cargo_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_rust_cargo); + use_this_source(pl_rust_cargo); char *content = RAWSTR_pl_rust_cargo_config; diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 68613ad..2b00cff 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -60,7 +60,7 @@ pl_rust_rustup_getsrc (char *option) void pl_rust_rustup_setsrc (char *option) { - chsrc_yield_source_and_confirm (pl_rust_rustup); + use_this_source(pl_rust_rustup); #ifdef XY_On_Windows