~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-03-29 23:36:33 UTC
  • mto: (1.5.1 sid)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: james.westby@ubuntu.com-20080329233633-l550uuwvfh1e68at
Tags: upstream-1.0+dfsg
ImportĀ upstreamĀ versionĀ 1.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
                                extras = new StringBuilder ();
129
129
                                datafiles = new StringBuilder ();
130
130
 
 
131
                                string includes = String.Empty;
131
132
                                string references, dllReferences;
132
133
                                ProcessProjectReferences (project, out references, out dllReferences, ctx);
133
134
 
194
195
 
195
196
                                        string programFilesDir = ctx.DeployContext.GetDirectory (TargetDirectory.ProgramFiles);
196
197
                                        //FIXME:temp
197
 
                                        programFilesDir = programFilesDir.Replace ("@prefix@", "$(prefix)");
198
 
                                        programFilesDir = programFilesDir.Replace ("@PACKAGE@", "$(PACKAGE)");
 
198
                                        programFilesDir = TranslateDir (programFilesDir);
199
199
                                        installDirs.Add (programFilesDir);
200
200
                                        installTarget.Append ("\tmake pre-install-local-hook prefix=$(prefix)\n");
201
201
                                        installTarget.AppendFormat ("\tmkdir -p $(DESTDIR){0}\n", programFilesDir);
212
212
                                        conf_vars.AppendFormat ("top_srcdir={0}\n\n",
213
213
                                                FileService.AbsoluteToRelativePath (project.BaseDirectory, ctx.TargetCombine.BaseDirectory));
214
214
 
215
 
                                        conf_vars.AppendFormat ("include $(top_srcdir)/Makefile.include\n");
216
215
                                        conf_vars.AppendFormat ("include $(top_srcdir)/config.make\n\n");
217
 
                                        if (ctx.TargetCombine.BaseDirectory != project.BaseDirectory)
218
 
                                                //Don't emit for top level project makefile(eg. pdn.make), as it would be
219
 
                                                //included by top level solution makefile
220
 
                                                conf_vars.AppendFormat ("#include $(srcdir)/custom-hooks.make\n\n");
 
216
 
 
217
                                        // Don't emit for top level project makefile(eg. pdn.make), as it would be
 
218
                                        // included by top level solution makefile
 
219
                                        if (ctx.TargetCombine.BaseDirectory != project.BaseDirectory){
 
220
                                                string customhooks = Path.Combine (project.BaseDirectory, "custom-hooks.make");
 
221
                                                bool include = File.Exists (customhooks);
 
222
                                        
 
223
                                                includes = "include $(top_srcdir)/Makefile.include\n";
 
224
                                                includes += String.Format ("{0}include $(srcdir)/custom-hooks.make\n\n", include ? "" : "#");
 
225
                                                if (include)
 
226
                                                        makefile.SetVariable ("EXTRA_DIST", "$(srcdir)/custom-hooks.make");
 
227
                                        }
221
228
                                }
222
229
 
223
230
                                bool buildEnabled;
320
327
                                                                        CustomCommandType.AfterClean}, monitor);
321
328
                                        } else {
322
329
                                                if (config.CustomCommands.Count > 0)
323
 
                                                        monitor.ReportWarning (GettextCatalog.GetString ("Custom commands are not supported for autotools based makefiles. Ignoring Ignoring.."));
 
330
                                                        monitor.ReportWarning (GettextCatalog.GetString ("Custom commands are not supported for autotools based makefiles. Ignoring."));
324
331
                                        }
325
332
 
326
333
                                        if (buildEnabled && pkgs.Count > 0)
356
363
                                                if (configSection.DeployFileVars.ContainsKey (targetDeployVar)) {
357
364
                                                        //use the dfile from the config section
358
365
                                                        DeployFile dfile = configSection.DeployFileVars [targetDeployVar];
359
 
                                                        string targetDeployFile = String.Format ("$(BUILD_DIR){0}{1}",
360
 
                                                                        Path.DirectorySeparatorChar, Path.GetFileName (dfile.RelativeTargetPath));
361
366
                                                        string fname = FileService.AbsoluteToRelativePath (
362
367
                                                                        Path.GetFullPath (project.BaseDirectory),
363
368
                                                                        Path.GetFullPath (dfile.SourcePath));
364
369
 
365
370
                                                        conf_vars.AppendFormat ("{0}_SOURCE={1}\n", targetDeployVar, fname);
366
 
                                                        if (!commonDeployVars.ContainsKey (targetDeployVar))
367
 
                                                                conf_vars.AppendFormat ("{0}={1}\n", targetDeployVar, targetDeployFile);
 
371
 
 
372
                                                        if (!commonDeployVars.ContainsKey (targetDeployVar)) {
 
373
                                                                //FOO_DLL=$(BUILD_DIR)/foo.dll
 
374
                                                                conf_vars.AppendFormat ("{0}=$(BUILD_DIR){1}{2}\n",
 
375
                                                                                targetDeployVar,
 
376
                                                                                Path.DirectorySeparatorChar,
 
377
                                                                                dfile.RelativeTargetPath);
 
378
                                                        }
368
379
                                                } else {
369
380
                                                        // not common and not part of @configSection
370
381
                                                        conf_vars.AppendFormat ("{0}=\n", pair.Key);
374
385
                                        conf_vars.Append ( "\nendif\n\n" );
375
386
                                }
