Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: codegen based on platform #395

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/nitrogen/src/nitrogen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Logger } from './Logger.js'
import { NitroConfig } from './config/NitroConfig.js'
import { createIOSAutolinking } from './autolinking/createIOSAutolinking.js'
import { createAndroidAutolinking } from './autolinking/createAndroidAutolinking.js'
import type { Autolinking } from './autolinking/Autolinking.js'

interface NitrogenOptions {
baseDirectory: string
Expand Down Expand Up @@ -78,6 +79,7 @@ export async function runNitrogen({
process.exit()
}

let platforms: Platform[] = []
const filesAfter: string[] = []
const writtenFiles: SourceFile[] = []

Expand All @@ -101,7 +103,8 @@ export async function runNitrogen({
continue
}

const platforms = Object.keys(platformSpec) as Platform[]
platforms = Object.keys(platformSpec) as Platform[]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overwrites platforms each time instead of appending to it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of lifting out platforms here, let's create a new value in line 82 called usedPlatforms and we additionally append to it.

Copy link
Contributor Author

@patrickkabwe patrickkabwe Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed the comment above


if (platforms.length === 0) {
console.warn(
`⚠️ ${moduleName} does not declare any platforms in HybridObject<T> - nothing can be generated.`
Expand Down Expand Up @@ -178,10 +181,16 @@ export async function runNitrogen({

// Autolinking
Logger.info(`⛓️ Setting up build configs for autolinking...`)
const iosFiles = createIOSAutolinking()
const androidFiles = createAndroidAutolinking(writtenFiles)

const autolinkingFiles = [iosFiles, androidFiles]
const autolinkingFiles: Autolinking[] = []

if (platforms.includes('ios')) {
autolinkingFiles.push(createIOSAutolinking())
}
if (platforms.includes('android')) {
autolinkingFiles.push(createAndroidAutolinking(writtenFiles))
}

for (const autolinking of autolinkingFiles) {
Logger.info(
` Creating autolinking build setup for ${chalk.dim(autolinking.platform)}...`
Expand Down
Loading