Skip to content

Commit 4cbfb57

Browse files
committed
tooling: Import and refactor
1 parent 46e84f6 commit 4cbfb57

15 files changed

+600
-0
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14.7

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.2

.travis.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Adapted from https://raw.githubusercontent.com/kaushalmodi/ox-hugo/master/.travis.yml
2+
language: nix
3+
4+
before_install:
5+
- sudo mkdir -p /etc/nix
6+
- echo "substituters = https://cache.nixos.org/ file://$HOME/nix.store" | sudo tee -a /etc/nix/nix.conf > /dev/null
7+
- echo 'require-sigs = false' | sudo tee -a /etc/nix/nix.conf > /dev/null
8+
9+
install:
10+
- bundle
11+
# We do this conditionally because it saves us some downloading if the
12+
# version is the same.
13+
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
14+
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
15+
else
16+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
17+
fi
18+
- bash miniconda.sh -b -p $HOME/miniconda
19+
- source "$HOME/miniconda/etc/profile.d/conda.sh"
20+
- hash -r
21+
- conda config --set always_yes yes --set changeps1 no
22+
- conda update -q conda
23+
# Useful for debugging any issues with conda
24+
- conda info -a
25+
26+
before_script:
27+
- sudo mkdir -p /etc/nix && echo 'sandbox = true' | sudo tee /etc/nix/nix.conf
28+
29+
script:
30+
- conda env create -f symeapi.yml
31+
- conda activate symeapi
32+
- rake api:mkDocs
33+
34+
before_cache:
35+
- mkdir -p $HOME/nix.store
36+
- nix copy --to file://$HOME/nix.store -f shell.nix buildInputs
37+
38+
cache:
39+
nix: true
40+
directories:
41+
- /home/travis/build/symengine/api-docs/.tmp/
42+
- $HOME/nix.store
43+
44+
deploy:
45+
provider: pages
46+
local_dir: ./public/
47+
skip_cleanup: true
48+
github_token: $GH_TOKEN # Set in the settings page of your repository, as a secure variable
49+
keep_history: true

Gemfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
source 'https://rubygems.org'
2+
gem 'rake', '13.0.1'
3+
gem 'filewatcher', '1.1.1'
4+
gem 'symengine'
5+
6+
group :iruby do
7+
gem 'iruby'
8+
gem 'irb'
9+
gem 'cztop'
10+
# gem 'rbczmq' # Kills irb for a bit
11+
end
12+
13+
group :pry do
14+
gem 'pry'
15+
gem 'pry-doc'
16+
gem 'awesome_print'
17+
end
18+
19+
group :plot do
20+
gem 'gnuplot'
21+
gem 'rubyvis'
22+
gem 'nyaplot'
23+
end

Gemfile.lock

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
awesome_print (1.8.0)
5+
bond (0.5.1)
6+
coderay (1.1.3)
7+
czmq-ffi-gen (0.16.1)
8+
ffi (~> 1.11)
9+
cztop (0.14.1)
10+
czmq-ffi-gen (~> 0.16)
11+
data_uri (0.1.0)
12+
ffi (1.13.1)
13+
filewatcher (1.1.1)
14+
optimist (~> 3.0)
15+
gnuplot (2.6.2)
16+
io-console (0.5.6)
17+
irb (1.2.7)
18+
reline (>= 0.1.5)
19+
iruby (0.4.0)
20+
bond (~> 0.5)
21+
data_uri (~> 0.1)
22+
mimemagic (~> 0.3)
23+
multi_json (~> 1.11)
24+
method_source (1.0.0)
25+
mimemagic (0.3.5)
26+
multi_json (1.15.0)
27+
nyaplot (0.1.6)
28+
optimist (3.0.1)
29+
pry (0.13.1)
30+
coderay (~> 1.1)
31+
method_source (~> 1.0)
32+
pry-doc (1.1.0)
33+
pry (~> 0.11)
34+
yard (~> 0.9.11)
35+
rake (13.0.1)
36+
reline (0.1.6)
37+
io-console (~> 0.5)
38+
rubyvis (0.7.0)
39+
symengine (0.0.2)
40+
yard (0.9.25)
41+
42+
PLATFORMS
43+
ruby
44+
45+
DEPENDENCIES
46+
awesome_print
47+
cztop
48+
filewatcher (= 1.1.1)
49+
gnuplot
50+
irb
51+
iruby
52+
nyaplot
53+
pry
54+
pry-doc
55+
rake (= 13.0.1)
56+
rubyvis
57+
symengine
58+
59+
BUNDLED WITH
60+
1.17.2

