void AIScannerInfo::Initialize() { ScriptScanner::Initialize("AIScanner"); ScriptAllocatorScope alloc_scope(this->engine); /* Create the dummy AI */ free(this->main_script); this->main_script = stredup("%_dummy"); extern void Script_CreateDummyInfo(HSQUIRRELVM vm, const char *type, const char *dir); Script_CreateDummyInfo(this->engine->GetVM(), "AI", "ai"); }
struct node *parse_main(struct compiler *compiler) { struct block *block; struct node *result = alloc_scope(compiler, &block, S_MAIN); block->owner = block; result->right = parse_statements(compiler); lexer_match(compiler, T_EOF); return result; }
static BuildProgress::Enum CheckInputSignature(BuildQueue* queue, ThreadState* thread_state, NodeState* node, Mutex* queue_lock) { CHECK(AllDependenciesReady(queue, node)); MutexUnlock(queue_lock); const BuildQueueConfig& config = queue->m_Config; StatCache* stat_cache = config.m_StatCache; DigestCache* digest_cache = config.m_DigestCache; const NodeData* node_data = node->m_MmapData; HashState sighash; FILE* debug_log = (FILE*) queue->m_Config.m_FileSigningLog; if (debug_log) { MutexLock(queue->m_Config.m_FileSigningLogMutex); fprintf(debug_log, "input_sig(\"%s\"):\n", node_data->m_Annotation.Get()); HashInitDebug(&sighash, debug_log); } else { HashInit(&sighash); } // Start with command line action. If that changes, we'll definitely have to rebuild. HashAddString(&sighash, node_data->m_Action); HashAddSeparator(&sighash); if (const char* pre_action = node_data->m_PreAction) { HashAddString(&sighash, pre_action); HashAddSeparator(&sighash); } const ScannerData* scanner = node_data->m_Scanner; for (const FrozenFileAndHash& input : node_data->m_InputFiles) { // Add path and timestamp of every direct input file. HashAddString(&sighash, input.m_Filename); ComputeFileSignature(&sighash, stat_cache, digest_cache, input.m_Filename, input.m_Hash, config.m_ShaDigestExtensions, config.m_ShaDigestExtensionCount); if (scanner) { // Roll back scratch allocator between scans MemAllocLinearScope alloc_scope(&thread_state->m_ScratchAlloc); ScanInput scan_input; scan_input.m_ScannerConfig = scanner; scan_input.m_ScratchAlloc = &thread_state->m_ScratchAlloc; scan_input.m_ScratchHeap = &thread_state->m_LocalHeap; scan_input.m_FileName = input.m_Filename; scan_input.m_ScanCache = queue->m_Config.m_ScanCache; ScanOutput scan_output; if (ScanImplicitDeps(stat_cache, &scan_input, &scan_output)) { for (int i = 0, count = scan_output.m_IncludedFileCount; i < count; ++i) { // Add path and timestamp of every indirect input file (#includes) const FileAndHash& path = scan_output.m_IncludedFiles[i]; HashAddString(&sighash, path.m_Filename); ComputeFileSignature(&sighash, stat_cache, digest_cache, path.m_Filename, path.m_Hash, config.m_ShaDigestExtensions, config.m_ShaDigestExtensionCount); } } } } HashFinalize(&sighash, &node->m_InputSignature); if (debug_log) { char sig[kDigestStringSize]; DigestToString(sig, node->m_InputSignature); fprintf(debug_log, " => %s\n", sig); MutexUnlock(queue->m_Config.m_FileSigningLogMutex); } // Figure out if we need to rebuild this node. const NodeStateData* prev_state = node->m_MmapState; BuildProgress::Enum next_state; if (!prev_state) { // This is a new node - we must built it Log(kSpam, "T=%d: building %s - new node", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kRunAction; } else if (prev_state->m_InputSignature != node->m_InputSignature) { // The input signature has changed (either direct inputs or includes) // We need to rebuild this node. Log(kSpam, "T=%d: building %s - input signature changed", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kRunAction; } else if (prev_state->m_BuildResult != 0) { // The build progress failed the last time around - we need to retry it. Log(kSpam, "T=%d: building %s - previous build failed", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kRunAction; } else if (OutputFilesDiffer(node_data, prev_state)) { // The output files are different - need to rebuild. Log(kSpam, "T=%d: building %s - output files have changed", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kRunAction; } else if (OutputFilesMissing(stat_cache, node_data)) { // One or more output files are missing - need to rebuild. Log(kSpam, "T=%d: building %s - output files are missing", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kRunAction; } else { // Everything is up to date Log(kSpam, "T=%d: %s - up to date", thread_state->m_ThreadIndex, node_data->m_Annotation.Get()); next_state = BuildProgress::kUpToDate; } MutexLock(queue_lock); return next_state; }