1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Cleaned up build system

This commit is contained in:
Starbeamrainbowlabs 2015-05-24 16:24:03 +01:00
parent f512958c05
commit bc4533c16c
4 changed files with 17 additions and 55 deletions

View file

@ -1,3 +1,5 @@
@echo off
echo Deleting old index.php
del index.php
php rebuild_module_index.php
php build.php

View file

@ -1,54 +0,0 @@
<?php
$start_time = microtime(true);
function logstr($str, $newline = true, $showtime = true)
{
global $start_time;
if($showtime)
echo("[ " . round(microtime(true) - $start_time, 4) . " ] ");
echo($str);
if($newline)
echo("\n");
}
function removeouterphptags($phpcode)
{
$firstindex = strpos($phpcode, "\n", strpos($phpcode, "<?php"));
$lastindex = strrpos($phpcode, "?>");
return substr($phpcode, $firstindex, $lastindex - $firstindex);
}
header("content-type: text/plain");
// Protects against users wiping the settings if run via CGI
logstr("Checking for existing build....", false);
if(file_exists("index.php"))
{
log_str("fail!", true, false);
log_str("A build already exists in this directory.");
log_str("Please delete it and then run this script again.");
exit();
}
logstr("pass - no other builds were found.", true, false);
logstr("Reading `core.php`...", false);
$build = file_get_contents("core.php");
logstr("done", true, false);
logstr("Reading `settings.fragment.php`...", false);
$settings = removeouterphptags(file_get_contents("settings.fragment.php"));
logstr("done", true, false);
logstr("Building.....", false);
$build = str_replace([
"{settings}"
], [
$settings
], $build);
logstr("done", true, false);
logstr("Writing build....", false);
file_put_contents("index.php", $build);
logstr("done!", true, false);
logstr("*** Build Completed ***");

View file

@ -1,5 +1,11 @@
<?php
if(php_sapi_name() == "cli")
{
echo("Beginning build...\n");
echo("Reading in module index...\n");
}
$module_index = json_decode(file_get_contents("module_index.json"));
$module_list = [];
foreach($module_index as $module)
@ -17,6 +23,8 @@ if(php_sapi_name() != "cli")
header("content-type: text/php");
}
if(php_sapi_name() == "cli") echo("Reading in core files...");
$core = file_get_contents("core.php");
$settings = file_get_contents("settings.fragment.php");
$settings = str_replace([ "<?php", "?>" ], "", $settings);
@ -28,6 +36,8 @@ foreach($module_list as $module_id)
{
if($module_id == "") continue;
if(php_sapi_name() == "cli") echo("Adding $module_id\n");
$module_filepath = "modules/" . preg_replace("[^a-zA-Z0-9\-]", "", $module_id) . ".php";
//echo("id: $module_id | filepath: $module_filepath\n");
@ -50,12 +60,15 @@ if(php_sapi_name() == "cli")
{
if(file_exists("index.php"))
{
echo("index.php already exists, exiting");
echo("index.php already exists, exiting\n");
exit(1);
}
else
{
echo("Done. Saving to disk...");
file_put_contents("index.php", $result);
echo("complete!\n");
echo("*** Build Completed ***\n");
}
}
else

View file

@ -1,4 +1,5 @@
<?php
echo("Rebuilding module index...\n");
$modules = glob("modules/*.php");
$module_index = [];