Просмотр исходного кода

build: generate docs per profile

Zaiming (Stone) Shi 3 лет назад
Родитель
Сommit
ab4b3dd60a
3 измененных файлов с 17 добавлено и 10 удалено
  1. 8 7
      build
  2. 4 2
      mix.exs
  3. 5 1
      rebar.config.erl

+ 8 - 7
build

@@ -92,7 +92,7 @@ log() {
 }
 
 make_docs() {
-    local libs_dir1 libs_dir2 libs_dir3
+    local libs_dir1 libs_dir2 libs_dir3 docdir dashboard_www_static
     libs_dir1="$("$FIND" "_build/$PROFILE/lib/" -maxdepth 2 -name ebin -type d)"
     if [ -d "_build/default/lib/" ]; then
         libs_dir2="$("$FIND" "_build/default/lib/" -maxdepth 2 -name ebin -type d)"
@@ -112,15 +112,16 @@ make_docs() {
             SCHEMA_MODULE='emqx_conf_schema'
             ;;
     esac
-    mkdir -p _build/docgen apps/emqx_dashboard/priv/www/static/
+    docdir="_build/docgen/$PROFILE"
+    dashboard_www_static='apps/emqx_dashboard/priv/www/static/'
+    mkdir -p "$docdir" "$dashboard_www_static"
     # shellcheck disable=SC2086
     erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \
-        "Dir = filename:join(['_build', docgen]), \
-         I18nFile = filename:join([apps, emqx_dashboard, priv, 'i18n.conf']), \
-         ok = emqx_conf:dump_schema(Dir, $SCHEMA_MODULE, I18nFile), \
+        "I18nFile = filename:join([apps, emqx_dashboard, priv, 'i18n.conf']), \
+         ok = emqx_conf:dump_schema('$docdir', $SCHEMA_MODULE, I18nFile), \
          halt(0)."
-    cp _build/docgen/bridge-api-*.json apps/emqx_dashboard/priv/www/static/
-    cp _build/docgen/hot-config-schema-*.json apps/emqx_dashboard/priv/www/static/
+    cp "$docdir"/bridge-api-*.json "$dashboard_www_static"
+    cp "$docdir"/hot-config-schema-*.json "$dashboard_www_static"
 }
 
 assert_no_compile_time_only_deps() {

+ 4 - 2
mix.exs

@@ -373,9 +373,11 @@ defmodule EMQXUmbrella.MixProject do
       Path.join(etc, "certs")
     )
 
+    profile = System.get_env("MIX_ENV")
+
     Mix.Generator.copy_file(
-      "apps/emqx_dashboard/etc/emqx.conf.en.example",
-      Path.join(etc, "emqx-example.conf"),
+      "_build/docgen/#{profile}/emqx.conf.en.example",
+      Path.join(etc, "emqx.conf.example"),
       force: overwrite?
     )
 

+ 5 - 1
rebar.config.erl

@@ -462,7 +462,8 @@ etc_overlay(ReleaseType, Edition) ->
     [
         {mkdir, "etc/"},
         {copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"},
-        {copy, "_build/docgen/emqx.conf.en.example", "etc/emqx.conf.example"}
+        {copy, "_build/docgen/" ++ name(Edition) ++ "/emqx.conf.en.example",
+            "etc/emqx.conf.example"}
     ] ++
         lists:map(
             fun
@@ -598,3 +599,6 @@ list_dir(Dir) ->
         false ->
             []
     end.
+
+name(ce) -> "emqx";
+name(ee) -> "emqx-enterprise".