aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/generate_dump.sh
blob: 17cafa7ee87df982ea90d584c833a535a5de8374 (plain) (blame)
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
#!/usr/bin/env bash

set -e

TMP_FOLDER='/tmp/ydb-build-dump'

rm -rf $TMP_FOLDER
mkdir $TMP_FOLDER

PLATFORM=$1
TARGET_PLATFORM=$2

PARAMS_FILE=$TMP_FOLDER/params.json
UNIX_TEMPLATE=$TMP_FOLDER/unix_template.txt
WIN_TEMPLATE=$TMP_FOLDER/win_template.txt

cat <<'EOF'>$UNIX_TEMPLATE
{
  "env": {
    "CPATH": [""],
    "LIBRARY_PATH": [""],
    "SDKROOT": [""]
  },
  "params": {
    "c_compiler": "$$($platform)/bin/clang",
    "cxx_compiler": "$$($platform)/bin/clang++",
    "gcc_version": "14.0",
    "llvm-symbolizer": "$$($platform)/bin/llvm-symbolizer",
    "match_root": "$platform",
    "objcopy": "$$($platform)/bin/llvm-objcopy",
    "strip": "$$($platform)/bin/llvm-strip",
    "type": "clang",
    "werror_mode": "all"
  },
  "platform": {
    "host": {
      "arch": "$arch",
      "os": "$os",
      "toolchain": "default",
      "visible_name": "clang14"
    },
    "target": {
      "arch": "$arch",
      "os": "$os",
      "toolchain": "default",
      "visible_name": "clang14"
    }
  }
}
EOF

cat <<'EOF'>$WIN_TEMPLATE
{
  "params": {
    "c_compiler": "$$($platform)/bin/Hostx64/x64/cl.exe",
    "cxx_compiler": "$$($platform)/bin/Hostx64/x64/cl.exe",
    "cxx_std": "c++latest",
    "for_ide": "msvs2019",
    "match_root": "$platform",
    "type": "msvc",
    "version": "2019",
    "werror_mode": "compiler_specific"
  },
  "platform": {
    "host": {
      "arch": "$arch",
      "os": "$os",
      "toolchain": "default",
      "visible_name": "msvc2019"
    },
    "target": {
      "arch": "$arch",
      "os": "$os",
      "toolchain": "default",
      "visible_name": "msvc2019"
    }
  }
}
EOF

if [[ $PLATFORM = win* ]]
then
    TEMPLATE=$WIN_TEMPLATE
else
    TEMPLATE=$UNIX_TEMPLATE
fi

DUMP_EXPORT_PATH="$TMP_FOLDER/ymake.$PLATFORM.conf"

# generate params for ymake_conf.py
if base64 --help | grep -q -e '^\s*-w,';then
  base64cmd='base64 -w0'
else
  base64cmd='base64'
fi
python3 -c "import sys, string as s; v=sys.argv; p = v[1].replace('-', '_'); o, a = v[2].split('-'); print(s.Template(open('$TEMPLATE').read()).substitute(platform=p.upper(), arch=a, os=o.upper()))" $TARGET_PLATFORM $PLATFORM >$DUMP_EXPORT_PATH.params
PARAMS=`cat $DUMP_EXPORT_PATH.params | $base64cmd`

ARCADIA=`realpath .`
python3 $ARCADIA/build/ymake_conf.py $ARCADIA release no --toolchain-params $PARAMS \
    -D NO_SVN_DEPENDS=yes -D REPORT_CONFIGURE_PROGRESS=yes -D EXPORT_CMAKE=yes -D TRAVERSE_RECURSE=yes -D TRAVERSE_RECURSE_FOR_TESTS=yes \
    -D BUILD_LANGUAGES=CPP -D EXPORTED_BUILD_SYSTEM_SOURCE_ROOT='${CMAKE_SOURCE_DIR}' -D EXPORTED_BUILD_SYSTEM_BUILD_ROOT='${CMAKE_BINARY_DIR}' \
    -D OPENSOURCE=yes -D OPENSOURCE_PROJECT=ydb -D HAVE_CUDA=no -D CUDA_VERSION=0.0 -D USE_PREBUILT_TOOLS=no >$DUMP_EXPORT_PATH
# append new line
echo >>$DUMP_EXPORT_PATH

cat $DUMP_EXPORT_PATH
# cp $DUMP_EXPORT_PATH .

# rm -rf $TMP_FOLDER