Rakefile

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
require "rake"
2+
require "mkmf" # for find_executable
3+
require "fileutils" # Cross Platform
4+
5+
#############
6+
# Variables #
7+
#############
8+
# Common
9+
CWD = File.expand_path(__dir__)
10+
DOXYFILE = "Doxyfile-syme.cfg"
11+
NIXSHELL = File.join(CWD, "shell.nix")
12+
SYMESRC = File.join(CWD, "projects/symengine/symengine")
13+
OUTPUB = File.join(CWD, "public")
14+
# API
15+
BASEAPI = File.join(CWD, "docs/")
16+
SPHINXAPI = File.join(BASEAPI, "Sphinx")
17+
DOXXML = File.join(BASEAPI, "Doxygen/gen_docs/xml")
18+
OUTAPI = File.join(CWD, "public")
19+
DOXLUA = File.join(BASEAPI, "doxyrestConf.lua")
20+
# Coverage
21+
OUTCOV = File.join(OUTAPI, "doc_coverage")
22+
DOCCOV = File.join(OUTAPI, "doc-coverage.info")
23+
24+
# Exception
25+
class RunnerException < StandardError
26+
def initialize(msg = "Undefined runner, supports nix and system (with conda)", exception_type = "custom")
27+
@exception_type = exception_type
28+
super(msg)
29+
end
30+
end
31+
32+
class ExecException < StandardError
33+
def initialize(msg = "Missing an application, typically doxyrest", exception_type = "custom")
34+
@exception_type = exception_type
35+
super(msg)
36+
end
37+
end
38+
39+
#########
40+
# Tasks #
41+
#########
42+
43+
# Genric
44+
task :default => :darkServe
45+
46+
desc "Clean the generated content"
47+
task :clean do
48+
rm_rf "public"
49+
rm_rf "docs/Doxygen/gen_docs"
50+
rm_rf "docs/Sphinx/build"
51+
rm_rf "docs/Sphinx/gen_doxyrest"
52+
end
53+
54+
desc "Serve site with darkhttpd"
55+
task :darkServe, [:port, :runner] do |task, args|
56+
args.with_defaults(:port => "1336", :runner => "system")
57+
if args.runner == "system"
58+
sh "darkhttpd #{OUTAPI} --port #{args.port}"
59+
elsif args.runner == "nix"
60+
sh "nix-shell #{NIXSHELL} --run 'darkhttpd #{OUTAPI} --port #{args.port}'"
61+
else
62+
raise RunnerException.new
63+
end
64+
end
65+
66+
namespace "api" do
67+
desc "Build full API documentation"
68+
task :mkDocs, [:builder, :runner] do |taks, args|
69+
args.with_defaults(:builder => "html", :runner => "system")
70+
Rake::Task["api:mkSphinx"].invoke(args.builder, args.runner)
71+
end
72+
73+
desc "Build doxygen API"
74+
task :mkDoxy, [:runner] do |task, args|
75+
args.with_defaults(:runner => "system")
76+
Dir.chdir(to = File.join(CWD, "docs/Doxygen"))
77+
if args.runner == "system"
78+
system("doxygen", DOXYFILE)
79+
elsif args.runner == "nix"
80+
sh "nix-shell #{NIXSHELL} --run 'doxygen #{DOXYFILE}'"
81+
else
82+
raise RunnerException.new
83+
end
84+
end
85+
86+
desc "Build doxyrest API"
87+
task :mkDoxyRest, [:builder, :runner] => "mkDoxy" do |task, args|
88+
args.with_defaults(:builder => "html", :runner => "system")
89+
Dir.chdir(to = CWD)
90+
if args.runner == "system"
91+
if find_executable "doxyrest"
92+
sh "doxyrest -c #{DOXLUA}"
93+
elsif find_executable "nix"
94+
begin
95+
puts "System has no doxyrest, trying nix"
96+
sh "nix-shell #{NIXSHELL} --run 'doxyrest -c #{DOXLUA}'"
97+
rescue
98+
puts "Falling back to conda"
99+
sh "conda run doxyrest -c #{DOXLUA}"
100+
end
101+
else
102+
raise ExecException.new
103+
end
104+
elsif args.runner == "nix"
105+
begin
106+
puts "System has no doxyrest, trying nix"
107+
sh "nix-shell #{NIXSHELL} --run 'doxyrest -c #{DOXLUA}'"
108+
rescue
109+
puts "Falling back to conda"
110+
sh "conda run doxyrest -c #{DOXLUA}"
111+
end
112+
else
113+
raise RunnerException.new
114+
end
115+
end
116+
117+
desc "Build Sphinx API docs"
118+
task :mkSphinx, [:builder, :runner] => ["mkDoxyRest"] do |task, args|
119+
args.with_defaults(:builder => "html", :runner => "system")
120+
if args.runner == "system"
121+
sh "conda run sphinx-build #{SPHINXAPI} #{OUTAPI} -b #{args.builder}"
122+
elsif args.runner == "nix"
123+
begin
124+
sh "nix-shell #{NIXSHELL} --run 'sphinx-build #{SPHINXAPI} #{OUTAPI} -b #{args.builder}'"
125+
rescue
126+
puts "Handling the case where nix errors out by rescuing with conda"
127+
sh "conda run sphinx-build #{SPHINXAPI} #{OUTAPI} -b #{args.builder}"
128+
end
129+
else
130+
raise RunnerException.new
131+
end
132+
end
133+
134+
desc "Build API Coverage"
135+
task :mkDocCover, [:runner] => ["mkDoxy"] do |task, args|
136+
args.with_defaults(:runner => "system")
137+
if args.runner == "system"
138+
sh "conda run python3 -m coverxygen --xml-dir #{DOXXML} --src-dir #{SYMESRC} --output #{DOCCOV}"
139+
elsif args.runner == "nix"
140+
sh "nix-shell #{NIXSHELL} --run 'python3 -m coverxygen --xml-dir #{DOXXML} --src-dir #{SYMESRC} --output #{DOCCOV}'"
141+
else
142+
raise RunnerException.new
143+
end
144+
end
145+
146+
desc "Build HTML Coverage Report"
147+
task :mkDocCovHTML, [:runner] => ["mkDocCover"] do |t, args|
148+
args.with_defaults(:runner => "system")
149+
if args.runner == "system"
150+
sh "genhtml --no-function-coverage --no-branch-coverage #{DOCCOV} -o #{OUTCOV}"
151+
elsif args.runner == "nix"
152+
sh "nix-shell #{NIXSHELL} --run 'genhtml --no-function-coverage --no-branch-coverage #{DOCCOV} -o #{OUTCOV}'"
153+
else
154+
raise RunnerException.new
155+
end
156+
end
157+
end

