Skip to content

Commit

Permalink
README.md, UPDATE.md added. Fixes and tweaks. Ready for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
prikolium-cfx committed May 17, 2024
1 parent eb36682 commit 3b471e0
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
v8
.cipd
.cipd
build_results
.gclient
.gclient_entries
.gclient_previous_sync_commits
.gcs_entries
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# V8 Build Tools

This repository contains all the necessary tools and scripts to build Google's V8 for embedding.

## Prerequisites

1. **Clone this repository:**

```sh
git clone https://github.com/citizenfx/v8-build.git
cd v8-build
```

2. **Python 3.8+ must be installed on your system.**

3. **Drive Mapping:**

Ensure you do not have a drive mapped to the letter 'Y'. If you do, change the mapping drive target to another letter in the `prepare-depot.ps1` and `build.ps1` files.

## Building V8

1. **Prepare the depot:**

Run the following script to prepare the depot:

```sh
.\build\prepare-depot.ps1
```

2. **Build V8:**

Run the build script:

```sh
.\build\build.ps1
```

3. **Wait approximately 20 minutes** for the build process to complete.

## Build Results

The build results will be located in the `builds_results` folder.
7 changes: 7 additions & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# In case if update needed
## Things you need to know
* There was bug in ICU script that generating ASM file with icudata for embedding. If it still generates ASM file with `icudata` variable that prefixed with `_` - bug still exists and clang compilation will fail. We are doing trick to remove underscore in build script
* By default v8_monolith use static crt, so are forcing it to use dynamic CRT. Maybe with some time Google will fix it, so then you need to check flags with `gn args` and look for flag that forcing dynamic crt to be used.

## How to update to newer V8
Simply put new commit hash/tag/branch from [V8 repository](https://github.com/v8/v8) into `target.txt`. It will be added to `git checkout` command
File renamed without changes.
39 changes: 34 additions & 5 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,47 @@ Write-Host "Mount directory: $MOUNT_DIR"
Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: /D" -ErrorAction SilentlyContinue
Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: $MOUNT_DIR" -ErrorAction SilentlyContinue

# Reading target commit hash
$COMMIT = Get-Content "${MOUNT_TARGET_DRIVE}:\build\target_commit.txt " -Raw
# Reading target commit/tag/branch hash
$REPOSITORY_TARGET_CHECKOUT = Get-Content "${MOUNT_TARGET_DRIVE}:\build\target.txt " -Raw

# Fetch v8 source
& fetch v8
New-Item -ItemType Directory -Force -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\build\args_debug.gn" -Destination "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release\"
New-Item -ItemType Directory -Force -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.debug"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\build\args_debug.gn" -Destination "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.debug\args.gn"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\build\args_release.gn" -Destination "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release\args.gn"
Set-Location "${MOUNT_TARGET_DRIVE}:\v8"
git checkout $COMMIT
git checkout $REPOSITORY_TARGET_CHECKOUT
gclient sync

####################################
# #
# Tricks and hacks zone #
# #
####################################

# Trick to force v8 to use dynamic CRT
(Get-Content "${MOUNT_TARGET_DRIVE}:\v8\build\config\BUILDCONFIG.gn").Replace('//build/config/win:default_crt', '//build/config/win:dynamic_crt') | Set-Content "${MOUNT_TARGET_DRIVE}:\v8\build\config\BUILDCONFIG.gn"

# Fixing bug with compiling inlined icudata in ASM with Clang
# This cheap trick breaks macos version compilation, but we don't care about that
(Get-Content "${MOUNT_TARGET_DRIVE}:\v8\third_party\icu\scripts\make_data_assembly.py").Replace('_icudt%s_dat', 'icudt%s_dat') | Set-Content "${MOUNT_TARGET_DRIVE}:\v8\third_party\icu\scripts\make_data_assembly.py"

####################################
# #
# Tricks and hacks zone end #
# #
####################################

gn gen out.gn/x64.debug
ninja -C out.gn/x64.debug -j16 v8_monolith

gn gen out.gn/x64.release
ninja -C out.gn/x64.release -j16 v8
ninja -C out.gn/x64.release -j16 v8_monolith

New-Item -ItemType Directory -Force -Path "${MOUNT_TARGET_DRIVE}:\build_results"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.debug\obj\v8_monolith.lib" -Destination "${MOUNT_TARGET_DRIVE}:\build_results\v8_monolithd.lib"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release\obj\v8_monolith.lib" -Destination "${MOUNT_TARGET_DRIVE}:\build_results\v8_monolith.lib"

# Attempt to clean up and remove X: mapping at the end; ignore errors
Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: /D" -ErrorAction SilentlyContinue
35 changes: 35 additions & 0 deletions build/build.ps1.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Define environment variables
$env:DEPOT_TOOLS_WIN_TOOLCHAIN = "0"

# Get the current directory of the script
$CURRENT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
Write-Host "Current directory: $CURRENT_DIR"

# Define the directory to be mounted
$MOUNT_DIR = Split-Path -Path $CURRENT_DIR -Parent
$MOUNT_TARGET_DRIVE = "Y"
Write-Host "Mount directory: $MOUNT_DIR"

Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: /D" -ErrorAction SilentlyContinue
Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: $MOUNT_DIR" -ErrorAction SilentlyContinue

# Reading target commit hash
$COMMIT = Get-Content "${MOUNT_TARGET_DRIVE}:\build\target_commit.txt " -Raw

# Fetch v8 source
& fetch v8
New-Item -ItemType Directory -Force -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release"
New-Item -ItemType Directory -Force -Path "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.debug"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\build\args_debug.gn" -Destination "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.debug\args.gn"
Copy-Item -Path "${MOUNT_TARGET_DRIVE}:\build\args_release.gn" -Destination "${MOUNT_TARGET_DRIVE}:\v8\out.gn\x64.release\args.gn"
Set-Location "${MOUNT_TARGET_DRIVE}:\v8"
git checkout $COMMIT
gclient sync
gn gen out.gn/x64.debug
ninja -C out.gn/x64.debug -j16 v8_monolith

gn gen out.gn/x64.release
ninja -C out.gn/x64.release -j16 v8_monolith

# Attempt to clean up and remove X: mapping at the end; ignore errors
Invoke-Expression "subst ${MOUNT_TARGET_DRIVE}: /D" -ErrorAction SilentlyContinue
File renamed without changes.
2 changes: 1 addition & 1 deletion depot_tools
Submodule depot_tools updated from e13852 to 9a8c80

0 comments on commit 3b471e0

Please sign in to comment.