Skip to content

Commit 849a814

Browse files
committed
fixed build and env scripts
1 parent bce836e commit 849a814

3 files changed

Lines changed: 88 additions & 72 deletions

File tree

ci/build.sh

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,68 @@
33
# Purpose: compiles gemc with optional sanitizers or debugging options.
44

55
# Container run:
6-
# docker run -it --rm --platform linux/amd64 ghcr.io/gemc/g4install:11.3.2-archlinux-latest bash -il
6+
# docker run --rm -it ghcr.io/gemc/g4install:11.4.0-fedora-40 bash -li
77
# git clone http://github.com/gemc/src /root/src && cd /root/src
88
# ./ci/build.sh
99

1010
source ci/env.sh
11-
meson_option=$(meson_options $1)
11+
meson_option=$(meson_setup_options $1)
1212

1313
echo " > Geant-config: $(which geant4-config) : $(geant4-config --version)" | tee $setup_log
1414
echo " > Root-config: $(which root-config) : $(root-config --version)" | tee -a $setup_log
15-
echo Meson Options: $meson_option
16-
exit
15+
echo " > Meson Interactive Options: $test_interactive_option"
16+
echo " > Meson Setup Options: $meson_option"
17+
echo " > Using $jobs cores"
18+
echo
19+
1720

18-
# detect cores and cap at 16
19-
cores=$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc)
20-
jobs=$((cores < 16 ? cores : 16))
2121

2222
meson subprojects download yaml-cpp
2323
meson subprojects download assimp
2424
echo " > Applying patch to version 0.8.0" | tee -a $setup_log
2525
meson subprojects update yaml-cpp --reset
2626
echo
27-
echo " > Running meson setup build ${args[@]}" | tee -a $setup_log
28-
meson setup build "meson_option" - >> $setup_log
27+
echo " > Running meson setup build $meson_option" | tee -a $setup_log
28+
meson setup build "$=meson_option" >> $setup_log
2929
if [ $? -ne 0 ]; then
30-
echo "Build Configure failed. Log: "
30+
echo " > Meson Configure failed. Log: "
3131
cat $setup_log
3232
exit 1
3333
else
34-
echo Build Configure Successful
35-
echo
34+
echo " > Meson Configure Successful"
3635
echo
3736
fi
3837

39-
echo " > Running meson install -v -j $cores" | tee $compile_log
40-
meson compile -C build -v -j $jobs >> $compile_log
41-
meson install -C build >> $compile_log
38+
39+
echo " > Running meson compile -C build -v -j $jobs " | tee -a $compile_log
40+
meson compile -C build -v -j $jobs >> $compile_log
4241
if [ $? -ne 0 ]; then
43-
echo "Compile or Install failed. Log: "
42+
echo " > Meson Compile failed. Log: "
4443
cat $compile_log
4544
exit 1
4645
else
47-
echo Compile Successful
46+
echo " > Meson Compile Successful"
4847
echo
48+
fi
49+
50+
echo " > Running meson install -C build " | tee -a $install_log
51+
meson install -C build >> $install_log
52+
if [ $? -ne 0 ]; then
53+
echo " > Meson Install failed. Log: "
54+
cat $install_log
55+
exit 1
56+
else
57+
echo " > Meson Install Successful"
4958
echo
5059
fi
5160

52-
echo " > $GEMC recursive content:" | tee -a $compile_log
53-
ls -lR $GEMC >>$compile_log
61+
show_gemc_installation
5462

5563
# if $1 is NOT one of sanitize option, run meson test
5664
if [[ $1 != @(address|thread|undefined|memory|leak) ]]; then
57-
echo " > Running meson test" | tee $test_log
58-
meson test -C build -j 1 --print-errorlogs --no-rebuild --num-processes 1 >>$test_log
59-
echo Successful: $(cat $test_log | grep "Ok:" | awk '{print $2}')
60-
echo Failures: $(cat $test_log | grep "Fail:" | awk '{print $2}')
61-
fi
62-
63-
echo
64-
echo " ldd of $GEMC/bin/gemc:" | tee -a $compile_log
65-
66-
# if on unix, use ldd , if on mac, use otool -L
67-
if [[ "$(uname)" == "Darwin" ]]; then
68-
otool -L $GEMC/bin/gemc
69-
else
70-
ldd $GEMC/bin/gemc | tee -a $compile_log
65+
echo " > Running meson test with options -C build -j 1 --print-errorlogs --no-rebuild --num-processes 1 " | tee $test_log
66+
meson test -C build -v -j 1 --print-errorlogs --no-rebuild --num-processes 1 >> $test_log
67+
echo " - Successful: $(cat $test_log | grep "Ok:" | awk '{print $2}')"
68+
echo " - Failures: $(cat $test_log | grep "Fail:" | awk '{print $2}')"
69+
echo " > Complete test log: $test_log"
7170
fi

ci/env.sh

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,29 @@ function enable_git_describe {
1111
}
1212