376
387
 
 
388
                                conf_vars.AppendFormat ("AL={0}\n", (dotnetProject.ClrVersion == ClrVersion.Net_2_0) ? "al2" : "al");
 
389
                                conf_vars.AppendFormat ("SATELLITE_ASSEMBLY_NAME={0}.resources.dll\n", dotnetProject.DefaultNamespace);
 
390
 
377
391
                                foreach (KeyValuePair<string, DeployFile> pair in allDeployVars) {
378
392
                                        HandleDeployFile (pair.Value, pair.Key, project, ctx);
379
393
 
380
394
                                        if (commonDeployVars.ContainsKey (pair.Key)) {
381
 
                                                string targetDeployFile = String.Format ("$(BUILD_DIR){0}{1}",
382
 
                                                        Path.DirectorySeparatorChar, Path.GetFileName (pair.Value.RelativeTargetPath));
383
 
 
384
395
                                                //FOO_DLL=$(BUILD_DIR)/foo.dll
385
 
                                                deployFileCopyVars.AppendFormat ("{0} = {1}\n", pair.Key, targetDeployFile);
 
396
                                                deployFileCopyVars.AppendFormat ("{0} = $(BUILD_DIR){1}{2}\n",
 
397
                                                                        pair.Key,
 
398
                                                                        Path.DirectorySeparatorChar,
 
399
                                                                        pair.Value.RelativeTargetPath);
386
400
                                        }
387
401
                                }
388
402
 
417
431
                                templateEngine.Variables["COPY_DEPLOY_FILES_VARS"] = deployFileCopyVars.ToString();
418
432
                                templateEngine.Variables["COPY_DEPLOY_FILES_TARGETS"] = deployFileCopyTargets.ToString();
419
433
                                templateEngine.Variables["ALL_TARGET"] = (ctx.TargetCombine.BaseDirectory == project.BaseDirectory) ? "all-local" : "all";
 
434
                                templateEngine.Variables["INCLUDES"] = includes;
420
435
 
421
436
                                templateEngine.Variables["FILES"] = files.ToString();
422
437
                                templateEngine.Variables["RESOURCES"] = res_files.ToString();
423
438
                                templateEngine.Variables["EXTRAS"] = extras.ToString();
424
439
                                templateEngine.Variables["DATA_FILES"] = datafiles.ToString();
 
440
                                templateEngine.Variables["CLEANFILES"] = vars.ToString ();
425
441
 
