TEST(ServerOptions, ParsesConfigurationFiles) { Common::Configuration config = Common::ParseConfigurationFiles(TestConfigPath); std::vector<Common::AddonInformation> addons(config.Modules.size()); std::transform(std::begin(config.Modules), std::end(config.Modules), std::begin(addons), [](const Common::ModuleConfiguration & module) { return Common::GetAddonInfomation(module); }); ASSERT_EQ(addons.size(), 1); const Common::AddonInformation & module = addons.front(); ASSERT_EQ(module.Id, "child_module"); //ASSERT_EQ(module.Path, "child_module.so"); ASSERT_EQ(module.Dependencies.size(), 2); ASSERT_EQ(module.Dependencies[0], "parent_module1"); ASSERT_EQ(module.Dependencies[1], "parent_module2"); ASSERT_EQ(module.Parameters.Parameters.size(), 5); ASSERT_EQ(module.Parameters.Parameters[0].Name, "application_name"); ASSERT_EQ(module.Parameters.Parameters[0].Value, "Test OPC UA Server"); ASSERT_EQ(module.Parameters.Groups.size(), 2); ASSERT_EQ(module.Parameters.Groups[0].Name, "user_token_policy"); ASSERT_EQ(module.Parameters.Groups[0].Parameters.size(), 3); ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Name, "id"); ASSERT_EQ(module.Parameters.Groups[0].Parameters[0].Value, "anonymous"); ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Name, "type"); ASSERT_EQ(module.Parameters.Groups[0].Parameters[1].Value, "anonymous"); }
//-------------------------------------------------------------- void testApp::setup(){ //ofSetLogLevel(OF_LOG_NOTICE); project = NULL; while(!checkConfigExists()){ askOFRoot(); } setOFRoot(getOFRootFromConfig()); setupDrawableOFPath(); int targ = ofGetTargetPlatform(); //plat = OF_TARGET_IPHONE; setupForTarget(targ); if(projectPath!="" || buildAllExamples){ for(int i = 0; i < (int)targetsToMake.size(); i++){ setupForTarget(targetsToMake[i]); if(buildAllExamples){ generateExamples(); }else{ project->setup(target); project->create(projectPath); vector < string > addons; parseAddonsDotMake(project->getPath() + "addons.make", addons); for (int i = 0; i < (int)addons.size(); i++){ ofAddon addon; addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target); project->addAddon(addon); } project->save(false); } } std::exit(0); } #ifndef COMMAND_LINE_ONLY panelAddons.setup(); ofDirectory addons(ofFilePath::join(getOFRoot(),"addons")); addons.listDir(); for(int i=0;i<(int)addons.size();i++){ string addon = addons.getName(i); if(addon.find("ofx")==0){ ofxToggle * toggle = new ofxToggle(); panelAddons.add(toggle->setup(addon,false,300)); } } panelOptions.setup("","settings.xml",ofGetWidth()-panelAddons.getWidth()-10,120); panelOptions.add(createProject.setup("create project",300)); panelOptions.add(updateProject.setup("update project",300)); panelOptions.add(createAndOpen.setup("create and open project",300)); panelOptions.add(changeOFRoot.setup("change OF path",300)); createProject.addListener(this,&testApp::createProjectPressed); updateProject.addListener(this,&testApp::updateProjectPressed); createAndOpen.addListener(this,&testApp::createAndOpenPressed); changeOFRoot.addListener(this,&testApp::changeOFRootPressed); examplesPanel.setup("generate examples", "examples.xml", 400, 10); examplesPanel.add(generateButton.setup("<--Generate")); examplesPanel.add(wincbToggle.setup("win CB projects",ofGetTargetPlatform()==OF_TARGET_WINGCC)); examplesPanel.add(winvsToggle.setup("win VS projects", ofGetTargetPlatform()==OF_TARGET_WINVS)); examplesPanel.add(linuxcbToggle.setup("linux CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX)); examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX64)); examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX)); examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE)); generateButton.addListener(this,&testApp::generateExamplesCB); ofSetVerticalSync(true); ofEnableAlphaBlending(); ofSetFrameRate(60); #else std::exit(0); #endif }
//-------------------------------------------------------------- void testApp::setup(){ ofEnableAlphaBlending(); ofSetLogLevel(OF_LOG_VERBOSE); ofSetVerticalSync(true); statusEnergy = 0; mode = 0; bInited = false; project = NULL; sketchName = "mySketch"; //------------------------------------- // get settings //------------------------------------- XML.loadFile("settings/projectGeneratorSettings.xml"); appToRoot = XML.getValue("appToRoot", "../../../../"); defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps"); //------------------------------------- // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc) //------------------------------------- // if appToRoot is wrong, we have alot of issues. all these paths are used in this project: #ifdef TARGET_OSX string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../")); #else string binPath = ofFilePath::getCurrentExeDir(); #endif string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot)); addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons")); sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc)); convertWindowsToUnixPath(ofRoot); convertWindowsToUnixPath(addonsPath); convertWindowsToUnixPath(sketchPath); // there's some issues internally in OF with non unix paths for OF root setOFRoot(ofRoot); //------------------------------------- // get settings //------------------------------------- //------------------------------------- // load font and setup the buttons font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90); titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90); secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90); // Sketch button // button.font = &font; button.secondFont = &secondFont; button.prefix = "Name: "; button.topLeftAnchor.set(76, 160+40); //set top button position - others are set relative to this. button.setText(sketchName); button.secondaryText = "<< CLICK TO CHANGE THE NAME"; buttons.push_back(button); // Path button // button.deliminater = "/"; button.prefix = "Path: "; button.setText(sketchPath); button.secondaryText = "<< CLICK TO CHANGE THE DIRECTORY"; button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); buttons.push_back(button); // Platform text // button.deliminater = ", "; button.prefix = "Platforms: "; button.secondaryText = ""; button.bDrawLong = false; button.secondaryText = ""; button.bSelectable = false; button.setText(platform); button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); buttons.push_back(button); // Addons button // button.deliminater = ", "; button.bDrawLong = true; button.prefix = "Addons: "; button.secondaryText = "<< CLICK TO SELECT ADDONS"; button.bSelectable = true; button.setText(addons); button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); buttons.push_back(button); // Generate // generateButton = button; generateButton.topLeftAnchor.set(906, 535); //generateButton.setColor(ofColor(50, 150, 255)); generateButton.deliminater = ","; generateButton.prefix = "GENERATE PROJECT"; generateButton.bSelectable = true; generateButton.setText(""); generateButton.bDrawLong = false; addonButton = button; addonButton.topLeftAnchor.set(906, 535); addonButton.prefix = "<< BACK"; addonButton.setText(""); addonButton.bDrawLong = false; for (int i = 0; i < buttons.size(); i++){ buttons[i].calculateRect(); } addonButton.calculateRect(); generateButton.calculateRect(); //------------------------------------- // addons panels: //------------------------------------- panelCoreAddons.setup(); panelOtherAddons.setup(); ofDirectory addons(addonsPath); addons.listDir(); for(int i=0;i<(int)addons.size();i++){ string addon = addons.getName(i); if(addon.find("ofx")==0){ if (isAddonCore(addon)){ ofxToggle * toggle = new ofxToggle(); panelCoreAddons.add(toggle->setup(addon,false,300)); } else { bHaveNonCoreAddons = true; ofxToggle * toggle = new ofxToggle(); panelOtherAddons.add(toggle->setup(addon,false,300)); } } } //------------------------------------- // platform panel (not used, really, but here just in case) //------------------------------------- panelPlatforms.setup(); panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC)); panelPlatforms.add(winvsToggle.setup("windows (visual studio)", ofGetTargetPlatform()==OF_TARGET_WINVS)); panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX)); panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64)); //for ios, we need to fake that the target is ios (since we're compiling w/ osx OF) //#define MAKE_IOS #ifdef MAKE_IOS panelPlatforms.add(osxToggle.setup("osx (xcode)",false)); panelPlatforms.add(iosToggle.setup("ios (xcode)",true)); #else panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX)); panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE)); #endif // update the platforms text in the platform button string platforms = ""; for (int i = 0; i < panelPlatforms.getNumControls(); i++){ if (*((ofxToggle *)panelPlatforms.getControl(i))){ if (platforms.length() > 0) platforms+=", "; platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName(); }; } buttons[2].setText(platforms); panelPlatforms.setPosition(10,40); panelCoreAddons.setPosition(10,40); panelOtherAddons.setPosition(330,40); logo.loadImage("images/ofw-logo.png"); ofBackground(230,230,230); generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - generateButton.rect.width + 10 , ofGetHeight() - generateButton.rect.height - 40);// 535); generateButton.calculateRect(); addonButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - addonButton.rect.width + 10 , ofGetHeight() - addonButton.rect.height - 40);// 535); addonButton.calculateRect(); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetLogLevel(OF_LOG_VERBOSE); ofSetVerticalSync(true); mode = 0; bInited = false; project = NULL; sketchName = "mySketch"; //------------------------------------- // get settings //------------------------------------- XML.loadFile("projectGeneratorSettings.xml"); appToRoot = XML.getValue("appToRoot", "../../../../"); defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps"); //------------------------------------- // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc) //------------------------------------- // if appToRoot is wrong, we have alot of issues. all these paths are used in this project: #ifdef TARGET_OSX string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../")); #else string binPath = ofFilePath::getCurrentExeDir(); #endif string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot)); setOFRoot(ofRoot); addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons")); sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc)); //------------------------------------- // get settings //------------------------------------- //------------------------------------- // load font and setup the buttons font.loadFont("frabk.ttf", 12, false, false); // sketch button button.font = &font; button.prefix = "name: "; button.setText(sketchName); buttons.push_back(button); // path button button.deliminater = "/"; button.prefix = "path: "; button.setText(sketchPath); buttons.push_back(button); button.deliminater = ", "; button.prefix = "platforms: "; button.bSelectable = false; button.setText(platform); button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); buttons.push_back(button); button.deliminater = ", "; button.prefix = "addons: "; button.bSelectable = true; button.setText(addons); button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); buttons.push_back(button); button.deliminater = ","; button.prefix = "generate"; button.bSelectable = true; button.setText(""); button.topLeftAnchor.set(50,ofGetHeight()-80); buttons.push_back(button); addonButton = button; addonButton.prefix = "< back"; addonButton.setText(""); for (int i = 0; i < buttons.size(); i++){ buttons[i].calculateRect(); } addonButton.calculateRect(); //------------------------------------- // addons panels: //------------------------------------- panelCoreAddons.setup(); panelOtherAddons.setup(); ofDirectory addons(addonsPath); addons.listDir(); for(int i=0;i<(int)addons.size();i++){ string addon = addons.getName(i); cout << "adding addon " << addon << endl; if(addon.find("ofx")==0){ if (isAddonCore(addon)){ ofxToggle * toggle = new ofxToggle(); panelCoreAddons.add(toggle->setup(addon,false,300)); } else { ofxToggle * toggle = new ofxToggle(); panelOtherAddons.add(toggle->setup(addon,false,300)); } } } //------------------------------------- // platform panel (not used, really, but here just in case) //------------------------------------- panelPlatforms.setup(); panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC)); panelPlatforms.add(winvsToggle.setup("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS)); panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX)); panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64)); panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX)); panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE)); // update the platforms text in the platform button string platforms = ""; for (int i = 0; i < panelPlatforms.getNumControls(); i++){ if (*((ofxToggle *)panelPlatforms.getControl(i))){ if (platforms.length() > 0) platforms+=", "; platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName(); }; } buttons[2].setText(platforms); panelPlatforms.setPosition(300,0); panelCoreAddons.setPosition(300,0); panelOtherAddons.setPosition(750,0); }