Skip to content

Commit

Permalink
drop boost/regex
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Oct 7, 2023
1 parent 8cf2719 commit 54a758e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 51 deletions.
2 changes: 1 addition & 1 deletion librime
14 changes: 12 additions & 2 deletions librime_patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aecf5a08..71be3a0b 100644
index af87ccf6..b2369307 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.12)
Expand All @@ -11,7 +11,7 @@ index aecf5a08..71be3a0b 100644
set(rime_soversion 1)

add_definitions(-DRIME_VERSION="${rime_version}")
@@ -46,6 +46,9 @@ if (ENABLE_ASAN)
@@ -45,6 +45,9 @@ if (ENABLE_ASAN)
set(CMAKE_SHARED_LINKER_FLAGS "${asan_lflags} ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

Expand All @@ -21,6 +21,16 @@ index aecf5a08..71be3a0b 100644
set(Boost_USE_STATIC_LIBS ${BUILD_STATIC})
set(Gflags_STATIC ${BUILD_STATIC})
set(Glog_STATIC ${BUILD_STATIC})
@@ -58,7 +61,9 @@ if(MSVC)
set(Boost_USE_STATIC_RUNTIME ON)
endif()

+if(LINUX)
set(BOOST_COMPONENTS regex)
+endif()

find_package(Boost 1.74.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND)
diff --git a/include/darts.h b/include/darts.h
index 18bf988b..4b9bb5d2 100644
--- a/include/darts.h
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"native": "node --loader ts-node/esm scripts/build_native.ts",
"schema": "node --loader ts-node/esm scripts/install_schemas.ts",
"lib": "node --loader ts-node/esm scripts/build_lib.ts",
"lib:boost": "pnpm run lib -- boost",
"lib:yaml-cpp": "pnpm run lib -- yaml-cpp",
"lib:leveldb": "pnpm run lib -- leveldb",
"lib:marisa": "pnpm run lib -- marisa",
Expand Down
24 changes: 1 addition & 23 deletions scripts/build_lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
symlinkSync,
mkdirSync
} from 'fs'
import { cpus, platform } from 'os'
import { platform } from 'os'
import { cwd, chdir } from 'process'
import { spawnSync, SpawnSyncOptionsWithBufferEncoding } from 'child_process'
import {
Expand All @@ -14,7 +14,6 @@ import {
} from './util.js'

const root = cwd()
const n = cpus().length
const PLATFORM = platform()
const emcmake = PLATFORM === 'win32' ? 'emcmake.bat' : 'emcmake'

Expand Down Expand Up @@ -46,26 +45,6 @@ const installArg: SpawnSyncOptionsWithBufferEncoding = {
}
}

function buildBoost () {
console.log('Building boost')
patch('boost/libs/interprocess', 'interprocess_patch')
chdir('boost')
ensure(spawnSync(PLATFORM === 'win32' ? '.\\bootstrap.bat' : './bootstrap.sh', [], spawnArg))
ensure(spawnSync('./b2', [
'toolset=emscripten',
'link=static',
'threading=single', // threading defaults to multi on Linux and single on macOS
'target-os=linux', // Windows hack
'--layout=system',
'--with-regex',
'--disable-icu',
`--prefix=${CMAKE_FIND_ROOT_PATH}`,
'install',
'-j', `${n}`
], spawnArg))
chdir(root)
}

function buildYamlCpp () {
console.log('Building yaml-cpp')
const src = 'librime/deps/yaml-cpp'
Expand Down Expand Up @@ -200,7 +179,6 @@ function buildLibrime () {
}

const targetHandler = {
boost: buildBoost,
'yaml-cpp': buildYamlCpp,
leveldb: buildLevelDB,
marisa: buildMarisaTrie,
Expand Down
22 changes: 2 additions & 20 deletions scripts/build_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
renameSync,
rmSync
} from 'fs'
import { cpus, platform } from 'os'
import { platform } from 'os'
import { cwd, chdir } from 'process'
import { spawnSync, SpawnSyncOptionsWithBufferEncoding } from 'child_process'
import {
Expand All @@ -12,7 +12,6 @@ import {
} from './util.js'

const root = cwd()
const n = cpus().length
const PLATFORM = platform()

const CMAKE_INSTALL_PREFIX = `${root}/librime`
Expand Down Expand Up @@ -48,6 +47,7 @@ const CMAKE_DEF_RIME = [
'-DBUILD_SHARED_LIBS:BOOL=ON',
...(PLATFORM === 'linux' ? [] : ['-DBUILD_STATIC:BOOL=ON']),
'-DBUILD_TEST:BOOL=OFF',
`-DCMAKE_FIND_ROOT_PATH:PATH=${root}/build/sysroot`,
'-DENABLE_TIMESTAMP:BOOL=OFF',
'-DENABLE_LOGGING:BOOL=OFF'
]
Expand All @@ -60,23 +60,6 @@ const spawnArg: SpawnSyncOptionsWithBufferEncoding = {
}
}

function buildBoost () {
console.log('Building boost')
chdir('boost')
ensure(spawnSync(PLATFORM === 'win32' ? '.\\bootstrap.bat' : './bootstrap.sh', [], spawnArg))
ensure(spawnSync('./b2', [
...(PLATFORM === 'win32' ? ['toolset=clang-win'] : []),
'address-model=64',
'variant=release',
'link=static',
'stage',
'runtime-link=static',
'--with-regex',
'-j', `${n}`
], spawnArg))
chdir(root)
}

function buildYamlCpp () {
console.log('Building yaml-cpp')
chdir('librime/deps/yaml-cpp')
Expand Down Expand Up @@ -161,7 +144,6 @@ function buildLibrime () {
}

if (PLATFORM !== 'linux') {
buildBoost()
buildYamlCpp()
buildLevelDB()
buildMarisaTrie()
Expand Down
17 changes: 13 additions & 4 deletions scripts/update_submodule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { chdir } from 'process'
import { mkdirSync, cpSync } from 'fs'
import { cwd, chdir } from 'process'
import { spawnSync, SpawnSyncOptionsWithBufferEncoding } from 'child_process'
import { ensure } from './util.js'
import { ensure, patch } from './util.js'

const root = cwd()
const includeBoost = `${root}/build/sysroot/usr/include/boost`
mkdirSync(includeBoost, { recursive: true })

const spawnArg: SpawnSyncOptionsWithBufferEncoding = {
stdio: 'inherit',
Expand Down Expand Up @@ -64,7 +69,7 @@ for (const submodule of [
'move',
'mp11',
'mpl',
'numeric',
'numeric/conversion',
'optional',
'predef',
'preprocessor',
Expand All @@ -87,5 +92,9 @@ for (const submodule of [
'variant2',
'winapi'
]) {
update(submodule, true)
update(submodule.split('/')[0], true)
if (submodule === 'interprocess') {
patch('interprocess', '../../interprocess_patch')
}
cpSync(`${submodule}/include/boost`, includeBoost, { recursive: true })
}

0 comments on commit 54a758e

Please sign in to comment.