426
442
                                if (!generateAutotools) {
427
 
                                        templateEngine.Variables["CLEANFILES"] = vars.ToString ();
428
443
                                        templateEngine.Variables["TEMPLATE_FILES_TARGETS"] = templateFilesTargets.ToString();
429
444
                                        templateEngine.Variables["INSTALL_TARGET"] = installTarget.ToString();
430
445
                                        templateEngine.Variables["UNINSTALL_TARGET"] = uninstallTarget.ToString();
498
513
                                else if (reference.ReferenceType == ReferenceType.Project)
499
514
                                        continue; // handled per-config
500
515
                                else
501
 
                                        throw new Exception ( GettextCatalog.GetString  ("Project Reference Type {0} not supported yet", 
 
516
                                        throw new Exception ( GettextCatalog.GetString  ("Project reference type '{0}' not supported yet", 
502
517
                                                        reference.ReferenceType.ToString() ) );
503
518
                        }
504
519
 
560
575
                                fname = FileService.NormalizeRelativePath (
561
576
                                                FileService.AbsoluteToRelativePath (project.BaseDirectory, full_fname));
562
577
                                infname = fname + ".in";
563
 
                                if (!generateAutotools) {
564
 
                                        templateFilesTargets.AppendFormat ("{0}: {1} $(top_srcdir)/config.make\n", fname, infname);
565
 
                                        templateFilesTargets.AppendFormat (
566
 
                                                "\tsed -e \"s,@prefix@,$(prefix),\" -e \"s,@PACKAGE@,$(PACKAGE),\" < {1} > {0}\n",
567
 
                                                fname, infname);
568
 
                                }
569
578
                                extras.AppendFormat ( "\\\n\t{0} ", infname);
570
579
 
571
580
                                //dependencyDeployFile here should be filename relative to the project
576
585
 
577
586
                        builtFiles.Add (Path.GetFileName (dfile.RelativeTargetPath));
578
587
 
579
 
                        deployFileCopyTargets.AppendFormat ("$({0}): {1}\n", targetDeployVar, dependencyDeployFile);
580
 
                        deployFileCopyTargets.AppendFormat ("\tmkdir -p $(BUILD_DIR)\n");
581
 
                        deployFileCopyTargets.AppendFormat ("\tcp '$<' '$@'\n");
582
 
                        if (!generateAutotools && (dfile.FileAttributes & DeployFileAttributes.Executable) != 0)
583
 
                                deployFileCopyTargets.AppendFormat ("\tchmod u+x '$@'\n");
584
 
                        deployFileCopyTargets.Append ("\n");
 
588
                        if (dfile.ContainsPathReferences)
 
589
                                deployFileCopyTargets.AppendFormat ("$(eval $(call emit-deploy-wrapper,{0},{1}{2}))\n",
 
590
                                        targetDeployVar,
 
591
                                        dependencyDeployFile,
 
592
                                        (dfile.FileAttributes & DeployFileAttributes.Executable) != 0 ? ",x" : String.Empty);
 
593
                        else
 
594
                                deployFileCopyTargets.AppendFormat ("$(eval $(call emit-deploy-target,{0}))\n", targetDeployVar);
585
595
 
586
596
                        switch (dfile.TargetDirectoryID) {
587
597
                                case TargetDirectory.Gac:
608
618
                        }
609
619
 
610
620
                        if (!generateAutotools) {
611
 
                                string installDir = ctx.DeployContext.GetDirectory (dfile.TargetDirectoryID);
 
621
                                string installDir = Path.GetDirectoryName (ctx.DeployContext.GetResolvedPath (dfile.TargetDirectoryID, dfile.RelativeTargetPath));
612
622
                                //FIXME: temp
613
 
                                installDir = installDir.Replace ("@prefix@", "$(prefix)");
614
 
                                installDir = installDir.Replace ("@PACKAGE@", "$(PACKAGE)");
 
623
                                installDir = TranslateDir (installDir);
615
624
 
616
 
                                if (!installDirs.Contains (installDir))
 
625
                                if (!installDirs.Contains (installDir)) {
617
626
                                        installTarget.AppendFormat ("\tmkdir -p $(DESTDIR){0}\n", installDir);
 
627
                                        installDirs.Add (installDir);
 
628
                                }
618
629
 
619
630
                                installTarget.AppendFormat ("\ttest -z '$({0})' || cp $({0}) $(DESTDIR){1}\n", targetDeployVar, installDir);
620
631
                                installDeps.AppendFormat (" $({0})", targetDeployVar);
622
633
                                uninstallTarget.AppendFormat ("\ttest -z '$({1})' || rm -f $(DESTDIR){0}/$(notdir $({1}))\n", installDir, targetDeployVar);
623
634
                        }
624
635
                }
 
636
                
 
637
                string TranslateDir (string dir)
 
638
                {
 
639
                        dir = dir.Replace ("@prefix@", "$(prefix)");
 
640
                        dir = dir.Replace ("@PACKAGE@", "$(PACKAGE)");
 
641
                        dir = dir.Replace ("@expanded_libdir@", "$(libdir)");
 
642
                        dir = dir.Replace ("@expanded_bindir@", "$(bindir)");
 
643
                        dir = dir.Replace ("@expanded_datadir@", "$(datadir)");
 
644
                        return dir;
 
645
                }
625
646
 
626
647
                void EmitCustomCommandTargets (CustomCommandCollection commands, Project project, StringBuilder builder, string configName, CustomCommandType[] types, IProgressMonitor monitor)
627
648
                {
638
659
                                                        foreach (CustomCommandType t in types)
639
660
                                                                types_list.AppendFormat ("{0}, ", t);
640
661
                                                        monitor.ReportWarning (GettextCatalog.GetString (
641
 
                                                                "Custom commands of only - {0} - types are supported.", types_list.ToString ()));
 
662
                                                                "Custom commands of only the following types are supported: {0}.", types_list.ToString ()));
642
663
                                                        warned = true;
643
664
                                                }
644
665
                                                continue;
720
741
                        
721
742
                        return refp;
722
743
                }
 
744
                
723
745
        }
724
746
}
725
747