nix/pkgs/doxyrest.nix

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ stdenv, fetchgit, cmake, lib, expat, ragelDev, which, lua5, pythonEnv }:
2+
3+
stdenv.mkDerivation rec {
4+
name = "doxyrest";
5+
# Somehow fetchFromGithub was ignoring submodules
6+
src = fetchgit {
7+
url = "https://github.com/vovkos/doxyrest_b";
8+
rev = "3500bc0101c5ebe4921d8cca49b42e209e761971";
9+
sha256 = "1h1r0g9yklgf2f8qv4dw0lnsldpcr5rch14q934fvxqbpjh9b7fn";
10+
fetchSubmodules = true;
11+
};
12+
13+
nativeBuildInputs = [ expat lua5 ragelDev which cmake ];
14+
buildInputs = [ pythonEnv ];
15+
16+
# otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]"
17+
hardeningDisable = [ "format" ];
18+
19+
meta = with stdenv.lib; {
20+
description = "";
21+
longDescription = "";
22+
homepage = "";
23+
license = licenses.mit;
24+
platforms = [ "x86_64-linux" ];
25+
maintainers = [ maintainers.HaoZeke ];
26+
};
27+
}

nix/sources.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"niv": {
3+
"branch": "master",
4+
"description": "Easy dependency management for Nix projects",
5+
"homepage": "https://github.com/nmattia/niv",
6+
"owner": "nmattia",
7+
"repo": "niv",
8+
"rev": "9d35b9e4837ab88517210b1701127612c260eccf",
9+
"sha256": "0q50xhnm8g2yfyakrh0nly4swyygxpi0a8cb9gp65wcakcgvzvdh",
10+
"type": "tarball",
11+
"url": "https://github.com/nmattia/niv/archive/9d35b9e4837ab88517210b1701127612c260eccf.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"nixpkgs": {
15+
"branch": "nixpkgs-unstable",
16+
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
17+
"homepage": "https://github.com/NixOS/nixpkgs",
18+
"owner": "NixOS",
19+
"repo": "nixpkgs-channels",
20+
"rev": "502845c3e31ef3de0e424f3fcb09217df2ce6df6",
21+
"sha256": "0fcqpsy6y7dgn0y0wgpa56gsg0b0p8avlpjrd79fp4mp9bl18nda",
22+
"type": "tarball",
23+
"url": "https://github.com/NixOS/nixpkgs-channels/archive/502845c3e31ef3de0e424f3fcb09217df2ce6df6.tar.gz",
24+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+
}
26+
}

0 commit comments

Comments
 (0)