1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
# Copyright (c) 1997-2024
# Ewgenij Gawrilow, Michael Joswig, and the polymake team
# Technische Universität Berlin, Germany
# https://polymake.org
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#-------------------------------------------------------------------------------
use strict;
use utf8;
use IO::Handle;
require Config;
require Cwd;
require File::Path;
########################################################################
#
# Load the foundations of polymake/perl language extension.
#
use Polymake::Namespaces;
package Polymake::RefHash;
use Polymake::Ext;
package Polymake;
use Polymake::Ext;
*UNIVERSAL::can=\&Polymake::can;
########################################################################
#
# Import fast JSON conversion functions directly
#
require JSON;
*encode_json = \&JSON::XS::encode_json;
*write_json = \&JSON::XS::write_json;
*decode_json = \&JSON::XS::decode_json;
########################################################################
#
# Global variables
#
declare $Version = "4.14";
declare $VersionNumber = eval "v$Version"; # for string comparisons with vM.N literals
declare ($Scope, # Scope object for the current cycle
$PrivateDir, # where the user's private settings, wrappers, etc. dwell
$Settings, # user's preferences, custom variables, auto-configuration
);
declare $Shell = new NoShell; # alternatively: Shell object listening to the console or some pipe
# resources for third-party programs launched by polymake
declare $Resources = $ENV{POLYMAKE_RESOURCE_DIR} // "$InstallTop/resources";
declare $mainURL = "https://polymake.org";
########################################################################
#
# Load the core modules in proper order.
#
require 'Polymake/utils.pl';
require Polymake::Interrupts;
require Polymake::Scope;
require Polymake::Pipe;
require Polymake::Tempfile;
require Polymake::TempTextFile;
require Polymake::Tempdir;
require Polymake::TempChangeDir;
require Polymake::OverwriteFile;
require Polymake::Overload;
require Polymake::Schema;
require Polymake::Core::UserSettings;
require Polymake::Core::Preference;
require Polymake::Core::Help;
require Polymake::User;
require Polymake::Core::PropertyType;
require Polymake::Core::Property;
require Polymake::Core::Permutation;
require Polymake::Core::PropertyValue;
require Polymake::Core::Rule;
require Polymake::Core::BigObjectType;
require Polymake::Core::Scheduler;
require Polymake::Core::Serializer;
require Polymake::Core::BigObject;
require Polymake::Core::Datafile;
require Polymake::Core::Application;
require Polymake::Core::Extension;
require Polymake::Core::CPlusPlus;
require Polymake::Core::StoredScript;
require Polymake::Core::RuleFilter;
package Polymake::Core;
declare $Prefs = new Preference;
declare $enable_plausibility_checks = true;
my @settings_callbacks;
sub add_settings_callback {
push @settings_callbacks, @_;
}
########################################################################
#
# The banner resides here to be available for the callable library and
# the polymake shell.
#
package Polymake::Main;
# is set to true when a user script is executed directly from the command line, without interactive shell
declare $standalone_script = false;
sub greeting {
my $verbose = $_[0] // 2;
my $full_version="$Version";
if ($DeveloperMode && -d "$InstallTop/.git") {
my $branch = `cd '$InstallTop'; git rev-parse --abbrev-ref HEAD`;
chomp $branch;
$full_version .= ", branch $branch ";
my $upstream = `cd '$InstallTop'; git rev-parse --abbrev-ref --symbolic-full-name \@{u} 2>&1`;
chomp $upstream;
unless ($?) {
my ($ahead,$behind) = split '\t',`cd '$InstallTop'; git rev-list --left-right --count $branch...$upstream`;
chomp $ahead;
chomp $behind;
$full_version .= "[";
$full_version .= "$ahead ahead " if ($ahead > 0);
$full_version .= "$behind behind " if ($behind > 0);
$full_version .= "$upstream]";
}
}
my @messages = ("polymake version $full_version", <<'.' . $mainURL . "\n", <<'.');
Copyright (c) 1997-2024
Ewgenij Gawrilow, Michael Joswig, and the polymake team
Technische Universität Berlin, Germany
.
This is free software licensed under GPL; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.
return join '', @messages[0 .. $verbose];
}
# initialize some modules in proper order
# "config path" =>
sub init {
$Settings = Core::UserSettings::init(@_);
$_->($Settings) for @settings_callbacks;
@settings_callbacks = ();
Core::Extension::init();
Core::CPlusPlus::init();
}
########################################################################
#
# Dummy object to fill the $Shell variable in non-interactive scenarios
#
package Polymake::NoShell;
sub new { bless \(my $dummy) }
sub interactive { 0 }
1
# Local Variables:
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|