Skip to content

Commit

Permalink
Add sim-server as submodule and setup builds to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagiera committed Mar 19, 2024
1 parent 5304734 commit ba3376c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "packages/simulator-server"]
path = packages/simulator-server
url = [email protected]:software-mansion-labs/simulator-server.git
1 change: 1 addition & 0 deletions packages/simulator-server
Submodule simulator-server added at 0af8a3
8 changes: 4 additions & 4 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
"build:extension-code": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --minify && cp ./node_modules/source-map/lib/mappings.wasm dist/.",
"build:expo-fingerprint": "esbuild ./node_modules/@expo/fingerprint/build/sourcer/ExpoConfigLoader.js --bundle --format=cjs --outfile=dist/ExpoConfigLoader.js --platform=node --minify",
"build:webview": "vite build --mode production && cp ./node_modules/@vscode/codicons/dist/codicon.* dist/.",
"build:sim-controller-debug": "./scripts/build-sim-controller.sh dist Debug",
"build:sim-controller": "./scripts/build-sim-controller.sh dist Release",
"build:debug": "npm run build:extension-debug && npm run build:sim-controller-debug",
"build:dist": "npm run build:extension && npm run build:sim-controller && npm run build:webview",
"build:sim-server-debug": "./scripts/build-sim-server.sh dist Debug",
"build:sim-server": "./scripts/build-sim-server.sh dist Release",
"build:debug": "npm run build:extension-debug && npm run build:sim-server-debug",
"build:dist": "npm run build:extension && npm run build:sim-server && npm run build:webview",
"watch:extension": "vite",
"package": "rm -rf dist/ && npm run build:dist",
"lint": "eslint src --ext ts && yarn prettier --check src",
Expand Down
31 changes: 0 additions & 31 deletions packages/vscode-extension/scripts/build-sim-controller.sh

This file was deleted.

35 changes: 35 additions & 0 deletions packages/vscode-extension/scripts/build-sim-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# take output directory from first argument or default to out
output_dir="${1:-out}"

# take configuration from second argument or default to Debug
configuration=${2:-Debug}

# Get the directory where the script is located
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

target_dir="${script_dir}/../${output_dir}"
target_location="${target_dir}/sim-server"

# Create the target directory if it doesn't exist
mkdir -p "$target_dir"

# execute the build from the simulator-server package
build_script_location="$script_dir/../../simulator-server/build.sh"
# the build product location is printed by the build script as the very last line, we capture this line to a variable to parse it:
product_path=$("$build_script_location" "$configuration" | tail -n 1)

# Check if the build was successful
if [[ $? -ne 0 ]]; then
echo "Build failed."
exit 1
fi

# Check if a file was found and copy it
if [[ -n $product_path ]]; then
echo "Found binary at $product_path"
cp "$product_path" "$target_location"
else
echo "No file found matching the pattern."
fi
2 changes: 1 addition & 1 deletion packages/vscode-extension/src/devices/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Preview implements Disposable {
}

async start() {
const simControllerBinary = path.join(extensionContext.extensionPath, "dist", "sim-controller");
const simControllerBinary = path.join(extensionContext.extensionPath, "dist", "sim-server");

Logger.debug(`Launch preview ${simControllerBinary} ${this.args}`);
const subprocess = exec(simControllerBinary, this.args, { buffer: false });
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ async function fixBinaries(context: ExtensionContext) {
// We try to do it only when the binary has been modified or for new installation, we detect it based
// on the modification date of the binary file.
const binModiticationDate = context.globalState.get(BIN_MODIFICATION_DATE_KEY);
const binPath = Uri.file(context.asAbsolutePath("dist/sim-controller"));
const tmpFile = Uri.file(path.join(os.tmpdir(), "sim-controller"));
const binPath = Uri.file(context.asAbsolutePath("dist/sim-server"));
const tmpFile = Uri.file(path.join(os.tmpdir(), "sim-server"));

if (binModiticationDate !== undefined) {
const binStats = await workspace.fs.stat(binPath);
Expand Down

0 comments on commit ba3376c

Please sign in to comment.