Skip to content

Commit

Permalink
Small simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed May 23, 2024
1 parent 769ca6a commit 973e0ad
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 77 deletions.
4 changes: 0 additions & 4 deletions packages/realm/binding/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ endif()
set(REALM_BUILD_LIB_ONLY ON)
set(REALM_ENABLE_SYNC ON)

if(ANDROID)
set(REALM_ANDROID ON)
endif()

add_subdirectory(${BINDGEN_DIR}/vendor/realm-core realm-core EXCLUDE_FROM_ALL)

add_library(realm-js OBJECT)
Expand Down
108 changes: 35 additions & 73 deletions packages/realm/src/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,27 @@ program
const { CMAKE_PATH: cmakePath = execSync("which cmake", { encoding: "utf8" }).trim() } = env;
const platforms = apple.validatePlatforms(rawPlatforms);

group("Generate Xcode project", () => {
if (platforms.length > 0) {
if (platforms.length > 0) {
group("Generate Xcode project", () => {
apple.generateXcodeProject({ cmakePath });
} else {
console.log("Skipped generating Xcode project (no platforms to build for)");
}
});
});
} else {
console.log("Skipped generating Xcode project (no platforms to build for)");
}

const producedArchivePaths = platforms.map((platform) => {
return group(`Build ${platform} / ${configuration}`, () => {
return apple.buildFramework({ platform, configuration });
});
});

group(`Collecting headers`, () => {
if (skipCollectingHeaders) {
console.log("Skipped collecting headers");
} else {
if (skipCollectingHeaders) {
group(`Collecting headers`, () => {
apple.collectHeaders();
}
});
});
} else {
console.log("Skipped collecting headers");
}

// Collect the absolute paths of all available archives in the build directory
// This allows for splitting up the invocation of the build command
Expand All @@ -135,13 +135,13 @@ program
);
}

group(`Creating xcframework`, () => {
if (skipCreatingXcframework) {
console.log("Skipped creating Xcframework");
} else {
if (skipCreatingXcframework) {
console.log("Skipped creating Xcframework");
} else {
group(`Creating xcframework`, () => {
apple.createXCFramework({ archivePaths });
}
});
});
}

console.log("Great success! 🥳");
}),
Expand All @@ -156,63 +156,25 @@ program
.option("--skip-collecting-headers", "Skip collecting headers from the build directory and copy them to the SDK")
// .option("--skip-generating-version-file", "Skip generating a Version.java file")
.action(
actionWrapper(
({
architecture: rawArchitectures,
configuration,
// skipCollectingHeaders,
// skipGeneratingVersionFile,
ndkVersion,
}) => {
assert(fs.existsSync(REALM_CORE_PATH), `Expected Realm Core at '${REALM_CORE_PATH}'`);
const { ANDROID_HOME, CMAKE_PATH: cmakePath = execSync("which cmake", { encoding: "utf8" }).trim() } = env;
assert(typeof ANDROID_HOME === "string", "Missing env variable ANDROID_HOME");
assert(fs.existsSync(ANDROID_HOME), `Expected the Android SDK at ${ANDROID_HOME}`);
const installNdkCommand = `sdkmanager --install "ndk;${ndkVersion}"`;
const ndkPath = path.resolve(ANDROID_HOME, "ndk", ndkVersion);
assert(
fs.existsSync(ndkPath),
`Missing Android NDK v${ndkVersion} (at ${ndkPath}) - run: ${installNdkCommand}`,
);

const architectures = android.validateArchitectures(rawArchitectures);

// group("Configure Cmake build directory", () => {
// });

architectures.map((architecture) => {
return group(`Build ${architecture} / ${configuration}`, () => {
return android.buildArchive({ cmakePath, architecture, configuration, ndkPath });
});
actionWrapper(({ architecture: rawArchitectures, configuration, ndkVersion }) => {
assert(fs.existsSync(REALM_CORE_PATH), `Expected Realm Core at '${REALM_CORE_PATH}'`);
const { ANDROID_HOME, CMAKE_PATH: cmakePath = execSync("which cmake", { encoding: "utf8" }).trim() } = env;
assert(typeof ANDROID_HOME === "string", "Missing env variable ANDROID_HOME");
assert(fs.existsSync(ANDROID_HOME), `Expected the Android SDK at ${ANDROID_HOME}`);
const installNdkCommand = `sdkmanager --install "ndk;${ndkVersion}"`;
const ndkPath = path.resolve(ANDROID_HOME, "ndk", ndkVersion);
assert(fs.existsSync(ndkPath), `Missing Android NDK v${ndkVersion} (at ${ndkPath}) - run: ${installNdkCommand}`);

const architectures = android.validateArchitectures(rawArchitectures);

architectures.map((architecture) => {
return group(`Build ${architecture} / ${configuration}`, () => {
return android.buildArchive({ cmakePath, architecture, configuration, ndkPath });
});
});

// architectures.map((architecture) => {
// return group(`Copy SSL archives for ${architecture}`, () => {
// return android.copySSLArchives({ architecture });
// });
// });

// group("Writing version source file", () => {
// if (skipGeneratingVersionFile) {
// console.log("Skipped generating version file");
// } else {
// android.generateVersionFile();
// }
// });

// group(`Collecting headers`, () => {
// if (skipCollectingHeaders) {
// console.log("Skipped collecting headers");
// } else {
// const [firstArchitecture] = architectures;
// assert(firstArchitecture, "Expected at least one architecture");
// android.collectHeaders({ architecture: firstArchitecture });
// }
// });

console.log("Great success! 🥳");
},
),
console.log("Great success! 🥳");
}),
);

if (require.main === module) {
Expand Down
2 changes: 2 additions & 0 deletions packages/realm/src/scripts/react-native-apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const REALM_CORE_LIBRARY_NAMES_DENYLIST = [
...COMMON_REALM_CORE_LIBRARY_NAMES_DENYLIST,
REALM_CORE_COMBINED_LIBRARY_NAME,
];

// TODO: Consider if this needs to be platform specific
const REALM_CORE_HEADERS_PATH = path.resolve(REALM_CORE_BUILD_PATH, "include");

const REALM_CORE_PRODUCTS_INSTALL_PATH = `Products${ARCHIVE_INSTALL_PATH}`;
Expand Down

0 comments on commit 973e0ad

Please sign in to comment.