1
1
#! /bin/bash
2
2
echo Entryponit script is Running...
3
3
4
+ echo Installing emscripten...
5
+
4
6
NGSPICE_HOME=" https://github.com/danchitnis/ngspice-sf-mirror"
5
7
# NGSPICE_HOME="https://git.code.sf.net/p/ngspice/ngspice"
6
8
@@ -13,15 +15,65 @@ cd emsdk
13
15
./emsdk activate latest
14
16
source ./emsdk_env.sh
15
17
18
+ echo emscripten is installed
19
+
20
+ # ###########################################
21
+
16
22
echo -e " \n"
17
- echo -e " installing ngspice...\n "
23
+ echo cloning ngspice repository ...
18
24
19
25
cd /opt
20
-
21
26
git clone $NGSPICE_HOME ngspice-ngspice
22
-
23
27
cd ngspice-ngspice
24
28
29
+ # ###########################################
30
+
31
+ echo -e " \n"
32
+ echo determining the latest release version and branch...
33
+
34
+ # Step 1: Find the latest tag with the version format "ngspice-X.Y"
35
+ latest_tag=$( git tag | grep -E ' ^ngspice-[0-9]+\.[0-9]+$' | sort -V | tail -n 1)
36
+ if [ -z " $latest_tag " ]; then
37
+ echo " No ngspice tags found."
38
+ exit 1
39
+ fi
40
+ latest_version=${latest_tag# ngspice-} # Extract version number (e.g., 44.2)
41
+ echo " Latest tag: $latest_tag (version $latest_version )"
42
+
43
+ # Step 2: Find the branch with a higher version than the latest tag.
44
+ # We assume branch names are in the form "pre-master-X" or "pre-master-X.Y"
45
+ # Extract the version number, sort them, and then pick the first branch with a version > latest_version.
46
+ branch_version=$( git branch -r | \
47
+ grep -Eo ' pre-master-[0-9]+(\.[0-9]+)?' | \
48
+ sed -E ' s/.*pre-master-([0-9]+(\.[0-9]+)?)/\1/' | \
49
+ sort -V | \
50
+ awk -v latest=" $latest_version " ' { if ($1+0 > latest+0) { print $1; exit } }' )
51
+
52
+ if [ -n " $branch_version " ]; then
53
+ echo " Branch with higher version: pre-master-$branch_version "
54
+ else
55
+ echo " No branch found with a version higher than $latest_version "
56
+ exit 1
57
+ fi
58
+
59
+ # ###########################################
60
+
61
+ echo -e " \n"
62
+ echo " Running build requested is: $VERSION "
63
+
64
+ if [ " $VERSION " == " next" ]; then
65
+ echo " Checking out the branch pre-master-$branch_version "
66
+ git checkout pre-master-$branch_version
67
+ else
68
+ echo " Checking out the master branch for version $latest_version "
69
+ fi
70
+
71
+ # ###########################################
72
+
73
+ echo -e " \n"
74
+ echo " Applying patches..."
75
+
76
+
25
77
# https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/
26
78
# https://sourceforge.net/p/ngspice/patches/99/
27
79
sed -i ' s/-Wno-unused-but-set-variable/-Wno-unused-const-variable/g' ./configure.ac
@@ -30,6 +82,11 @@ sed -i 's|#include "ngspice/ngspice.h"|#include <emscripten.h>\n\n#include "ngsp
30
82
sed -i ' s|freewl = wlist = getcommand(string);|emscripten_sleep(100);\n\n\t\tfreewl = wlist = getcommand(string);|g' ./src/frontend/control.c
31
83
32
84
85
+ # ###########################################
86
+
87
+ echo -e " \n"
88
+ echo " Building ngspice..."
89
+
33
90
./autogen.sh
34
91
mkdir release
35
92
cd release
@@ -46,13 +103,19 @@ emmake make -j
46
103
47
104
wait
48
105
106
+ # ###########################################
49
107
108
+ echo -e " \n"
109
+ echo " Copying the build artifacts..."
50
110
51
111
cd src
52
112
mv spice.mjs spice.js
53
113
mkdir -p /mnt/build
54
114
\c p spice.js spice.wasm /mnt/build
55
115
116
+ echo " Build artifacts are copied to /mnt/build"
117
+
118
+ # ###########################################
56
119
57
120
echo -e " \n"
58
121
echo -e " This script is ended\n"
0 commit comments