1313
function show_gemc_installation {
14-
echo
15-
echo "- Content of \$GEMC=$GEMC"
16-
ls -lrt $GEMC
1714

18-
echo "- Content of \$GEMC/bin=$GEMC/bin"
19-
ls -lrt $GEMC/bin
15+
echo "- Content of \$GEMC=$GEMC" >> $gemc_install_show
16+
ls -lrt $GEMC >> $gemc_install_show
17+
18+
echo "- Content of \$GEMC/bin=$GEMC/bin" >> $gemc_install_show
19+
ls -lrt $GEMC/bin >> $gemc_install_show
2020

2121
if [ -d $GEMC/lib ]; then
22-
echo "- Content of \$GEMC/lib=$GEMC/lib"
23-
ls -lrt $GEMC/lib
22+
echo "- Content of \$GEMC/lib=$GEMC/lib" >> $gemc_install_show
23+
ls -lrt $GEMC/lib >> $gemc_install_show
2424
fi
25+
26+
echo " ldd of $GEMC/bin/gemc:" >> $gemc_install_show
27+
28+
# if on unix, use ldd , if on mac, use otool -L
29+
if [[ "$(uname)" == "Darwin" ]]; then
30+
otool -L $GEMC/bin/gemc >> $gemc_install_show
31+
else
32+
ldd $GEMC/bin/gemc >> $gemc_install_show
33+
fi
34+
35+
echo " > To check gemc installation: cat $gemc_install_show"
36+
2537
}
2638

2739
function meson_setup_options {
@@ -30,6 +42,7 @@ function meson_setup_options {
3042

3143
meson_options=""
3244
buildtype=" -Dbuildtype=debug "
45+
interactive_option=""
3346

3447
case $1 in
3548
"address")
@@ -60,45 +73,49 @@ function meson_setup_options {
6073
;;
6174
esac
6275

63-
additional_args=(
64-
"--native-file=core.ini"
65-
"-Di_test=true"
66-
"-Droot=enabled"
67-
"-Dprefix=${install_dir}"
68-
"-Dpkg_config_path=$PKG_CONFIG_PATH:${install_dir}/lib/pkgconfig"
69-
)
70-
71-
echo $meson_options $buildtype "${additional_args[@]}"
76+
args=(
77+
$meson_options
78+
$test_interactive_option
79+
"--native-file=core.ini"
80+
"-Droot=enabled"
81+
"-Dprefix=${install_dir}"
82+
"-Dpkg_config_path=$PKG_CONFIG_PATH:${install_dir}/lib/pkgconfig"
83+
$buildtype
84+
)
85+
86+
echo "${args[@]}"
7287
}
7388

74-
75-
# recent versions of Git refuse to touch a repository whose on-disk owner
76-
# doesn’t match the UID that is running the command
77-
# mark the workspace (and any nested path) as safe
78-
echo "Marking workspace as safe for Git"
79-
git config --global --add safe.directory '*'
80-
81-
enable_git_describe
8289
log_dir=$SIM_HOME/logs
90+
test_interactive_option=""
8391

8492
# if we are in the docker container, we need to load the modules
8593
if [[ -z "${AUTOBUILD}" ]]; then
8694
echo "\nNot in container"
95+
test_interactive_option="-Di_test=true"
8796
else
8897
echo "\nIn docker container."
98+
# recent versions of Git refuse to touch a repository whose on-disk owner
99+
# doesn’t match the UID that is running the command
100+
# mark the workspace (and any nested path) as safe
101+
echo "Marking workspace as safe for Git"
102+
git config --global --add safe.directory '*'
103+
enable_git_describe
89104
log_dir=/root/src/logs
90105
fi
91106

92-
export $GEMC=$SIM_HOME/gemc/dev
93-
94-
setup_log=/root/src/logs/setup.log
95-
compile_log=/root/src/logs/build.log
96-
test_log=/root/src/logs/test.log
97107

98-
touch $setup_log $compile_log $test_log
108+
export GEMC=${SIM_HOME}/gemc/dev
109+
# detect cores and cap at 16
110+
cores=$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc)
111+
jobs=$((cores < 16 ? cores : 16))
99112

100-
echo Logs:
113+
mkdir -p $log_dir
114+
setup_log=$log_dir/setup.log
115+
compile_log=$log_dir/build.log
116+
install_log=$log_dir/install.log
117+
test_log=$log_dir/test.log
118+
gemc_install_show=$log_dir/gemc.log
101119

102-
ls -l $setup_log
103-
ls -l $compile_log
104-
ls -l $test_log
120+
touch $setup_log $compile_log $install_log $test_log
121+
echo

meson/meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ endif
5757

5858
# geant4.pc if not found
5959
fs = import('fs')
60-
gemc_prefix = get_option('prefix')
61-
geant4_pc = gemc_prefix / 'lib/pkgconfig/geant4.pc'
62-
script_path = meson.project_source_root() / 'meson/g4_pkgconfig.py'
60+
geant4_pc_path = get_option('prefix') / 'lib/pkgconfig'
61+
geant4_pc = geant4_pc_path / 'geant4.pc'
62+
g4_pkgconfig_script = meson.project_source_root() / 'meson/g4_pkgconfig.py'
6363
if not fs.exists(geant4_pc)
64-
message('geant4.pc not found in ' + geant4_pc + ', running install script...')
65-
run_command(script_path, gemc_prefix, check : true)
64+
message('geant4.pc not found in ' + geant4_pc + ', running install script to install it in ' + geant4_pc_path)
65+
run_command(g4_pkgconfig_script, geant4_pc_path, check : true)
6666
endif
6767
geant4_dep = dependency('geant4', version : '>=11.3.2')
6868

0 commit comments

Comments
 (0)