Skip to content

Commit 4640dcb

Browse files
committed
refactor(packages): emit dependency build params only when the dep is present
Same ifDep guard as the gdal recipe for geotiff, tiff, spatialite, proj and curl: a dependency removed via excludedDependencies or an override no longer crashes getBuildParams; its params (including feature toggles like -Djpeg=ON) are simply omitted. Full-dependency output is byte-identical.
1 parent 32cb967 commit 4640dcb

5 files changed

Lines changed: 47 additions & 21 deletions

File tree

  • cppjs-packages
    • cppjs-package-curl/cppjs-package-curl
    • cppjs-package-geotiff/cppjs-package-geotiff
    • cppjs-package-proj/cppjs-package-proj
    • cppjs-package-spatialite/cppjs-package-spatialite
    • cppjs-package-tiff/cppjs-package-tiff

cppjs-packages/cppjs-package-curl/cppjs-package-curl/build.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ export default {
1212
buildType: 'cmake',
1313
getBuildParams: (target, depPaths) => [
1414
...(platformBuild[target.platform] || []),
15-
`-DOPENSSL_INCLUDE_DIR=${depPaths.ssl.header}`,
16-
`-DOPENSSL_SSL_LIBRARY=${depPaths.ssl.lib}`,
17-
`-DOPENSSL_CRYPTO_LIBRARY=${depPaths.crypto.lib}`,
15+
...(depPaths.ssl && depPaths.crypto
16+
? [
17+
`-DOPENSSL_INCLUDE_DIR=${depPaths.ssl.header}`,
18+
`-DOPENSSL_SSL_LIBRARY=${depPaths.ssl.lib}`,
19+
`-DOPENSSL_CRYPTO_LIBRARY=${depPaths.crypto.lib}`,
20+
]
21+
: []),
1822
'-DBUILD_EXAMPLES=OFF', '-DBUILD_CURL_EXE=OFF', '-DBUILD_LIBCURL_DOCS=OFF',
1923
'-DBUILD_TESTING=OFF',
2024
'-DENABLE_CURL_MANUAL=OFF',

cppjs-packages/cppjs-package-geotiff/cppjs-package-geotiff/build.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ const platformExtraLibs = {
1212
'ios': ['-lc++'],
1313
};
1414

15+
const ifDep = (dep, params) => (dep ? params(dep) : []);
16+
1517
export default {
1618
getURL: (version) => `https://download.osgeo.org/geotiff/libgeotiff/libgeotiff-${version}.tar.gz`,
1719
buildType: 'configure',
1820
getBuildParams: (target, depPaths) => [
1921
...(platformBuild[target.platform] || platformBuild[`${target.platform}-${target.arch}`] || []),
20-
`--with-proj=${depPaths.proj.root}`, `--with-libtiff=${depPaths.tiff.root}`,
21-
`--with-zlib=${depPaths.z.root}`, `--with-jpeg=${depPaths.jpeg.root}`,
22+
...ifDep(depPaths.proj, (d) => [`--with-proj=${d.root}`]),
23+
...ifDep(depPaths.tiff, (d) => [`--with-libtiff=${d.root}`]),
24+
...ifDep(depPaths.z, (d) => [`--with-zlib=${d.root}`]),
25+
...ifDep(depPaths.jpeg, (d) => [`--with-jpeg=${d.root}`]),
2226
],
2327
getExtraLibs: (target) => platformExtraLibs[target.platform] || [],
2428
replaceList: [
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
const ifDep = (dep, params) => (dep ? params(dep) : []);
2+
13
export default {
24
getURL: (version) => `https://download.osgeo.org/proj/proj-${version}.tar.gz`,
35
buildType: 'cmake',
46
getBuildParams: (target, depPaths) => [
57
'-DENABLE_CURL=OFF', '-DBUILD_TESTING=OFF', '-DBUILD_APPS=OFF',
6-
`-DSQLite3_INCLUDE_DIR=${depPaths.sqlite3.header}`,
7-
`-DSQLite3_LIBRARY=${depPaths.sqlite3.lib}`,
8-
`-DTIFF_INCLUDE_DIR=${depPaths.tiff.header}`,
9-
`-DTIFF_LIBRARY_RELEASE=${depPaths.tiff.lib}`,
8+
...ifDep(depPaths.sqlite3, (d) => [
9+
`-DSQLite3_INCLUDE_DIR=${d.header}`,
10+
`-DSQLite3_LIBRARY=${d.lib}`,
11+
]),
12+
...ifDep(depPaths.tiff, (d) => [
13+
`-DTIFF_INCLUDE_DIR=${d.header}`,
14+
`-DTIFF_LIBRARY_RELEASE=${d.lib}`,
15+
]),
1016
],
1117
};

cppjs-packages/cppjs-package-spatialite/cppjs-package-spatialite/build.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const platformSourceReplaceList = {
2323
],
2424
};
2525

26+
const ifDep = (dep, params) => (dep ? params(dep) : []);
27+
2628
export default {
2729
getURL: (version) => `https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-${version}.tar.gz`,
2830
copyToSource: { 'config.sub': 'config.sub' },
@@ -32,9 +34,11 @@ export default {
3234
...(platformBuild[target.platform] || platformBuild[`${target.platform}-${target.arch}`] || []),
3335
'--enable-geosadvanced=yes', '--enable-geopackage=yes', '--enable-examples=no', '--enable-minizip=no',
3436
'--enable-libxml2=no', '--enable-freexl=no', '--disable-rttopo', '--disable-gcp',
35-
`--with-geosconfig=${depPaths.geos.bin}/geos-config`,
36-
`SQLITE3_CFLAGS=-I${depPaths.sqlite3.header}`,
37-
`SQLITE3_LIBS=-L${depPaths.sqlite3.libPath}`,
37+
...ifDep(depPaths.geos, (d) => [`--with-geosconfig=${d.bin}/geos-config`]),
38+
...ifDep(depPaths.sqlite3, (d) => [
39+
`SQLITE3_CFLAGS=-I${d.header}`,
40+
`SQLITE3_LIBS=-L${d.libPath}`,
41+
]),
3842
],
3943
getExtraLibs: (target) => platformLibs[target.platform] || [],
4044
};
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
const ifDep = (dep, params) => (dep ? params(dep) : []);
2+
13
export default {
24
getURL: (version) => `https://download.osgeo.org/libtiff/tiff-${version}.tar.gz`,
35
buildType: 'cmake',
46
getBuildParams: (target, depPaths) => [
57
'-Dtiff-tools=OFF', '-Dtiff-tests=OFF', '-Dtiff-contrib=OFF',
68
'-Dtiff-docs=OFF', '-Dld-version-script=OFF',
7-
'-Djpeg=ON',
8-
`-DJPEG_INCLUDE_DIR=${depPaths.jpeg.header}`,
9-
`-DJPEG_LIBRARY=${depPaths.jpeg.lib}`,
10-
'-Dzstd=ON',
11-
`-DZSTD_INCLUDE_DIR=${depPaths.zstd.header}`,
12-
`-DZSTD_LIBRARY=${depPaths.zstd.lib}`,
13-
'-Dlerc=ON',
14-
`-DLERC_INCLUDE_DIR=${depPaths.Lerc.header}`,
15-
`-DLERC_LIBRARY=${depPaths.Lerc.lib}`,
9+
...ifDep(depPaths.jpeg, (d) => [
10+
'-Djpeg=ON',
11+
`-DJPEG_INCLUDE_DIR=${d.header}`,
12+
`-DJPEG_LIBRARY=${d.lib}`,
13+
]),
14+
...ifDep(depPaths.zstd, (d) => [
15+
'-Dzstd=ON',
16+
`-DZSTD_INCLUDE_DIR=${d.header}`,
17+
`-DZSTD_LIBRARY=${d.lib}`,
18+
]),
19+
...ifDep(depPaths.Lerc, (d) => [
20+
'-Dlerc=ON',
21+
`-DLERC_INCLUDE_DIR=${d.header}`,
22+
`-DLERC_LIBRARY=${d.lib}`,
23+
]),
1624
],
1725
};

0 commit comments

Comments
 (0)