Fix bsconst plugin
This commit is contained in:
1 parent
5aac07d36c
commit
1faec073f0
4 files changed
+19
-33
No files matched your search
@@ -19,9 +19,9 @@ function GetPlayletLibUrls() as object
|
|||||||
embedded = { type: "embedded", link: ReadManifestValue("playlet_lib_embedded_url") }
|
embedded = { type: "embedded", link: ReadManifestValue("playlet_lib_embedded_url") }
|
||||||
registry = { type: "registry", link: ReadRegistryKey("playlet_lib_url", "Playlet") }
|
registry = { type: "registry", link: ReadRegistryKey("playlet_lib_url", "Playlet") }
|
||||||
|
|
||||||
if IsDebugMode()
|
#if DEBUG
|
||||||
return [embedded]
|
return [embedded]
|
||||||
end if
|
#end if
|
||||||
|
|
||||||
urls = []
|
urls = []
|
||||||
|
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ function Main(args as object) as void
|
|||||||
input = CreateObject("roInput")
|
input = CreateObject("roInput")
|
||||||
input.setMessagePort(m.port)
|
input.setMessagePort(m.port)
|
||||||
|
|
||||||
if IsDebugMode()
|
#if DEBUG
|
||||||
' The following comment is to enable the SceneGraph inspector
|
' The following comment is to enable the SceneGraph inspector
|
||||||
' on the VSCode BrightScript plugin.
|
' on the VSCode BrightScript plugin.
|
||||||
' vscode_rdb_on_device_component_entry
|
' vscode_rdb_on_device_component_entry
|
||||||
|
|
||||||
' The following comment is to enable RALE tracking
|
' The following comment is to enable RALE tracking
|
||||||
' vscode_rale_tracker_entry
|
' vscode_rale_tracker_entry
|
||||||
end if
|
#end if
|
||||||
|
|
||||||
while true
|
while true
|
||||||
msg = wait(0, m.port)
|
msg = wait(0, m.port)
|
||||||
|
|||||||
@@ -1,26 +1,3 @@
|
|||||||
function IsDebugMode() as boolean
|
|
||||||
bsConst = GetBsConstValues()
|
|
||||||
return bsConst["DEBUG"]
|
|
||||||
end function
|
|
||||||
|
|
||||||
function GetBsConstValues() as object
|
|
||||||
result = {}
|
|
||||||
|
|
||||||
bsConst = ReadManifestValue("bs_const")
|
|
||||||
symbols = bsConst.Tokenize(";")
|
|
||||||
|
|
||||||
for each symbol in symbols
|
|
||||||
keyValuePair = symbol.Tokenize("=")
|
|
||||||
if keyValuePair.Count() <> 2
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
|
|
||||||
result[UCase(keyValuePair[0])] = UCase(keyValuePair[1]) = "TRUE"
|
|
||||||
end for
|
|
||||||
|
|
||||||
return result
|
|
||||||
end function
|
|
||||||
|
|
||||||
function ReadManifestValue(key as string) as string
|
function ReadManifestValue(key as string) as string
|
||||||
appInfo = CreateObject("roAppInfo")
|
appInfo = CreateObject("roAppInfo")
|
||||||
return appInfo.GetValue(key)
|
return appInfo.GetValue(key)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
CompilerPlugin,
|
CompilerPlugin,
|
||||||
ProgramBuilder,
|
ProgramBuilder
|
||||||
FileObj
|
|
||||||
} from 'brighterscript';
|
} from 'brighterscript';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
@@ -9,18 +8,28 @@ import fs from 'fs';
|
|||||||
export class ManifestBsConstDebugPlugin implements CompilerPlugin {
|
export class ManifestBsConstDebugPlugin implements CompilerPlugin {
|
||||||
public name = 'manifestBsConstDebugPlugin';
|
public name = 'manifestBsConstDebugPlugin';
|
||||||
|
|
||||||
beforePublish(builder: ProgramBuilder, files: FileObj[]) {
|
private originalManifestContent?: string;
|
||||||
|
|
||||||
|
beforeProgramCreate(builder: ProgramBuilder) {
|
||||||
const debugFlag = process.argv.find(arg => /--debug=(true|false)/i.test(arg))
|
const debugFlag = process.argv.find(arg => /--debug=(true|false)/i.test(arg))
|
||||||
if (!debugFlag) {
|
if (!debugFlag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const value = /--debug=(true|false)/i.exec(debugFlag)![1].toLowerCase()
|
const value = /--debug=(true|false)/i.exec(debugFlag)![1].toLowerCase()
|
||||||
builder.logger.log(`Setting bs_const DEBUG to ${value}`)
|
builder.logger.log(`Setting bs_const DEBUG to ${value}`)
|
||||||
const manifestPath = path.join(builder.options.stagingDir!, "manifest")
|
const manifestPath = path.join(builder.options.rootDir!, "manifest")
|
||||||
let manifestContent = fs.readFileSync(manifestPath, { encoding: 'utf8', flag: 'r' })
|
this.originalManifestContent = fs.readFileSync(manifestPath, { encoding: 'utf8', flag: 'r' })
|
||||||
manifestContent = manifestContent.replace(/DEBUG=(true|false)/i, `DEBUG=${value}`);
|
let manifestContent = this.originalManifestContent.replace(/DEBUG=(true|false)/i, `DEBUG=${value}`);
|
||||||
fs.writeFileSync(manifestPath, manifestContent)
|
fs.writeFileSync(manifestPath, manifestContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afterPublish(builder: ProgramBuilder) {
|
||||||
|
if (!this.originalManifestContent) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const manifestPath = path.join(builder.options.rootDir!, "manifest")
|
||||||
|
fs.writeFileSync(manifestPath, this.originalManifestContent!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
|||||||
Reference in new issue
Block a user