@@ -50,6 +50,7 @@ class InstallOptions:
5050 # Tools
5151 git_path : str = ''
5252 cmake_path : str = ''
53+ java_path : str = ''
5354
5455 # MrDocs
5556 mrdocs_src_dir : str = field (
@@ -107,6 +108,7 @@ class InstallOptions:
107108INSTALL_OPTION_DESCRIPTIONS = {
108109 "git_path" : "Path to the git executable, if not in system PATH." ,
109110 "cmake_path" : "Path to the cmake executable, if not in system PATH." ,
111+ "java_path" : "Path to the java executable, if not in system PATH." ,
110112 "mrdocs_src_dir" : "MrDocs source directory." ,
111113 "mrdocs_repo" : "URL of the MrDocs repository to clone." ,
112114 "mrdocs_branch" : "Branch or tag of the MrDocs repository to use." ,
@@ -510,7 +512,8 @@ def setup_mrdocs_dir(self):
510512
511513 # MrDocs build type
512514 self .prompt_build_type_option ("mrdocs_build_type" )
513- self .prompt_option ("mrdocs_build_tests" )
515+ if self .prompt_option ("mrdocs_build_tests" ):
516+ self .check_tool ("java" )
514517
515518 def is_inside_mrdocs_dir (self , path ):
516519 """
@@ -962,6 +965,31 @@ def generate_clion_run_configs(self, configs):
962965 for key , value in config ['env' ].items ():
963966 ET .SubElement (envs , "env" , name = key , value = value )
964967 ET .SubElement (clion_config , "method" , v = "2" )
968+ else :
969+ attrib = {
970+ "default" : "false" ,
971+ "name" : config ["name" ],
972+ "type" : "ShConfigurationType"
973+ }
974+ if 'folder' in config :
975+ attrib ["folderName" ] = config ["folder" ]
976+ clion_config = ET .SubElement (root , "configuration" , attrib )
977+ ET .SubElement (clion_config , "option" , name = "SCRIPT_TEXT" , value = f"{ shlex .quote (config ['script' ])} { ' ' .join (shlex .quote (arg ) for arg in config ['args' ])} " )
978+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_SCRIPT_PATH" , value = "true" )
979+ ET .SubElement (clion_config , "option" , name = "SCRIPT_PATH" , value = config ["script" ])
980+ ET .SubElement (clion_config , "option" , name = "SCRIPT_OPTIONS" , value = "" )
981+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_SCRIPT_WORKING_DIRECTORY" , value = "true" )
982+ if 'cwd' in config and config ["cwd" ] != self .options .mrdocs_src_dir :
983+ ET .SubElement (clion_config , "option" , name = "SCRIPT_WORKING_DIRECTORY" , value = config ["cwd" ])
984+ else :
985+ ET .SubElement (clion_config , "option" , name = "SCRIPT_WORKING_DIRECTORY" , value = "$PROJECT_DIR$" )
986+ ET .SubElement (clion_config , "option" , name = "INDEPENDENT_INTERPRETER_PATH" , value = "true" )
987+ ET .SubElement (clion_config , "option" , name = "INTERPRETER_PATH" , value = "" )
988+ ET .SubElement (clion_config , "option" , name = "INTERPRETER_OPTIONS" , value = "" )
989+ ET .SubElement (clion_config , "option" , name = "EXECUTE_IN_TERMINAL" , value = "true" )
990+ ET .SubElement (clion_config , "option" , name = "EXECUTE_SCRIPT_FILE" , value = "false" )
991+ ET .SubElement (clion_config , "envs" )
992+ ET .SubElement (clion_config , "method" , v = "2" )
965993
966994 tree = ET .ElementTree (root )
967995 tree .write (run_config_path , encoding = "utf-8" , xml_declaration = False )
@@ -988,7 +1016,7 @@ def generate_visual_studio_run_configs(self, configs):
9881016 "type" : "default" ,
9891017 "project" : "MrDocs" ,
9901018 "args" : config ["args" ],
991- "cwd" : self .options .mrdocs_build_dir ,
1019+ "cwd" : config . get ( 'cwd' , self .options .mrdocs_build_dir ) ,
9921020 "env" : {},
9931021 "stopAtEntry" : False ,
9941022 "console" : "integratedTerminal"
@@ -1227,6 +1255,57 @@ def generate_run_configs(self):
12271255 "cwd" : mrdocs_website_dir
12281256 })
12291257
1258+ # XML schema tests
1259+ if self .options .java_path :
1260+ configs .append ({
1261+ "name" : "MrDocs Generate RelaxNG Schema" ,
1262+ "script" : self .options .java_path ,
1263+ "args" : [
1264+ "-jar" ,
1265+ os .path .join (self .options .mrdocs_src_dir , "util" , "trang.jar" ),
1266+ os .path .join (self .options .mrdocs_src_dir , "mrdocs.rnc" ),
1267+ os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" )
1268+ ],
1269+ "cwd" : self .options .mrdocs_src_dir
1270+ })
1271+
1272+ libxml2_xmllint_executable = os .path .join (self .options .libxml2_install_dir , "bin" , "xmllint" )
1273+ xml_sources_dir = os .path .join (self .options .mrdocs_src_dir , "test-files" , "golden-tests" )
1274+
1275+ if self .is_windows ():
1276+ xml_sources = []
1277+ for root , _ , files in os .walk (xml_sources_dir ):
1278+ for file in files :
1279+ if file .endswith (".xml" ) and not file .endswith (".bad.xml" ):
1280+ xml_sources .append (os .path .join (root , file ))
1281+ configs .append ({
1282+ "name" : "MrDocs XML Lint with RelaxNG Schema" ,
1283+ "script" : libxml2_xmllint_executable ,
1284+ "args" : [
1285+ "--dropdtd" ,
1286+ "--noout" ,
1287+ "--relaxng" ,
1288+ os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" )
1289+ ].extend (xml_sources ),
1290+ "cwd" : self .options .mrdocs_src_dir
1291+ })
1292+ else :
1293+ configs .append ({
1294+ "name" : "MrDocs XML Lint with RelaxNG Schema" ,
1295+ "script" : "find" ,
1296+ "args" : [
1297+ xml_sources_dir ,
1298+ "-type" , "f" ,
1299+ "-name" , "*.xml" ,
1300+ "!" , "-name" , "*.bad.xml" ,
1301+ "-exec" , libxml2_xmllint_executable ,
1302+ "--dropdtd" , "--noout" ,
1303+ "--relaxng" , os .path .join (self .options .mrdocs_build_dir , "mrdocs.rng" ),
1304+ "{}" , "+"
1305+ ],
1306+ "cwd" : self .options .mrdocs_src_dir
1307+ })
1308+
12301309 print ("Generating CLion run configurations for MrDocs..." )
12311310 self .generate_clion_run_configs (configs )
12321311 print ("Generating Visual Studio run configurations for MrDocs..." )
0 commit comments